/* Called by landing pads during unwinding to figure out which stack segment we are currently running on and record the stack limit (which was not restored when unwinding through __morestack). */ void rust_task::reset_stack_limit() { uintptr_t sp = get_sp(); while (!sp_in_stk_seg(sp, stk)) { prev_stack(); assert(stk != NULL && "Failed to find the current stack"); } }
void reset_stack_limit_on_c_stack(reset_args *args) { rust_task *task = args->task; uintptr_t sp = args->sp; while (!sp_in_stk_seg(sp, task->stk)) { task->stk = task->stk->prev; assert(task->stk != NULL && "Failed to find the current stack"); } task->record_stack_limit(); }
/* Returns true if we're currently running on the Rust stack */ bool rust_task::on_rust_stack() { if (stk == NULL) { // This only happens during construction return false; } uintptr_t sp = get_sp(); bool in_first_segment = sp_in_stk_seg(sp, stk); if (in_first_segment) { return true; } else if (stk->prev != NULL) { // This happens only when calling the upcall to delete // a stack segment bool in_second_segment = sp_in_stk_seg(sp, stk->prev); return in_second_segment; } else { return false; } }