Skip to content

Commit

Permalink
small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
frank-emrich committed Sep 14, 2023
1 parent 8eac661 commit 064ac26
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion cranelift/wasm/src/code_translator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2748,7 +2748,7 @@ pub fn translate_operator<FE: FuncEnvironment + ?Sized>(
state.popn(param_count);

let tag_index_val = builder.ins().iconst(I32, *tag_index as i64);
let _vmctx = environ.translate_suspend(builder, state, tag_index_val);
environ.translate_suspend(builder, state, tag_index_val);

let contobj = environ.typed_continuations_load_continuation_object(builder);

Expand Down
4 changes: 2 additions & 2 deletions crates/cranelift/src/func_environ.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2817,13 +2817,13 @@ impl<'module_environment> cranelift_wasm::FuncEnvironment for FuncEnvironment<'m
) -> ir::Value {
let pointer_type = self.pointer_type();
let vmctx = self.vmctx(builder.cursor().func);
let base = builder.ins().global_value(pointer_type, vmctx);
let base_addr = builder.ins().global_value(pointer_type, vmctx);

let memflags = ir::MemFlags::trusted();
let offset = i32::try_from(self.offsets.vmctx_typed_continuations_store()).unwrap();
builder
.ins()
.load(self.pointer_type(), memflags, base, offset)
.load(self.pointer_type(), memflags, base_addr, offset)
}

fn typed_continuations_new_cont_ref(
Expand Down
2 changes: 1 addition & 1 deletion crates/runtime/src/continuation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type ContinuationFiber = Fiber<'static, (), u32, ()>;
type Yield = Suspend<(), u32, ()>;

#[allow(dead_code)]
const ENABLE_DEBUG_PRINTING: bool = true;
const ENABLE_DEBUG_PRINTING: bool = false;

macro_rules! debug_println {
($( $args:expr ),+ ) => {
Expand Down
33 changes: 14 additions & 19 deletions crates/runtime/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,22 +154,6 @@ pub struct Instance {
}

impl Instance {
pub(crate) fn typed_continuations_store(
&mut self,
) -> *mut crate::continuation::ContinuationObject {
unsafe { *self.vmctx_plus_offset_mut(self.offsets().vmctx_typed_continuations_store()) }
}

pub(crate) fn set_typed_continuations_store(
&mut self,
contobj: *mut crate::continuation::ContinuationObject,
) {
unsafe {
let ptr = self.vmctx_plus_offset_mut(self.offsets().vmctx_typed_continuations_store());
*ptr = contobj;
}
}

/// Create an instance at the given memory address.
///
/// It is assumed the memory was properly aligned and the
Expand Down Expand Up @@ -1233,9 +1217,20 @@ impl Instance {
fault
}

/// TODO
pub unsafe fn get_typed_continuations_store_mut(&mut self) -> *mut u32 {
self.vmctx_plus_offset_mut(self.offsets().vmctx_typed_continuations_store())
pub(crate) fn typed_continuations_store(
&mut self,
) -> *mut crate::continuation::ContinuationObject {
unsafe { *self.vmctx_plus_offset_mut(self.offsets().vmctx_typed_continuations_store()) }
}

pub(crate) fn set_typed_continuations_store(
&mut self,
contobj: *mut crate::continuation::ContinuationObject,
) {
unsafe {
let ptr = self.vmctx_plus_offset_mut(self.offsets().vmctx_typed_continuations_store());
*ptr = contobj;
}
}

/// TODO
Expand Down

0 comments on commit 064ac26

Please sign in to comment.