diff options
author | Andreu Botella <abb@randomunok.com> | 2021-10-10 07:03:23 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-10 16:03:23 +0200 |
commit | 5edd2771619ddc3cd2f6c76cc93ee64277aa17c2 (patch) | |
tree | 88307d65fc81388579328dfb7d3da782ffa3f5a9 /core | |
parent | 6ac0337165d5e341eee9bff9ff0065894289df69 (diff) |
feat: Show the URL of streaming WASM modules in stack traces (#12268)
WebAssembly modules compiled through `WebAssembly.compile()` and similar
non-streaming APIs don't have a URL associated to them, because they
have been compiled from a buffer source. In stack traces, V8 will use
a URL such as `wasm://wasm/d1c677ea`, with a hash of the module.
However, wasm modules compiled through streaming APIs, like
`WebAssembly.compileStreaming()`, do have a known URL, which can be
obtained from the `Response` object passed into the streaming APIs. And
as per the developer-facing display conventions in the WebAssembly
Web API spec, this URL should be used in stack traces. This change
implements that.
Diffstat (limited to 'core')
-rw-r--r-- | core/lib.deno_core.d.ts | 2 | ||||
-rw-r--r-- | core/ops_builtin.rs | 17 |
2 files changed, 19 insertions, 0 deletions
diff --git a/core/lib.deno_core.d.ts b/core/lib.deno_core.d.ts index efa138d77..6db01df61 100644 --- a/core/lib.deno_core.d.ts +++ b/core/lib.deno_core.d.ts @@ -63,6 +63,8 @@ declare namespace Deno { * compiler. Takes the rid and a `Uint8Array`. * - `op_wasm_streaming_abort`. Aborts the wasm compilation. Takes the rid * and an exception. Invalidates the resource. + * - `op_wasm_streaming_set_url`. Sets a source URL for the wasm module. + * Takes the rid and a string. * - To indicate the end of the resource, use `Deno.core.close()` with the * rid. */ diff --git a/core/ops_builtin.rs b/core/ops_builtin.rs index 392062960..bb04cddf4 100644 --- a/core/ops_builtin.rs +++ b/core/ops_builtin.rs @@ -26,6 +26,10 @@ pub(crate) fn init_builtins() -> Extension { ("op_resources", op_sync(op_resources)), ("op_wasm_streaming_feed", op_sync(op_wasm_streaming_feed)), ("op_wasm_streaming_abort", op_sync(op_wasm_streaming_abort)), + ( + "op_wasm_streaming_set_url", + op_sync(op_wasm_streaming_set_url), + ), ]) .build() } @@ -137,3 +141,16 @@ pub fn op_wasm_streaming_abort( Ok(()) } + +pub fn op_wasm_streaming_set_url( + state: &mut OpState, + rid: ResourceId, + url: String, +) -> Result<(), AnyError> { + let wasm_streaming = + state.resource_table.get::<WasmStreamingResource>(rid)?; + + wasm_streaming.0.borrow_mut().set_url(&url); + + Ok(()) +} |