diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-03-07 11:11:54 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-07 16:11:54 +0100 |
commit | 76d085ff6a24a7560658f3502bd65f16fe0a5773 (patch) | |
tree | c13b5a6c5df2fb44989933af5c9f7b61c6f43d23 /runtime/js/99_main.js | |
parent | 08591d052a623fdb2d95a599e742d22cabca344e (diff) |
perf: move runtime bootstrap code to snapshot time (#18062)
This commit moves some of the code from "99_main.js" to
be executed during the snapshot time instead of on each
worker bootstrap. These should minimally help with startup
time benchmark.
Diffstat (limited to 'runtime/js/99_main.js')
-rw-r--r-- | runtime/js/99_main.js | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index 0199c5148..af24051be 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -383,6 +383,8 @@ function promiseRejectMacrotaskCallback() { } let hasBootstrapped = false; +// Set up global properties shared by main and worker runtime. +ObjectDefineProperties(globalThis, windowOrWorkerGlobalScope); function bootstrapMainRuntime(runtimeOptions) { if (hasBootstrapped) { @@ -392,12 +394,9 @@ function bootstrapMainRuntime(runtimeOptions) { performance.setTimeOrigin(DateNow()); globalThis_ = globalThis; - const consoleFromV8 = globalThis.Deno.core.console; - // Remove bootstrapping data from the global scope delete globalThis.__bootstrap; delete globalThis.bootstrap; - util.log("bootstrapMainRuntime"); hasBootstrapped = true; // If the `--location` flag isn't set, make `globalThis.location` `undefined` and @@ -411,7 +410,6 @@ function bootstrapMainRuntime(runtimeOptions) { location.setLocationHref(runtimeOptions.location); } - ObjectDefineProperties(globalThis, windowOrWorkerGlobalScope); if (runtimeOptions.unstableFlag) { ObjectDefineProperties(globalThis, unstableWindowOrWorkerGlobalScope); } @@ -423,6 +421,7 @@ function bootstrapMainRuntime(runtimeOptions) { ObjectSetPrototypeOf(globalThis, Window.prototype); if (runtimeOptions.inspectFlag) { + const consoleFromV8 = core.console; const consoleFromDeno = globalThis.console; wrapConsole(consoleFromDeno, consoleFromV8); } @@ -529,9 +528,8 @@ function bootstrapWorkerRuntime( // Remove bootstrapping data from the global scope delete globalThis.__bootstrap; delete globalThis.bootstrap; - util.log("bootstrapWorkerRuntime"); hasBootstrapped = true; - ObjectDefineProperties(globalThis, windowOrWorkerGlobalScope); + if (runtimeOptions.unstableFlag) { ObjectDefineProperties(globalThis, unstableWindowOrWorkerGlobalScope); } @@ -634,12 +632,7 @@ function bootstrapWorkerRuntime( ObjectDefineProperty(globalThis, "Deno", util.readOnly(finalDenoNs)); } -ObjectDefineProperties(globalThis, { - bootstrap: { - value: { - mainRuntime: bootstrapMainRuntime, - workerRuntime: bootstrapWorkerRuntime, - }, - configurable: true, - }, -}); +globalThis.bootstrap = { + mainRuntime: bootstrapMainRuntime, + workerRuntime: bootstrapWorkerRuntime, +}; |