diff options
| author | Elliott Slaughter <eslaughter@mozilla.com> | 2012-09-06 21:22:50 -0700 |
|---|---|---|
| committer | Elliott Slaughter <eslaughter@mozilla.com> | 2012-09-07 09:21:22 -0700 |
| commit | cb5362334134f1d0d8b2c5557c49ee6534526474 (patch) | |
| tree | 3ec161e922820a13222f5bae9408d1b5f2a316fe /src/libcore | |
| parent | 244b95490b9f0ca5c7ab38455153b421b0b51818 (diff) | |
gc: Add early abort when GC is disabled.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/gc.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libcore/gc.rs b/src/libcore/gc.rs index 2c68607c6d4..d99fc631bef 100644 --- a/src/libcore/gc.rs +++ b/src/libcore/gc.rs @@ -65,6 +65,11 @@ unsafe fn align_to_pointer<T>(ptr: *T) -> *T { return unsafe::reinterpret_cast(&ptr); } +unsafe fn get_safe_point_count() -> uint { + let module_meta = rustrt::rust_gc_metadata(); + return *module_meta; +} + type SafePoint = { sp_meta: *Word, fn_meta: *Word }; // Returns the safe point metadata for the given program counter, if @@ -260,6 +265,11 @@ unsafe fn walk_gc_roots(mem: Memory, sentinel: **Word, visitor: Visitor) { fn gc() { unsafe { + // Abort when GC is disabled. + if get_safe_point_count() == 0 { + return; + } + for walk_gc_roots(task_local_heap, ptr::null()) |_root, _tydesc| { // FIXME(#2997): Walk roots and mark them. io::stdout().write([46]); // . @@ -288,6 +298,11 @@ fn expect_sentinel() -> bool { false } // dead. fn cleanup_stack_for_failure() { unsafe { + // Abort when GC is disabled. + if get_safe_point_count() == 0 { + return; + } + // Leave a sentinel on the stack to mark the current frame. The // stack walker will ignore any frames above the sentinel, thus // avoiding collecting any memory being used by the stack walker |
