Skip to content

Commit dd6236f

Browse files
author
Elliott Slaughter
committed
---
yaml --- r: 23785 b: refs/heads/master c: cb53623 h: refs/heads/master i: 23783: 7052506 v: v3
1 parent 69a20e8 commit dd6236f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 244b95490b9f0ca5c7ab38455153b421b0b51818
2+
refs/heads/master: cb5362334134f1d0d8b2c5557c49ee6534526474
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libcore/gc.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ unsafe fn align_to_pointer<T>(ptr: *T) -> *T {
6565
return unsafe::reinterpret_cast(&ptr);
6666
}
6767

68+
unsafe fn get_safe_point_count() -> uint {
69+
let module_meta = rustrt::rust_gc_metadata();
70+
return *module_meta;
71+
}
72+
6873
type SafePoint = { sp_meta: *Word, fn_meta: *Word };
6974

7075
// 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) {
260265

261266
fn gc() {
262267
unsafe {
268+
// Abort when GC is disabled.
269+
if get_safe_point_count() == 0 {
270+
return;
271+
}
272+
263273
for walk_gc_roots(task_local_heap, ptr::null()) |_root, _tydesc| {
264274
// FIXME(#2997): Walk roots and mark them.
265275
io::stdout().write([46]); // .
@@ -288,6 +298,11 @@ fn expect_sentinel() -> bool { false }
288298
// dead.
289299
fn cleanup_stack_for_failure() {
290300
unsafe {
301+
// Abort when GC is disabled.
302+
if get_safe_point_count() == 0 {
303+
return;
304+
}
305+
291306
// Leave a sentinel on the stack to mark the current frame. The
292307
// stack walker will ignore any frames above the sentinel, thus
293308
// avoiding collecting any memory being used by the stack walker

0 commit comments

Comments
 (0)