Skip to content

Commit c68e02c

Browse files
committed
---
yaml --- r: 6579 b: refs/heads/master c: 3b8bfaf h: refs/heads/master i: 6577: 88f76b8 6575: 6286558 v: v3
1 parent 8d8044e commit c68e02c

File tree

4 files changed

+32
-15
lines changed

4 files changed

+32
-15
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 98cd96ce96c8be7248e3d375053938354c82878a
2+
refs/heads/master: 3b8bfaf5343dd13839df465cde6a4df50136ff03

trunk/src/rt/arch/i386/morestack.S

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,12 @@ MORESTACK:
7575

7676
// The arguments to rust_new_stack2
7777
movl 40(%esp),%eax // Size of stack arguments
78-
movl %eax,16(%esp)
78+
movl %eax,20(%esp)
7979
leal 48(%esp),%eax // Address of stack arguments
80-
movl %eax,12(%esp)
80+
movl %eax,16(%esp)
8181
movl 36(%esp),%eax // The amount of stack needed
82-
movl %eax,8(%esp)
82+
movl %eax,12(%esp)
83+
movl $0, 8(%esp) // Out pointer
8384

8485
#ifdef __APPLE__
8586
call 1f
@@ -97,7 +98,7 @@ MORESTACK:
9798
movl 32(%esp),%edx // Grab the return pointer.
9899
inc %edx // Skip past the ret instruction in the parent fn
99100

100-
movl %eax,%esp // Switch stacks.
101+
movl 8(%esp),%esp // Switch stacks.
101102
call *%edx // Re-enter the function that called us.
102103

103104
// Now the function that called us has returned, so we need to delete the

trunk/src/rt/arch/x86_64/morestack.S

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,12 @@ MORESTACK:
8181
movq %rbp, %rcx
8282
addq $24, %rcx // Base pointer, return address x2
8383

84+
pushq $0 // Alignment
85+
8486
pushq %r11 // Size of stack arguments
8587
pushq %rcx // Address of stack arguments
8688
pushq %r10 // The amount of stack needed
89+
pushq $0 // Out pointer
8790

8891
movq UPCALL_NEW_STACK@GOTPCREL(%rip), %rsi
8992
movq %rsp, %rdi
@@ -95,7 +98,8 @@ MORESTACK:
9598
#endif
9699

97100
// Pop the new_stack_args struct
98-
addq $24, %rsp
101+
popq %rax
102+
addq $32, %rsp
99103

100104
// Pop the saved arguments
101105
popq %r9

trunk/src/rt/rust_upcall.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,28 +217,40 @@ extern "C" void record_sp(void *limit);
217217
*/
218218
extern "C" CDECL void
219219
upcall_call_shim_on_c_stack(void *args, void *fn_ptr) {
220+
rust_task *task = rust_scheduler::get_task();
221+
220222
// FIXME (1226) - The shim functions generated by rustc contain the
221223
// morestack prologue, so we need to let them know they have enough
222224
// stack.
223-
record_sp(0);
224-
rust_task *task = rust_scheduler::get_task();
225+
//record_sp(0);
226+
225227
rust_scheduler *sched = task->sched;
226-
sched->c_context.call_shim_on_c_stack(args, fn_ptr);
227-
task->record_stack_limit();
228+
try {
229+
sched->c_context.call_shim_on_c_stack(args, fn_ptr);
230+
} catch (...) {
231+
//task = rust_scheduler::get_task();
232+
//task->record_stack_limit();
233+
throw;
234+
}
235+
//task = rust_scheduler::get_task();
236+
//task->record_stack_limit();
228237
}
229238

230239
struct rust_new_stack2_args {
231-
size_t stk_sz;
232-
void *args_addr;
233-
size_t args_sz;
240+
void *new_stack;
241+
size_t stk_sz;
242+
void *args_addr;
243+
size_t args_sz;
234244
};
235245

236246
// A new stack function suitable for calling through
237247
// upcall_call_shim_on_c_stack
238-
extern "C" CDECL void *
248+
extern "C" CDECL void
239249
upcall_new_stack(struct rust_new_stack2_args *args) {
240250
rust_task *task = rust_scheduler::get_task();
241-
return task->new_stack(args->stk_sz, args->args_addr, args->args_sz);
251+
args->new_stack = task->new_stack(args->stk_sz,
252+
args->args_addr,
253+
args->args_sz);
242254
}
243255

244256
extern "C" CDECL void

0 commit comments

Comments
 (0)