3
3
//! We can use Cargo features to choose one of `ImmixSpace` (default), `ImmortalSpace` and
4
4
//! `MarkSweepSpace` as the non-moving space.
5
5
6
- use crate :: { util:: VMWorkerThread , vm:: VMBinding , AllocationSemantics , Mutator } ;
6
+ use crate :: {
7
+ plan:: ReservedAllocators ,
8
+ util:: { alloc:: AllocatorSelector , VMWorkerThread } ,
9
+ vm:: VMBinding ,
10
+ AllocationSemantics , Mutator ,
11
+ } ;
7
12
8
13
use super :: space:: { PlanCreateSpaceArgs , Space } ;
9
14
@@ -21,6 +26,8 @@ pub(crate) trait NonMovingSpace<VM: VMBinding>: Space<VM> {
21
26
fn end_of_gc_nonmoving_space ( & mut self ) ;
22
27
/// Call this in `common_release_func` when using this space as the non-moving space.
23
28
fn release_mutator_nonmoving_space ( mutator : & mut Mutator < VM > , tls : VMWorkerThread ) ;
29
+ /// Call this to reserve allocator in `create_space_mapping`.
30
+ fn reserve_allocator ( reserved : & mut ReservedAllocators ) -> AllocatorSelector ;
24
31
}
25
32
26
33
impl < VM : VMBinding > NonMovingSpace < VM > for crate :: policy:: immortalspace:: ImmortalSpace < VM > {
@@ -43,6 +50,10 @@ impl<VM: VMBinding> NonMovingSpace<VM> for crate::policy::immortalspace::Immorta
43
50
fn release_mutator_nonmoving_space ( _mutator : & mut Mutator < VM > , _tls : VMWorkerThread ) {
44
51
// Do nothing
45
52
}
53
+
54
+ fn reserve_allocator ( reserved : & mut ReservedAllocators ) -> AllocatorSelector {
55
+ reserved. add_bump_pointer_allocator ( )
56
+ }
46
57
}
47
58
48
59
impl < VM : VMBinding > NonMovingSpace < VM >
@@ -75,6 +86,10 @@ impl<VM: VMBinding> NonMovingSpace<VM>
75
86
. unwrap ( )
76
87
. release ( ) ;
77
88
}
89
+
90
+ fn reserve_allocator ( reserved : & mut ReservedAllocators ) -> AllocatorSelector {
91
+ reserved. add_malloc_allocator ( )
92
+ }
78
93
}
79
94
80
95
impl < VM : VMBinding > NonMovingSpace < VM > for crate :: policy:: immix:: ImmixSpace < VM > {
@@ -113,6 +128,10 @@ impl<VM: VMBinding> NonMovingSpace<VM> for crate::policy::immix::ImmixSpace<VM>
113
128
. unwrap ( )
114
129
. reset ( ) ;
115
130
}
131
+
132
+ fn reserve_allocator ( reserved : & mut ReservedAllocators ) -> AllocatorSelector {
133
+ reserved. add_immix_allocator ( )
134
+ }
116
135
}
117
136
118
137
// Choose one concrete non-moving space implementation according to the enabled Cargo feature.
0 commit comments