rt: Disable some expensive asserts

This commit is contained in:
Brian Anderson
2012-02-09 22:28:52 -08:00
parent d90a9d3da0
commit d493438c98
3 changed files with 40 additions and 33 deletions

View File

@@ -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++