Skip to content

Commit 678b46a

Browse files
Liedtkenodejs-github-bot
authored andcommitted
deps: V8: cherry-pick 435a2cdf664c
Original commit message: [wasm] Update WebAssembly.Exception JS API WebIDL specifies the existence of a `WebAssembly.Exception.prototype.stack` getter. WebIDL also expects the constructor to have 2 parameters (plus an optional one). https://webassembly.github.io/spec/js-api/#exceptions Bug: 336347912, 42204334 Change-Id: I128e976a84f942dcf9b93a157534b15fad0f9215 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/7697976 Commit-Queue: Matthias Liedtke <mliedtke@chromium.org> Auto-Submit: Matthias Liedtke <mliedtke@chromium.org> Commit-Queue: Clemens Backes <clemensb@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/main@{#106215} Refs: v8/v8@435a2cd PR-URL: #63136 Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Mattias Buelens <mattias@buelens.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 6009d93 commit 678b46a

6 files changed

Lines changed: 30 additions & 1 deletion

File tree

common.gypi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
# Reset this number to 0 on major V8 upgrades.
4242
# Increment by one for each non-official patch applied to deps/v8.
43-
'v8_embedder_string': '-node.19',
43+
'v8_embedder_string': '-node.20',
4444

4545
##### V8 defaults for Node.js #####
4646

deps/v8/src/codegen/external-reference.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,8 @@ enum class IsolateFieldId : uint8_t;
375375
IF_WASM(V, wasm_WebAssemblyExceptionGetArg, \
376376
"wasm::WebAssemblyExceptionGetArg") \
377377
IF_WASM(V, wasm_WebAssemblyExceptionIs, "wasm::WebAssemblyExceptionIs") \
378+
IF_WASM(V, wasm_WebAssemblyExceptionGetStack, \
379+
"wasm::WebAssemblyExceptionGetStack") \
378380
IF_WASM(V, wasm_WebAssemblyGlobal, "wasm::WebAssemblyGlobal") \
379381
IF_WASM(V, wasm_WebAssemblyGlobalGetValue, \
380382
"wasm::WebAssemblyGlobalGetValue") \

deps/v8/src/wasm/wasm-js.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3119,6 +3119,15 @@ void WebAssemblyExceptionIsImpl(
31193119
info.GetReturnValue().Set(tag_object->tag() == *tag);
31203120
}
31213121

3122+
void WebAssemblyExceptionGetStackImpl(
3123+
const v8::FunctionCallbackInfo<v8::Value>& info) {
3124+
WasmJSApiScope js_api_scope{info, "WebAssembly.Exception.stack()"};
3125+
auto [isolate, i_isolate, thrower] = js_api_scope.isolates_and_thrower();
3126+
EXTRACT_THIS(exception, WasmExceptionPackage);
3127+
3128+
info.GetReturnValue().Set(v8::Undefined(isolate));
3129+
}
3130+
31223131
void WebAssemblyGlobalGetValueCommon(WasmJSApiScope& js_api_scope) {
31233132
auto [isolate, i_isolate, thrower] = js_api_scope.isolates_and_thrower();
31243133
auto& info = js_api_scope.callback_info(); // Needed by EXTRACT_THIS.
@@ -3562,6 +3571,7 @@ void WasmJs::PrepareForSnapshot(Isolate* isolate) {
35623571
{
35633572
DirectHandle<JSFunction> exception_constructor = InstallConstructorFunc(
35643573
isolate, webassembly, "Exception", wasm::WebAssemblyException);
3574+
exception_constructor->shared()->set_length(2);
35653575
SetDummyInstanceTemplate(isolate, exception_constructor);
35663576
DirectHandle<JSObject> exception_proto = SetupConstructor(
35673577
isolate, exception_constructor, WASM_EXCEPTION_PACKAGE_TYPE,
@@ -3571,6 +3581,8 @@ void WasmJs::PrepareForSnapshot(Isolate* isolate) {
35713581
wasm::WebAssemblyExceptionGetArg, 2);
35723582
InstallFunc(isolate, exception_proto, "is", wasm::WebAssemblyExceptionIs,
35733583
1);
3584+
InstallGetter(isolate, exception_proto, "stack",
3585+
wasm::WebAssemblyExceptionGetStack);
35743586
native_context->set_wasm_exception_constructor(*exception_constructor);
35753587

35763588
DirectHandle<Map> initial_map(exception_constructor->initial_map(),

deps/v8/src/wasm/wasm-js.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ V8_EXPORT_PRIVATE std::unique_ptr<WasmStreaming> StartStreamingForTesting(
3434
V(WebAssemblyCompile) \
3535
V(WebAssemblyException) \
3636
V(WebAssemblyExceptionGetArg) \
37+
V(WebAssemblyExceptionGetStack) \
3738
V(WebAssemblyExceptionIs) \
3839
V(WebAssemblyGlobal) \
3940
V(WebAssemblyGlobalGetValue) \

deps/v8/test/mjsunit/wasm/exceptions-api.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,19 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
106106
print(arguments.callee.name);
107107
let tag = new WebAssembly.Tag({parameters: []});
108108
let exn = new WebAssembly.Exception(tag, []);
109+
assertTrue('stack' in exn);
109110
assertEquals(undefined, exn.stack);
110111
exn = new WebAssembly.Exception(tag, [], {traceStack: false});
112+
assertTrue('stack' in exn);
111113
assertEquals(undefined, exn.stack);
112114
exn = new WebAssembly.Exception(tag, [], {traceStack: true});
113115
assertTrue(exn.stack.indexOf(arguments.callee.name) > 0);
114116
assertThrows(() => new WebAssembly.Exception(tag, [], 0), TypeError,
115117
/Argument 2 is not an object/);
118+
// The stack getter may only be used with a receiver that is a
119+
// WebAssembly.Exception.
120+
let proto = WebAssembly.Exception.prototype;
121+
assertThrows(() => proto.stack, TypeError);
116122
})();
117123

118124
(function TestCatchJSException() {
@@ -319,3 +325,7 @@ function TestGetArgHelper(types_str, types, values) {
319325
// Don't catch with implicit wrapping.
320326
assertThrowsEquals(() => instance.exports.test(obj), obj);
321327
})();
328+
329+
(function TestExceptionConstructorLength() {
330+
assertEquals(2, WebAssembly.Exception.length);
331+
})();

deps/v8/test/wasm-js/wasm-js.status

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
'wpt/table/type.tentative': [FAIL],
4343
'wpt/tag/type.tentative': [FAIL],
4444

45+
# TODO(mliedtke): This requires synchronizing the spec-tests with their newest version.
46+
'wpt/exception/constructor.tentative': [FAIL],
47+
'exception/constructor.tentative': [FAIL],
48+
4549
# Broken test (forgot to define JS function 'nulls()').
4650
'table/grow-memory64': [FAIL],
4751

0 commit comments

Comments
 (0)