Skip to content

Commit 6e56f01

Browse files
Liedtkeaduh95
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 287e023 commit 6e56f01

5 files changed

Lines changed: 26 additions & 1 deletion

File tree

common.gypi

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

3939
# Reset this number to 0 on major V8 upgrades.
4040
# Increment by one for each non-official patch applied to deps/v8.
41-
'v8_embedder_string': '-node.49',
41+
'v8_embedder_string': '-node.50',
4242

4343
##### V8 defaults for Node.js #####
4444

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,8 @@ enum class IsolateFieldId : uint8_t;
364364
IF_WASM(V, wasm_WebAssemblyExceptionGetArg, \
365365
"wasm::WebAssemblyExceptionGetArg") \
366366
IF_WASM(V, wasm_WebAssemblyExceptionIs, "wasm::WebAssemblyExceptionIs") \
367+
IF_WASM(V, wasm_WebAssemblyExceptionGetStack, \
368+
"wasm::WebAssemblyExceptionGetStack") \
367369
IF_WASM(V, wasm_WebAssemblyGlobal, "wasm::WebAssemblyGlobal") \
368370
IF_WASM(V, wasm_WebAssemblyGlobalGetValue, \
369371
"wasm::WebAssemblyGlobalGetValue") \

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

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

3057+
void WebAssemblyExceptionGetStackImpl(
3058+
const v8::FunctionCallbackInfo<v8::Value>& info) {
3059+
WasmJSApiScope js_api_scope{info, "WebAssembly.Exception.stack()"};
3060+
auto [isolate, i_isolate, thrower] = js_api_scope.isolates_and_thrower();
3061+
EXTRACT_THIS(exception, WasmExceptionPackage);
3062+
3063+
info.GetReturnValue().Set(v8::Undefined(isolate));
3064+
}
3065+
30573066
void WebAssemblyGlobalGetValueCommon(WasmJSApiScope& js_api_scope) {
30583067
auto [isolate, i_isolate, thrower] = js_api_scope.isolates_and_thrower();
30593068
auto& info = js_api_scope.callback_info(); // Needed by EXTRACT_THIS.
@@ -3494,6 +3503,7 @@ void WasmJs::PrepareForSnapshot(Isolate* isolate) {
34943503
{
34953504
DirectHandle<JSFunction> exception_constructor = InstallConstructorFunc(
34963505
isolate, webassembly, "Exception", wasm::WebAssemblyException);
3506+
exception_constructor->shared()->set_length(2);
34973507
SetDummyInstanceTemplate(isolate, exception_constructor);
34983508
DirectHandle<JSObject> exception_proto = SetupConstructor(
34993509
isolate, exception_constructor, WASM_EXCEPTION_PACKAGE_TYPE,
@@ -3503,6 +3513,8 @@ void WasmJs::PrepareForSnapshot(Isolate* isolate) {
35033513
wasm::WebAssemblyExceptionGetArg, 2);
35043514
InstallFunc(isolate, exception_proto, "is", wasm::WebAssemblyExceptionIs,
35053515
1);
3516+
InstallGetter(isolate, exception_proto, "stack",
3517+
wasm::WebAssemblyExceptionGetStack);
35063518
native_context->set_wasm_exception_constructor(*exception_constructor);
35073519

35083520
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
@@ -33,6 +33,7 @@ V8_EXPORT_PRIVATE std::unique_ptr<WasmStreaming> StartStreamingForTesting(
3333
V(WebAssemblyCompile) \
3434
V(WebAssemblyException) \
3535
V(WebAssemblyExceptionGetArg) \
36+
V(WebAssemblyExceptionGetStack) \
3637
V(WebAssemblyExceptionIs) \
3738
V(WebAssemblyGlobal) \
3839
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+
})();

0 commit comments

Comments
 (0)