rt: Switch to the C stack in reset_stack_limit
This commit is contained in:
parent
c16bfbe0c3
commit
b5c7997ef5
2 changed files with 24 additions and 5 deletions
|
@ -687,6 +687,23 @@ sp_in_stk_seg(uintptr_t sp, stk_seg *stk) {
|
||||||
return (uintptr_t)stk->data <= sp && sp <= stk->end;
|
return (uintptr_t)stk->data <= sp && sp <= stk->end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct reset_args {
|
||||||
|
rust_task *task;
|
||||||
|
uintptr_t sp;
|
||||||
|
};
|
||||||
|
|
||||||
|
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->del_stack();
|
||||||
|
A(task->thread, task->stk != NULL,
|
||||||
|
"Failed to find the current stack");
|
||||||
|
}
|
||||||
|
task->record_stack_limit();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Called by landing pads during unwinding to figure out which
|
Called by landing pads during unwinding to figure out which
|
||||||
stack segment we are currently running on, delete the others,
|
stack segment we are currently running on, delete the others,
|
||||||
|
@ -695,12 +712,12 @@ through __morestack).
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
rust_task::reset_stack_limit() {
|
rust_task::reset_stack_limit() {
|
||||||
|
I(thread, on_rust_stack());
|
||||||
uintptr_t sp = get_sp();
|
uintptr_t sp = get_sp();
|
||||||
while (!sp_in_stk_seg(sp, stk)) {
|
// Have to do the rest on the C stack because it involves
|
||||||
del_stack();
|
// freeing stack segments, logging, etc.
|
||||||
A(thread, stk != NULL, "Failed to find the current stack");
|
reset_args ra = {this, sp};
|
||||||
}
|
call_on_c_stack(&ra, (void*)reset_stack_limit_on_c_stack);
|
||||||
record_stack_limit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -39,6 +39,7 @@ typedef unsigned long task_result;
|
||||||
|
|
||||||
struct spawn_args;
|
struct spawn_args;
|
||||||
struct cleanup_args;
|
struct cleanup_args;
|
||||||
|
struct reset_args;
|
||||||
|
|
||||||
// std::lib::task::task_notification
|
// std::lib::task::task_notification
|
||||||
//
|
//
|
||||||
|
@ -131,6 +132,7 @@ private:
|
||||||
|
|
||||||
friend void task_start_wrapper(spawn_args *a);
|
friend void task_start_wrapper(spawn_args *a);
|
||||||
friend void cleanup_task(cleanup_args *a);
|
friend void cleanup_task(cleanup_args *a);
|
||||||
|
friend void reset_stack_limit_on_c_stack(reset_args *a);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue