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

Commit 9190a8a

Browse files
authored
Merge pull request #194 from lumen/gc/tests
Fixes and improvements to term/alloc implementation
2 parents 73d80c5 + f785dd0 commit 9190a8a

35 files changed

+3988
-1262
lines changed

Cargo.lock

Lines changed: 47 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

liblumen_alloc/Cargo.toml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,18 @@ authors = ["Paul Schoenfelder <paulschoenfelder@gmail.com>"]
55
publish = false
66
edition = "2018"
77

8+
[features]
9+
# Turns on allocation instrumentation
10+
instrument = []
11+
812
[dependencies]
913
log = "0.4"
1014
cfg-if = "0.1"
1115
lazy_static = "1.2"
1216
num-traits = "0.2"
1317
num-bigint = "0.2"
1418
thread_local = "0.3"
19+
heapless = { git = "https://github.com/japaric/heapless" }
1520
liblumen_core = { path = "../liblumen_core" }
1621
liblumen_arena = { path = "../liblumen_arena"}
1722
liblumen_alloc_macros = { path = "../liblumen_alloc_macros" }
@@ -26,13 +31,12 @@ features = ["nightly"]
2631
version = "0.7"
2732
features = ["nightly"]
2833

34+
[dependencies.static_assertions]
35+
version = "0.3"
36+
features = ["nightly"]
37+
2938
[target.'cfg(target_arch = "wasm32")'.dependencies]
3039
wasm-bindgen = "0.2"
3140

3241
[dev-dependencies]
3342
pretty_assertions = "0.6"
34-
quickcheck_macros = "0.8"
35-
36-
[dev-dependencies.quickcheck]
37-
version = "0.8"
38-
features = ["unstable"]

liblumen_alloc/src/borrow/clone_to_process.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::erts::{ProcessControlBlock, Term};
1+
use crate::erts::{AllocInProcess, Term};
22

33
/// This trait represents cloning, like `Clone`, but specifically
44
/// in the context of terms which need to be cloned into the heap
@@ -14,8 +14,8 @@ use crate::erts::{ProcessControlBlock, Term};
1414
/// NOTE: You can implement both `CloneInProcess` and `Clone` for a type,
1515
/// just be aware that any uses of `Clone` will allocate on the global heap
1616
pub trait CloneToProcess {
17-
/// Returns a copy of this value, performing any heap allocations
17+
/// Returns boxed copy of this value, performing any heap allocations
1818
/// using the process heap of `process`, or using heap fragments if
1919
/// there is not enough space for the cloned value
20-
fn clone_to_process(&self, process: &mut ProcessControlBlock) -> Term;
20+
fn clone_to_process<A: AllocInProcess>(&self, process: &mut A) -> Term;
2121
}

liblumen_alloc/src/erts/fragment.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl RawFragment {
3838

3939
/// Returns true if the given pointer is contained within this fragment
4040
#[inline]
41-
pub fn contains(&self, ptr: *const Term) -> bool {
41+
pub fn contains<T>(&self, ptr: *const T) -> bool {
4242
let ptr = ptr as usize;
4343
let start = self.data as usize;
4444
let end = unsafe { self.data.offset(self.size as isize) } as usize;
@@ -68,7 +68,7 @@ impl HeapFragment {
6868

6969
/// Returns true if the given pointer is contained within this fragment
7070
#[inline]
71-
pub fn contains(&self, ptr: *const Term) -> bool {
71+
pub fn contains<T>(&self, ptr: *const T) -> bool {
7272
self.raw.contains(ptr)
7373
}
7474

0 commit comments

Comments
 (0)