mirror of
https://github.com/denoland/deno.git
synced 2025-01-18 03:44:05 -05:00
perf: move setting up Deno namespace to snapshot time (#18067)
No need to do it on startup every time.
This commit is contained in:
parent
b32a6f8ad2
commit
9eb987e46c
1 changed files with 14 additions and 18 deletions
|
@ -385,6 +385,20 @@ function promiseRejectMacrotaskCallback() {
|
||||||
let hasBootstrapped = false;
|
let hasBootstrapped = false;
|
||||||
// Set up global properties shared by main and worker runtime.
|
// Set up global properties shared by main and worker runtime.
|
||||||
ObjectDefineProperties(globalThis, windowOrWorkerGlobalScope);
|
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) {
|
function bootstrapMainRuntime(runtimeOptions) {
|
||||||
if (hasBootstrapped) {
|
if (hasBootstrapped) {
|
||||||
|
@ -452,8 +466,6 @@ function bootstrapMainRuntime(runtimeOptions) {
|
||||||
setUserAgent(runtimeOptions.userAgent);
|
setUserAgent(runtimeOptions.userAgent);
|
||||||
setLanguage(runtimeOptions.locale);
|
setLanguage(runtimeOptions.locale);
|
||||||
|
|
||||||
const internalSymbol = Symbol("Deno.internal");
|
|
||||||
|
|
||||||
// These have to initialized here and not in `90_deno_ns.js` because
|
// 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
|
// the op function that needs to be passed will be invalidated by creating
|
||||||
// a snapshot
|
// a snapshot
|
||||||
|
@ -475,13 +487,6 @@ function bootstrapMainRuntime(runtimeOptions) {
|
||||||
core,
|
core,
|
||||||
});
|
});
|
||||||
|
|
||||||
const finalDenoNs = {
|
|
||||||
internal: internalSymbol,
|
|
||||||
[internalSymbol]: internals,
|
|
||||||
resources: core.resources,
|
|
||||||
close: core.close,
|
|
||||||
...denoNs,
|
|
||||||
};
|
|
||||||
ObjectDefineProperties(finalDenoNs, {
|
ObjectDefineProperties(finalDenoNs, {
|
||||||
pid: util.readOnly(runtimeOptions.pid),
|
pid: util.readOnly(runtimeOptions.pid),
|
||||||
ppid: util.readOnly(runtimeOptions.ppid),
|
ppid: util.readOnly(runtimeOptions.ppid),
|
||||||
|
@ -579,8 +584,6 @@ function bootstrapWorkerRuntime(
|
||||||
|
|
||||||
globalThis.pollForMessages = pollForMessages;
|
globalThis.pollForMessages = pollForMessages;
|
||||||
|
|
||||||
const internalSymbol = Symbol("Deno.internal");
|
|
||||||
|
|
||||||
// These have to initialized here and not in `90_deno_ns.js` because
|
// 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
|
// the op function that needs to be passed will be invalidated by creating
|
||||||
// a snapshot
|
// a snapshot
|
||||||
|
@ -602,13 +605,6 @@ function bootstrapWorkerRuntime(
|
||||||
core,
|
core,
|
||||||
});
|
});
|
||||||
|
|
||||||
const finalDenoNs = {
|
|
||||||
internal: internalSymbol,
|
|
||||||
[internalSymbol]: internals,
|
|
||||||
resources: core.resources,
|
|
||||||
close: core.close,
|
|
||||||
...denoNs,
|
|
||||||
};
|
|
||||||
if (runtimeOptions.unstableFlag) {
|
if (runtimeOptions.unstableFlag) {
|
||||||
ObjectAssign(finalDenoNs, denoNsUnstable);
|
ObjectAssign(finalDenoNs, denoNsUnstable);
|
||||||
// These have to initialized here and not in `90_deno_ns.js` because
|
// These have to initialized here and not in `90_deno_ns.js` because
|
||||||
|
|
Loading…
Add table
Reference in a new issue