diff --git a/src/tracing/js/bindings.rs b/src/tracing/js/bindings.rs index f1d155c1..364e3bc1 100644 --- a/src/tracing/js/bindings.rs +++ b/src/tracing/js/bindings.rs @@ -237,12 +237,18 @@ impl StepLog { pub(crate) struct MemoryRef(GuardedNullableGc); impl MemoryRef { - /// Creates a new stack reference + /// Creates a new memory reference pub(crate) fn new(mem: &SharedMemory) -> (Self, GcGuard<'_, SharedMemory>) { let (inner, guard) = GuardedNullableGc::new_ref(mem); (Self(inner), guard) } + /// Creates a new owned memory + pub(crate) fn new_owned(mem: SharedMemory) -> (Self, GcGuard<'static, SharedMemory>) { + let (inner, guard) = GuardedNullableGc::new_owned(mem); + (Self(inner), guard) + } + fn len(&self) -> usize { self.0.with_inner(|mem| mem.len()).unwrap_or_default() } @@ -428,6 +434,12 @@ impl StackRef { (Self(inner), guard) } + /// Creates a new owned stack + pub(crate) fn new_owned(stack: Stack) -> (Self, GcGuard<'static, Stack>) { + let (inner, guard) = GuardedNullableGc::new_owned(stack); + (Self(inner), guard) + } + fn peek(&self, idx: usize, ctx: &mut Context) -> JsResult { self.0 .with_inner(|stack| {