Skip to content

Commit

Permalink
Tweak some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Apr 14, 2020
1 parent fc1029f commit 8147d95
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions crates/runtime/src/traphandlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,10 +486,13 @@ impl CallThreadState {
///
/// For more information about interrupts and stack limits see
/// `crates/environ/src/cranelift.rs`.
///
/// Note that this function must be called with `self` on the stack, not the
/// heap/etc.
fn update_stack_limit(&self, max_wasm_stack: usize) -> Result<impl Drop + '_, Trap> {
// Make an "educated guess" to figure out where the wasm sp value should
// start trapping if it drops below.
let wasm_stack_limit = &self as *const _ as usize - max_wasm_stack;
let wasm_stack_limit = self as *const _ as usize - max_wasm_stack;

let interrupts = unsafe { &**(&*self.vmctx).instance().interrupts() };
let reset_stack_limit = match interrupts.stack_limit.compare_exchange(
Expand All @@ -499,8 +502,8 @@ impl CallThreadState {
SeqCst,
) {
Ok(_) => {
// We're the first wasm on the stack so we've now reserved
// the `WASM_STACK` bytes of native stack space for wasm.
// We're the first wasm on the stack so we've now reserved the
// `max_wasm_stack` bytes of native stack space for wasm.
// Nothing left to do here now except reset back when we're
// done.
true
Expand Down

0 comments on commit 8147d95

Please sign in to comment.