diff options
author | Aaron O'Mullan <aaron.omullan@gmail.com> | 2021-04-25 22:00:05 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-25 22:00:05 +0200 |
commit | 83bece56b01f6997cb71e9289a4d83a398cde0c8 (patch) | |
tree | 6f688f86bffd3ada71f7afa67d27a812d0bae386 /core/core.js | |
parent | 1c7164257d146c279b61708ddf8514d85b5fc11c (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/core.js')
-rw-r--r-- | core/core.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/core/core.js b/core/core.js index a11f281f1..fd9b2c3ea 100644 --- a/core/core.js +++ b/core/core.js @@ -60,12 +60,14 @@ } function ops() { - // op id 0 is a special value to retrieve the map of registered ops. - const newOpsCache = Object.fromEntries(opcall(0)); - opsCache = Object.freeze(newOpsCache); return opsCache; } + function syncOpsCache() { + // op id 0 is a special value to retrieve the map of registered ops. + opsCache = Object.freeze(Object.fromEntries(opcall(0))); + } + function handleAsyncMsgFromRust() { for (let i = 0; i < arguments.length; i += 2) { const promiseId = arguments[i]; @@ -130,5 +132,6 @@ resources, registerErrorClass, handleAsyncMsgFromRust, + syncOpsCache, }); })(this); |