summaryrefslogtreecommitdiff
path: root/core/runtime.rs
diff options
context:
space:
mode:
Diffstat (limited to 'core/runtime.rs')
-rw-r--r--core/runtime.rs25
1 files changed, 17 insertions, 8 deletions
diff --git a/core/runtime.rs b/core/runtime.rs
index cb8b242e9..50f7399d4 100644
--- a/core/runtime.rs
+++ b/core/runtime.rs
@@ -164,6 +164,9 @@ pub(crate) struct JsRuntimeState {
pub(crate) unrefed_ops: HashSet<i32>,
pub(crate) have_unpolled_ops: bool,
pub(crate) op_state: Rc<RefCell<OpState>>,
+ #[allow(dead_code)]
+ // We don't explicitly re-read this prop but need the slice to live alongside the isolate
+ pub(crate) op_ctxs: Box<[OpCtx]>,
pub(crate) shared_array_buffer_store: Option<SharedArrayBufferStore>,
pub(crate) compiled_wasm_module_store: Option<CompiledWasmModuleStore>,
waker: AtomicWaker,
@@ -298,6 +301,16 @@ impl JsRuntime {
}
let op_state = Rc::new(RefCell::new(op_state));
+ let op_ctxs = ops
+ .into_iter()
+ .enumerate()
+ .map(|(id, decl)| OpCtx {
+ id,
+ state: op_state.clone(),
+ decl,
+ })
+ .collect::<Vec<_>>()
+ .into_boxed_slice();
let global_context;
let (mut isolate, maybe_snapshot_creator) = if options.will_snapshot {
@@ -309,8 +322,7 @@ impl JsRuntime {
let mut isolate = JsRuntime::setup_isolate(isolate);
{
let scope = &mut v8::HandleScope::new(&mut isolate);
- let context =
- bindings::initialize_context(scope, &ops, false, op_state.clone());
+ let context = bindings::initialize_context(scope, &op_ctxs, false);
global_context = v8::Global::new(scope, context);
creator.set_default_context(context);
}
@@ -336,12 +348,8 @@ impl JsRuntime {
let mut isolate = JsRuntime::setup_isolate(isolate);
{
let scope = &mut v8::HandleScope::new(&mut isolate);
- let context = bindings::initialize_context(
- scope,
- &ops,
- snapshot_loaded,
- op_state.clone(),
- );
+ let context =
+ bindings::initialize_context(scope, &op_ctxs, snapshot_loaded);
global_context = v8::Global::new(scope, context);
}
@@ -374,6 +382,7 @@ impl JsRuntime {
shared_array_buffer_store: options.shared_array_buffer_store,
compiled_wasm_module_store: options.compiled_wasm_module_store,
op_state: op_state.clone(),
+ op_ctxs,
have_unpolled_ops: false,
waker: AtomicWaker::new(),
})));