/********************************************************************** * Switches to the C-stack and invokes |fn_ptr|, passing |args| as argument. * This is used by the C compiler to call native functions and by other * upcalls to switch to the C stack. The return value is passed through a * field in the args parameter. This upcall is specifically for switching * to the shim functions generated by rustc. */ extern "C" CDECL void upcall_call_shim_on_c_stack(void *args, void *fn_ptr) { rust_task *task = rust_task_thread::get_task(); // FIXME (1226) - The shim functions generated by rustc contain the // morestack prologue, so we need to let them know they have enough // stack. record_sp_limit(0); try { task->call_on_c_stack(args, fn_ptr); } catch (...) { LOG_ERR(task, task, "Native code threw an exception"); abort(); } task->record_stack_limit(); }
/* * The opposite of above. Starts on a C stack and switches to the Rust * stack. This is the only upcall that runs from the C stack. */ extern "C" CDECL void upcall_call_shim_on_rust_stack(void *args, void *fn_ptr) { rust_task *task = rust_task_thread::get_task(); // FIXME: Because of the hack in the other function that disables the // stack limit when entering the C stack, here we restore the stack limit // again. task->record_stack_limit(); try { task->call_on_rust_stack(args, fn_ptr); } catch (...) { // We can't count on being able to unwind through arbitrary // code. Our best option is to just fail hard. LOG_ERR(task, task, "Rust task failed after reentering the Rust stack"); abort(); } // FIXME: As above record_sp_limit(0); }
virtual void run() { record_sp_limit(0); fn->f(NULL, fn->env, NULL); }
virtual void run() { record_sp_limit(0); fn.f(fn.env, NULL); }