diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-02-09 22:28:52 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-02-09 22:58:40 -0800 |
| commit | d493438c9805ff82b45aa5c40941c05311794130 (patch) | |
| tree | 9c1e02f74a9f550333ec55110cdacad808e1b8c6 /src/rt/rust_task.cpp | |
| parent | d90a9d3da0f8c77d98bd38148d78db95f7f8fc5a (diff) | |
| download | rust-d493438c9805ff82b45aa5c40941c05311794130.tar.gz rust-d493438c9805ff82b45aa5c40941c05311794130.zip | |
rt: Disable some expensive asserts
Diffstat (limited to 'src/rt/rust_task.cpp')
| -rw-r--r-- | src/rt/rust_task.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp index 815830e1974..b2b2753476a 100644 --- a/src/rt/rust_task.cpp +++ b/src/rt/rust_task.cpp @@ -673,6 +673,17 @@ rust_task::record_stack_limit() { record_sp(stk->data + LIMIT_OFFSET + RED_ZONE_SIZE); } +static bool +sp_in_stk_seg(uintptr_t sp, stk_seg *stk) { + // Not positive these bounds for sp are correct. I think that the first + // possible value for esp on a new stack is stk->end, which points to the + // address before the first value to be pushed onto a new stack. The last + // possible address we can push data to is stk->data. Regardless, there's + // so much slop at either end that we should never hit one of these + // boundaries. + return (uintptr_t)stk->data <= sp && sp <= stk->end; +} + /* Called by landing pads during unwinding to figure out which stack segment we are currently running on, delete the others, @@ -700,6 +711,25 @@ rust_task::config_notify(chan_handle chan) { notify_chan = chan; } +/* +Returns true if we're currently running on the Rust stack + */ +bool +rust_task::on_rust_stack() { + uintptr_t sp = get_sp(); + bool in_first_segment = sp_in_stk_seg(sp, stk); + if (in_first_segment) { + return true; + } else if (stk->next != NULL) { + // This happens only when calling the upcall to delete + // a stack segment + bool in_second_segment = sp_in_stk_seg(sp, stk->next); + return in_second_segment; + } else { + return false; + } +} + // // Local Variables: // mode: C++ |
