diff options
author | Matt Mastracci <matthew@mastracci.com> | 2023-11-09 13:57:26 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-09 13:57:26 -0700 |
commit | 9010b8df53cd37f0410e08c43a194667974686a2 (patch) | |
tree | 97c13d696ba1216e74b745f5ce1b25ed34afa2cd /runtime | |
parent | c4029f6af22b373bf22383453cb4e2159f3b5b72 (diff) |
perf: remove knowledge of promise IDs from deno (#21132)
We can move all promise ID knowledge to deno_core, allowing us to better
experiment with promise implementation in deno_core.
`{un,}refOpPromise(promise)` is equivalent to
`{un,}refOp(promise[promiseIdSymbol])`
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/js/40_process.js | 10 | ||||
-rw-r--r-- | runtime/js/40_signals.js | 3 |
2 files changed, 5 insertions, 8 deletions
diff --git a/runtime/js/40_process.js b/runtime/js/40_process.js index 4ddc4a02a..67093398a 100644 --- a/runtime/js/40_process.js +++ b/runtime/js/40_process.js @@ -13,7 +13,6 @@ const { ObjectPrototypeIsPrototypeOf, PromisePrototypeThen, SafePromiseAll, - SymbolFor, Symbol, } = primordials; import { FsFile } from "ext:deno_fs/30_fs.js"; @@ -148,7 +147,6 @@ function run({ } const illegalConstructorKey = Symbol("illegalConstructorKey"); -const promiseIdSymbol = SymbolFor("Deno.core.internalPromiseId"); function spawnChildInner(opFn, command, apiName, { args = [], @@ -203,7 +201,7 @@ function collectOutput(readableStream) { class ChildProcess { #rid; - #waitPromiseId; + #waitPromise; #waitComplete = false; #pid; @@ -266,7 +264,7 @@ class ChildProcess { signal?.[abortSignal.add](onAbort); const waitPromise = core.opAsync("op_spawn_wait", this.#rid); - this.#waitPromiseId = waitPromise[promiseIdSymbol]; + this.#waitPromise = waitPromise; this.#status = PromisePrototypeThen(waitPromise, (res) => { signal?.[abortSignal.remove](onAbort); this.#waitComplete = true; @@ -333,13 +331,13 @@ class ChildProcess { } ref() { - core.refOp(this.#waitPromiseId); + core.refOpPromise(this.#waitPromise); if (this.#stdout) readableStreamForRidUnrefableRef(this.#stdout); if (this.#stderr) readableStreamForRidUnrefableRef(this.#stderr); } unref() { - core.unrefOp(this.#waitPromiseId); + core.unrefOpPromise(this.#waitPromise); if (this.#stdout) readableStreamForRidUnrefableUnref(this.#stdout); if (this.#stderr) readableStreamForRidUnrefableUnref(this.#stderr); } diff --git a/runtime/js/40_signals.js b/runtime/js/40_signals.js index 51d6bb349..3c5b83789 100644 --- a/runtime/js/40_signals.js +++ b/runtime/js/40_signals.js @@ -8,7 +8,6 @@ const { SafeSetIterator, SetPrototypeAdd, SetPrototypeDelete, - SymbolFor, TypeError, } = primordials; @@ -18,7 +17,7 @@ function bindSignal(signo) { function pollSignal(rid) { const promise = core.opAsync("op_signal_poll", rid); - core.unrefOp(promise[SymbolFor("Deno.core.internalPromiseId")]); + core.unrefOpPromise(promise); return promise; } |