summaryrefslogtreecommitdiff
path: root/core/runtime.rs
diff options
context:
space:
mode:
authorAaron O'Mullan <aaron.omullan@gmail.com>2021-04-25 22:00:05 +0200
committerGitHub <noreply@github.com>2021-04-25 22:00:05 +0200
commit83bece56b01f6997cb71e9289a4d83a398cde0c8 (patch)
tree6f688f86bffd3ada71f7afa67d27a812d0bae386 /core/runtime.rs
parent1c7164257d146c279b61708ddf8514d85b5fc11c (diff)
refactor(core): move op cache sync responsibility to rust space (#10340)
Even if bootstrapping the JS runtime is low level, it's an abstraction leak of core to require users to call `Deno.core.ops()` in JS space. So instead we're introducing a `JsRuntime::sync_ops_cache()` method, once we have runtime extensions a new runtime will ensure the ops cache is setup (for the provided extensions) and then loading/unloading plugins should be the only operations that require op cache syncs
Diffstat (limited to 'core/runtime.rs')
-rw-r--r--core/runtime.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/core/runtime.rs b/core/runtime.rs
index 34a83e3f3..7475c7020 100644
--- a/core/runtime.rs
+++ b/core/runtime.rs
@@ -367,6 +367,11 @@ impl JsRuntime {
state.js_recv_cb.replace(v8::Global::new(scope, cb));
}
+ /// Ensures core.js has the latest op-name to op-id mappings
+ pub fn sync_ops_cache(&mut self) {
+ self.execute("<anon>", "Deno.core.syncOpsCache()").unwrap()
+ }
+
/// Returns the runtime's op state, which can be used to maintain ops
/// and access resources between op calls.
pub fn op_state(&mut self) -> Rc<RefCell<OpState>> {
@@ -2140,6 +2145,7 @@ pub mod tests {
module_loader: Some(loader),
..Default::default()
});
+ runtime.sync_ops_cache();
runtime
.execute(
"file:///dyn_import3.js",
@@ -2149,8 +2155,6 @@ pub mod tests {
if (mod.b() !== 'b') {
throw Error("bad");
}
- // Now do any op
- Deno.core.ops();
})();
"#,
)