Skip to content

Commit ba38ad7

Browse files
author
Elliott Slaughter
committed
---
yaml --- r: 32441 b: refs/heads/dist-snap c: 578b036 h: refs/heads/master i: 32439: 2ae91fc v: v3
1 parent 0ccf7dc commit ba38ad7

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
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: 7823ad8586f52bcd6277965277bd15ff15674219
10+
refs/heads/dist-snap: 578b036f9b0415852aae0af9286ff53630fa1c56
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/dist-snap/src/libcore/gc.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,18 +167,33 @@ fn RootSet() -> RootSet {
167167
LinearMap()
168168
}
169169

170+
#[cfg(gc)]
171+
fn expect_sentinel() -> bool { true }
172+
173+
#[cfg(nogc)]
174+
fn expect_sentinel() -> bool { false }
175+
170176
// This should only be called from fail, as it will drop the roots
171177
// which are *live* on the stack, rather than dropping those that are
172178
// dead.
173179
fn cleanup_stack_for_failure() {
174180
unsafe {
175-
// Leave a sentinel on the stack to mark the current
176-
// frame. The stack walker will ignore any frames above the
177-
// sentinel, thus avoiding collecting any memory being used by
178-
// the stack walker itself.
181+
// Leave a sentinel on the stack to mark the current frame. The
182+
// stack walker will ignore any frames above the sentinel, thus
183+
// avoiding collecting any memory being used by the stack walker
184+
// itself.
185+
//
186+
// However, when core itself is not compiled with GC, then none of
187+
// the functions in core will have GC metadata, which means we
188+
// won't be able to find the sentinel root on the stack. In this
189+
// case, we can safely skip the sentinel since we won't find our
190+
// own stack roots on the stack anyway.
179191
let sentinel_box = ~0;
180-
let sentinel: **Word =
181-
unsafe::reinterpret_cast(&ptr::addr_of(sentinel_box));
192+
let sentinel: **Word = if expect_sentinel() {
193+
unsafe::reinterpret_cast(&ptr::addr_of(sentinel_box))
194+
} else {
195+
ptr::null()
196+
};
182197

183198
let mut roots = ~RootSet();
184199
for walk_gc_roots(need_cleanup, sentinel) |root, tydesc| {

0 commit comments

Comments
 (0)