Skip to content
This repository was archived by the owner on Jun 10, 2024. It is now read-only.

Commit bc18568

Browse files
committed
cargo fmt
1 parent f6946fe commit bc18568

File tree

23 files changed

+288
-192
lines changed

23 files changed

+288
-192
lines changed

liblumen_alloc/src/erts/process.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ use core::mem;
1111
use core::ptr::{self, NonNull};
1212
use core::sync::atomic::{AtomicUsize, Ordering};
1313

14-
use intrusive_collections::{LinkedList, UnsafeRef};
1514
use hashbrown::HashMap;
15+
use intrusive_collections::{LinkedList, UnsafeRef};
1616
use liblumen_core::locks::SpinLock;
1717

18-
1918
use self::gc::*;
2019
use super::*;
2120
use crate::borrow::CloneToProcess;
@@ -137,7 +136,7 @@ impl ProcessControlBlock {
137136

138137
/// Frees stack space occupied by the last term on the stack,
139138
/// adjusting the stack pointer accordingly.
140-
///
139+
///
141140
/// Use `stack_popn` to pop multiple terms from the stack at once
142141
#[inline]
143142
pub fn stack_pop(&mut self) -> Option<Term> {
@@ -151,7 +150,7 @@ impl ProcessControlBlock {
151150
}
152151

153152
/// Pushes an immediate term or reference to term/list on top of the stack
154-
///
153+
///
155154
/// Returns `Err(AllocErr)` if the process is out of stack space
156155
#[inline]
157156
pub fn stack_push(&mut self, term: Term) -> Result<(), AllocErr> {

liblumen_alloc/src/erts/process/alloc.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ use core::alloc::{AllocErr, Layout};
22
use core::mem;
33
use core::ptr::NonNull;
44

5-
use lazy_static::lazy_static;
6-
use heapless::Vec;
75
#[cfg(target_pointer_width = "64")]
86
use heapless::consts::U152 as UHEAP_SIZES_LEN;
97
#[cfg(target_pointer_width = "32")]
108
use heapless::consts::U57 as UHEAP_SIZES_LEN;
9+
use heapless::Vec;
10+
use lazy_static::lazy_static;
1111

1212
use liblumen_alloc_macros::generate_heap_sizes;
1313
use liblumen_core::alloc::mmap;
@@ -214,7 +214,7 @@ pub trait AllocInProcess {
214214
/// Perform a stack allocation of `size` words to hold a single term.
215215
///
216216
/// Returns `Err(AllocErr)` if there is not enough space available
217-
///
217+
///
218218
/// NOTE: Do not use this to allocate space for multiple terms (lists
219219
/// and boxes count as a single term), as the size of the stack in terms
220220
/// is tied to allocations. Each time `stack_alloc` is called, the stack
@@ -268,9 +268,9 @@ pub trait StackPrimitives {
268268
fn stack_size(&self) -> usize;
269269

270270
/// Manually sets the stack size
271-
///
271+
///
272272
/// # Safety
273-
///
273+
///
274274
/// This is super unsafe, its only use is when constructing objects such as lists
275275
/// on the stack incrementally, thus representing a single logical term but composed
276276
/// of many small allocations. As `alloca_*` increments the `stack_size` value each
@@ -282,11 +282,11 @@ pub trait StackPrimitives {
282282
fn stack_pointer(&mut self) -> *mut Term;
283283

284284
/// Manually sets the stack pointer to the given pointer
285-
///
285+
///
286286
/// NOTE: This will panic if the stack pointer is outside the process heap
287-
///
287+
///
288288
/// # Safety
289-
///
289+
///
290290
/// This is obviously super unsafe, but is useful as an optimization in some
291291
/// cases where a stack allocated object is being constructed but fails partway,
292292
/// and needs to be freed
@@ -299,10 +299,10 @@ pub trait StackPrimitives {
299299
fn stack_available(&self) -> usize;
300300

301301
/// This function returns the term located in the given stack slot, if it exists.
302-
///
302+
///
303303
/// The stack slots are 1-indexed, where `1` is the top of the stack, or most recent
304-
/// allocation, and `S` is the bottom of the stack, or oldest allocation.
305-
///
304+
/// allocation, and `S` is the bottom of the stack, or oldest allocation.
305+
///
306306
/// If `S > stack_size`, then `None` is returned. Otherwise, `Some(Term)` is returned.
307307
#[inline]
308308
fn stack_slot(&mut self, n: usize) -> Option<Term>;
@@ -316,4 +316,4 @@ pub trait StackPrimitives {
316316
/// number of terms allocated on the stack
317317
#[inline]
318318
fn stack_popn(&mut self, n: usize);
319-
}
319+
}

liblumen_alloc/src/erts/process/gc/collector.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ impl<'p> GarbageCollector<'p> {
192192
// Move the stack to the end of the new heap
193193
let old_stack_start = self.process.young.stack_pointer();
194194
let old_stack_slots = self.process.young.stack_size();
195-
unsafe {
195+
unsafe {
196196
let new_stack_start = new_heap.alloca_unchecked(stack_size).as_ptr();
197197
ptr::copy_nonoverlapping(old_stack_start, new_stack_start, stack_size);
198198
new_heap.set_stack_pointer(new_stack_start);
@@ -425,7 +425,12 @@ impl<'p> GarbageCollector<'p> {
425425
// most references on the new heap point to the old heap so the next stage
426426
// is to scan through the new heap, evacuating data to the new heap until all
427427
// live references have been moved
428-
new_young.sweep(&mut self.process.young, &mut self.process.old, mature, mature_end);
428+
new_young.sweep(
429+
&mut self.process.young,
430+
&mut self.process.old,
431+
mature,
432+
mature_end,
433+
);
429434

430435
// If we have been tenuring (we have an old generation and have moved values into it),
431436
// then those newly tenured values may hold references into the old young generation
@@ -571,4 +576,4 @@ impl<'p> GarbageCollector<'p> {
571576
fn sanity_check(&self) {
572577
self.process.young.sanity_check()
573578
}
574-
}
579+
}

liblumen_alloc/src/erts/process/gc/old_heap.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
use core::fmt;
12
use core::mem;
23
use core::ptr;
3-
use core::fmt;
44

55
use crate::erts::*;
66

77
use liblumen_core::util::pointer::*;
88

9-
use super::{YoungHeap, VirtualBinaryHeap};
9+
use super::{VirtualBinaryHeap, YoungHeap};
1010

1111
/// This type represents the old generation process heap
1212
///
@@ -32,7 +32,7 @@ impl OldHeap {
3232
let top = start;
3333
let vheap = VirtualBinaryHeap::new(size);
3434
Self {
35-
start,
35+
start,
3636
end,
3737
top,
3838
vheap,
@@ -366,7 +366,8 @@ impl Drop for OldHeap {
366366
fn drop(&mut self) {
367367
unsafe {
368368
if self.active() {
369-
// Free virtual binary heap, we can't free the memory of this heap until we've done this
369+
// Free virtual binary heap, we can't free the memory of this heap until we've done
370+
// this
370371
self.vheap.clear();
371372
// Free memory region managed by this heap instance
372373
process::alloc::free(self.start, self.size());
@@ -378,7 +379,8 @@ impl fmt::Debug for OldHeap {
378379
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
379380
f.write_fmt(format_args!(
380381
"OldHeap (heap: {:?}-{:?}, used: {}, unused: {}) [\n",
381-
self.start, self.top,
382+
self.start,
383+
self.top,
382384
self.heap_used(),
383385
self.heap_available(),
384386
))?;
@@ -400,4 +402,4 @@ impl fmt::Debug for OldHeap {
400402
f.write_fmt(format_args!(" {:?}: END OF HEAP", pos))?;
401403
f.write_str("]\n")
402404
}
403-
}
405+
}

liblumen_alloc/src/erts/process/gc/virtual_heap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,4 +164,4 @@ impl VirtualBinaryHeap {
164164
}
165165
}
166166
}
167-
}
167+
}

0 commit comments

Comments
 (0)