summaryrefslogtreecommitdiff
path: root/core/core.js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2021-01-05 22:10:50 +0100
committerGitHub <noreply@github.com>2021-01-05 22:10:50 +0100
commit46c0cab763380a1ecbdf93e309257de4e37a7341 (patch)
tree232992fc9a79bb312144e2426759c41b0afd15c6 /core/core.js
parent0d41e21b0e9b46cc179eff42c215439fb672964b (diff)
refactor(core): simplify Deno.core initialisation, remove stale TODO (#8847)
This commit rewrites initialisation of the "shared queue" and in effect prevents from double execution of "core/core.js" and "core/error.js". Previously both of these files were executed every time a "JsRuntime" was created. That lead to a situation where one copy of each script was included in the snapshot and then another copy would be executed after loading the snapshot. Effectively "JsRuntime::shared_init" was removed; instead execution of those scripts and actual initialisation of shared queue was split into two helper functions: "JsRuntime::js_init" and "JsRuntime::share_queue_init". Additionally stale TODO comments were removed.
Diffstat (limited to 'core/core.js')
-rw-r--r--core/core.js12
1 files changed, 1 insertions, 11 deletions
diff --git a/core/core.js b/core/core.js
index 8be7dc4ff..ac2980fad 100644
--- a/core/core.js
+++ b/core/core.js
@@ -34,17 +34,9 @@ SharedQueue Binary Layout
let asyncHandlers;
- let initialized = false;
let opsCache = {};
const errorMap = {};
- function maybeInit() {
- if (!initialized) {
- init();
- initialized = true;
- }
- }
-
function init() {
const shared = core.shared;
assert(shared.byteLength > 0);
@@ -72,14 +64,12 @@ SharedQueue Binary Layout
}
function reset() {
- maybeInit();
shared32[INDEX_NUM_RECORDS] = 0;
shared32[INDEX_NUM_SHIFTED_OFF] = 0;
shared32[INDEX_HEAD] = HEAD_INIT;
}
function head() {
- maybeInit();
return shared32[INDEX_HEAD];
}
@@ -160,7 +150,6 @@ SharedQueue Binary Layout
}
function setAsyncHandler(opId, cb) {
- maybeInit();
assert(opId != null);
asyncHandlers[opId] = cb;
}
@@ -273,6 +262,7 @@ SharedQueue Binary Layout
resources,
registerErrorClass,
getErrorClass,
+ sharedQueueInit: init,
// sharedQueue is private but exposed for testing.
sharedQueue: {
MAX_RECORDS,