Skip to content

Commit dc75c3c

Browse files
committed
---
yaml --- r: 14432 b: refs/heads/try c: b5c7997 h: refs/heads/master v: v3
1 parent de65559 commit dc75c3c

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
refs/heads/master: 61b1875c16de39c166b0f4d54bba19f9c6777d1a
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 4a81779abd786ff22d71434c6d9a5917ea4cdfff
5-
refs/heads/try: c16bfbe0c365b6d3f0c274a53bc1374822766e6b
5+
refs/heads/try: b5c7997ef588916e566c18ba91608454bc4ffaaf
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

branches/try/src/rt/rust_task.cpp

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,23 @@ sp_in_stk_seg(uintptr_t sp, stk_seg *stk) {
687687
return (uintptr_t)stk->data <= sp && sp <= stk->end;
688688
}
689689

690+
struct reset_args {
691+
rust_task *task;
692+
uintptr_t sp;
693+
};
694+
695+
void
696+
reset_stack_limit_on_c_stack(reset_args *args) {
697+
rust_task *task = args->task;
698+
uintptr_t sp = args->sp;
699+
while (!sp_in_stk_seg(sp, task->stk)) {
700+
task->del_stack();
701+
A(task->thread, task->stk != NULL,
702+
"Failed to find the current stack");
703+
}
704+
task->record_stack_limit();
705+
}
706+
690707
/*
691708
Called by landing pads during unwinding to figure out which
692709
stack segment we are currently running on, delete the others,
@@ -695,12 +712,12 @@ through __morestack).
695712
*/
696713
void
697714
rust_task::reset_stack_limit() {
715+
I(thread, on_rust_stack());
698716
uintptr_t sp = get_sp();
699-
while (!sp_in_stk_seg(sp, stk)) {
700-
del_stack();
701-
A(thread, stk != NULL, "Failed to find the current stack");
702-
}
703-
record_stack_limit();
717+
// Have to do the rest on the C stack because it involves
718+
// freeing stack segments, logging, etc.
719+
reset_args ra = {this, sp};
720+
call_on_c_stack(&ra, (void*)reset_stack_limit_on_c_stack);
704721
}
705722

706723
void

branches/try/src/rt/rust_task.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ typedef unsigned long task_result;
3939

4040
struct spawn_args;
4141
struct cleanup_args;
42+
struct reset_args;
4243

4344
// std::lib::task::task_notification
4445
//
@@ -131,6 +132,7 @@ rust_task : public kernel_owned<rust_task>, rust_cond
131132

132133
friend void task_start_wrapper(spawn_args *a);
133134
friend void cleanup_task(cleanup_args *a);
135+
friend void reset_stack_limit_on_c_stack(reset_args *a);
134136

135137
public:
136138

0 commit comments

Comments
 (0)