You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BasePlan should contain all plan-related state and functions that are _fundamental_ to _all_ plans. These include VM-specific (but not plan-specific) features such as a code space or vm space, which are fundamental to all plans for a given VM. Features that are common to _many_ (but not intrinsically _all_) plans should instead be included in CommonPlan.
371
377
*/
372
378
pubstructBasePlan<VM:VMBinding>{
373
-
// Whether MMTk is now ready for collection. This is set to true when enable_collection() is called.
379
+
/// Whether MMTk is now ready for collection. This is set to true when initialize_collection() is called.
374
380
pubinitialized:AtomicBool,
381
+
/// Should we trigger a GC when the heap is full? It seems this should always be true. However, we allow
382
+
/// bindings to temporarily disable GC, at which point, we do not trigger GC even if the heap is full.
/// This test allocates after calling initialize_collection(). When we exceed the heap limit, MMTk will trigger a GC. And block_for_gc will be called.
6
+
/// We havent implemented block_for_gc so it will panic. This test is similar to allocate_with_initialize_collection, except that we once disabled GC in the test.
7
+
#[test]
8
+
#[should_panic(expected = "block_for_gc is not implemented")]
9
+
pubfnallocate_with_re_enable_collection(){
10
+
constMB:usize = 1024*1024;
11
+
// 1MB heap
12
+
gc_init(MB);
13
+
initialize_collection(VMThread::UNINITIALIZED);
14
+
let handle = bind_mutator(VMMutatorThread(VMThread::UNINITIALIZED));
15
+
// Allocate 1MB. It should be fine.
16
+
let addr = alloc(handle,MB,8,0,AllocationSemantics::Default);
17
+
assert!(!addr.is_zero());
18
+
// Disable GC. So we can keep allocate without triggering a GC.
19
+
disable_collection();
20
+
let addr = alloc(handle,MB,8,0,AllocationSemantics::Default);
21
+
assert!(!addr.is_zero());
22
+
// Enable GC again. When we allocate, we should see a GC triggered immediately.
23
+
enable_collection();
24
+
let addr = alloc(handle,MB,8,0,AllocationSemantics::Default);
0 commit comments