diff options
author | Andreu Botella <abb@randomunok.com> | 2021-09-13 14:27:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-13 14:27:54 +0200 |
commit | 4d6f412b0b8a415a084605e5353ef46c36bcbe27 (patch) | |
tree | dc2d01af7b074cd6ea2708d18dbfcf0caf653a0e /ext/fetch/26_fetch.js | |
parent | a95ca9dc70515240b1be7a12dbf686b1ebfb3490 (diff) |
refactor(core): Turn the `wasm_streaming_feed` binding into ops (#11985)
Async WebAssembly compilation was implemented by adding two
bindings: `set_wasm_streaming_callback`, which registered a callback to
be called whenever a streaming wasm compilation was started, and
`wasm_streaming_feed`, which let the JS callback modify the state of the
v8 wasm compiler.
`set_wasm_streaming_callback` cannot currently be implemented as
anything other than a binding, but `wasm_streaming_feed` does not really
need to use anything specific to bindings, and could indeed be
implemented as one or more ops. This PR does that, resulting in a
simplification of the relevant code.
There are three operations on the state of the v8 wasm compiler that
`wasm_streaming_feed` allowed: feeding new bytes into the compiler,
letting it know that there are no more bytes coming from the network,
and aborting the compilation. This PR provides `op_wasm_streaming_feed`
to feed new bytes into the compiler, and `op_wasm_streaming_abort` to
abort the compilation. It doesn't provide an op to let v8 know that the
response is finished, but closing the resource with `Deno.core.close()`
will achieve that.
Diffstat (limited to 'ext/fetch/26_fetch.js')
-rw-r--r-- | ext/fetch/26_fetch.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ext/fetch/26_fetch.js b/ext/fetch/26_fetch.js index 663d7c61c..295ee8544 100644 --- a/ext/fetch/26_fetch.js +++ b/ext/fetch/26_fetch.js @@ -505,8 +505,8 @@ * * @param {any} source The source parameter that the WebAssembly * streaming API was called with. - * @param {number} rid An rid that can be used with - * `Deno.core.wasmStreamingFeed`. + * @param {number} rid An rid that represents the wasm streaming + * resource. */ function handleWasmStreaming(source, rid) { // This implements part of @@ -543,15 +543,15 @@ while (true) { const { value: chunk, done } = await reader.read(); if (done) break; - core.wasmStreamingFeed(rid, "bytes", chunk); + core.opSync("op_wasm_streaming_feed", rid, chunk); } } // 2.7. - core.wasmStreamingFeed(rid, "finish"); + core.close(rid); } catch (err) { // 2.8 and 3 - core.wasmStreamingFeed(rid, "abort", err); + core.opSync("op_wasm_streaming_abort", rid, err); } })(); } |