Skip to content

Commit f456427

Browse files
author
Elliott Slaughter
committed
---
yaml --- r: 32447 b: refs/heads/dist-snap c: cb53623 h: refs/heads/master i: 32445: 55cb551 32443: a032d1f 32439: 2ae91fc 32431: e0f5a2a 32415: 5d84939 32383: ebe5b0e v: v3
1 parent 19325df commit f456427

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
@@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10-
refs/heads/dist-snap: 244b95490b9f0ca5c7ab38455153b421b0b51818
10+
refs/heads/dist-snap: cb5362334134f1d0d8b2c5557c49ee6534526474
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/dist-snap/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)