summaryrefslogtreecommitdiff
path: root/runtime/js/99_main.js
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-03-08 00:20:54 -0400
committerGitHub <noreply@github.com>2023-03-08 09:50:54 +0530
commit9eb987e46c4d51badc9a566c880798d925d35d54 (patch)
treeabd82245b2b5b01c4ddca4d84cf39665b9578fc3 /runtime/js/99_main.js
parentb32a6f8ad20e6e4b0cc24b8256c08192b4899844 (diff)
perf: move setting up Deno namespace to snapshot time (#18067)
No need to do it on startup every time.
Diffstat (limited to 'runtime/js/99_main.js')
-rw-r--r--runtime/js/99_main.js32
1 files changed, 14 insertions, 18 deletions
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js
index af24051be..d90e186d9 100644
--- a/runtime/js/99_main.js
+++ b/runtime/js/99_main.js
@@ -385,6 +385,20 @@ function promiseRejectMacrotaskCallback() {
let hasBootstrapped = false;
// Set up global properties shared by main and worker runtime.
ObjectDefineProperties(globalThis, windowOrWorkerGlobalScope);
+// FIXME(bartlomieju): temporarily add whole `Deno.core` to
+// `Deno[Deno.internal]` namespace. It should be removed and only necessary
+// methods should be left there.
+ObjectAssign(internals, {
+ core,
+});
+const internalSymbol = Symbol("Deno.internal");
+const finalDenoNs = {
+ internal: internalSymbol,
+ [internalSymbol]: internals,
+ resources: core.resources,
+ close: core.close,
+ ...denoNs,
+};
function bootstrapMainRuntime(runtimeOptions) {
if (hasBootstrapped) {
@@ -452,8 +466,6 @@ function bootstrapMainRuntime(runtimeOptions) {
setUserAgent(runtimeOptions.userAgent);
setLanguage(runtimeOptions.locale);
- const internalSymbol = Symbol("Deno.internal");
-
// These have to initialized here and not in `90_deno_ns.js` because
// the op function that needs to be passed will be invalidated by creating
// a snapshot
@@ -475,13 +487,6 @@ function bootstrapMainRuntime(runtimeOptions) {
core,
});
- const finalDenoNs = {
- internal: internalSymbol,
- [internalSymbol]: internals,
- resources: core.resources,
- close: core.close,
- ...denoNs,
- };
ObjectDefineProperties(finalDenoNs, {
pid: util.readOnly(runtimeOptions.pid),
ppid: util.readOnly(runtimeOptions.ppid),
@@ -579,8 +584,6 @@ function bootstrapWorkerRuntime(
globalThis.pollForMessages = pollForMessages;
- const internalSymbol = Symbol("Deno.internal");
-
// These have to initialized here and not in `90_deno_ns.js` because
// the op function that needs to be passed will be invalidated by creating
// a snapshot
@@ -602,13 +605,6 @@ function bootstrapWorkerRuntime(
core,
});
- const finalDenoNs = {
- internal: internalSymbol,
- [internalSymbol]: internals,
- resources: core.resources,
- close: core.close,
- ...denoNs,
- };
if (runtimeOptions.unstableFlag) {
ObjectAssign(finalDenoNs, denoNsUnstable);
// These have to initialized here and not in `90_deno_ns.js` because