Diff
Modified: trunk/JSTests/ChangeLog (288064 => 288065)
--- trunk/JSTests/ChangeLog 2022-01-15 21:17:40 UTC (rev 288064)
+++ trunk/JSTests/ChangeLog 2022-01-15 21:32:37 UTC (rev 288065)
@@ -1,5 +1,16 @@
2022-01-15 Yusuke Suzuki <[email protected]>
+ [JSC] Fix misc issues in WebAssembly.Exception
+ https://bugs.webkit.org/show_bug.cgi?id=235261
+
+ Reviewed by Alexey Shvayka.
+
+ * wasm/stress/create-tag-from.js:
+ * wasm/v8/exceptions-api.js:
+ (TestGetArg):
+
+2022-01-15 Yusuke Suzuki <[email protected]>
+
[JSC] Upgrade test262
https://bugs.webkit.org/show_bug.cgi?id=235263
Modified: trunk/JSTests/wasm/stress/create-tag-from.js (288064 => 288065)
--- trunk/JSTests/wasm/stress/create-tag-from.js 2022-01-15 21:17:40 UTC (rev 288064)
+++ trunk/JSTests/wasm/stress/create-tag-from.js 2022-01-15 21:32:37 UTC (rev 288065)
@@ -17,6 +17,6 @@
assert.eq(exception.getArg(tag, 1), 2.5);
assert.eq(exception.getArg(tag, 2), parameters);
-assert.throws(() => exception.getArg(tag, 3), RangeError, "WebAssembly.Exception.getArg(): Index out of range");
+assert.throws(() => exception.getArg(tag, 3), TypeError, "WebAssembly.Exception.getArg(): Index out of range");
assert.eq(WebAssembly.Exception.prototype.__proto__, Object.prototype)
Modified: trunk/JSTests/wasm/v8/exceptions-api.js (288064 => 288065)
--- trunk/JSTests/wasm/v8/exceptions-api.js 2022-01-15 21:17:40 UTC (rev 288064)
+++ trunk/JSTests/wasm/v8/exceptions-api.js 2022-01-15 21:32:37 UTC (rev 288065)
@@ -202,7 +202,7 @@
/First argument must be a WebAssembly.Tag/);
//assertThrows(() => exception.getArg(tag, undefined), TypeError,
///Index must be convertible to a valid number/);
- assertThrows(() => exception.getArg(tag, 0xFFFFFFFF), RangeError,
+ assertThrows(() => exception.getArg(tag, 0xFFFFFFFF), TypeError,
/Index out of range/);
let wrong_tag = new WebAssembly.Tag({parameters: ['i32']});
assertThrows(() => exception.getArg(wrong_tag, 0), TypeError,
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (288064 => 288065)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2022-01-15 21:17:40 UTC (rev 288064)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2022-01-15 21:32:37 UTC (rev 288065)
@@ -1,5 +1,32 @@
2022-01-15 Yusuke Suzuki <[email protected]>
+ [JSC] Fix misc issues in WebAssembly.Exception
+ https://bugs.webkit.org/show_bug.cgi?id=235261
+
+ Reviewed by Alexey Shvayka.
+
+ Remove web-platform-tests/wasm/jsapi/exception/type.tentative.any.js test since
+ this behavior is not defined in wasm exception-handling and/or wasm js-types spec.
+ Probably this test was confused with WebAssembly.Tag (and that test is in wasm/jsapi/tag/).
+
+ Also change RangeError to TypeError according to the spec[1].
+
+ [1]: https://webassembly.github.io/exception-handling/js-api/index.html#dom-exception-getarg
+
+ * web-platform-tests/wasm/jsapi/exception/getArg.tentative.any-expected.txt:
+ * web-platform-tests/wasm/jsapi/exception/getArg.tentative.any.js:
+ (test):
+ * web-platform-tests/wasm/jsapi/exception/getArg.tentative.any.worker-expected.txt:
+ * web-platform-tests/wasm/jsapi/exception/toString.tentative.any-expected.txt:
+ * web-platform-tests/wasm/jsapi/exception/toString.tentative.any.worker-expected.txt:
+ * web-platform-tests/wasm/jsapi/exception/type.tentative.any-expected.txt: Removed.
+ * web-platform-tests/wasm/jsapi/exception/type.tentative.any.html: Removed.
+ * web-platform-tests/wasm/jsapi/exception/type.tentative.any.js: Removed.
+ * web-platform-tests/wasm/jsapi/exception/type.tentative.any.worker-expected.txt: Removed.
+ * web-platform-tests/wasm/jsapi/exception/type.tentative.any.worker.html: Removed.
+
+2022-01-15 Yusuke Suzuki <[email protected]>
+
[JSC] Fix misc WebAssembly.Table issues
https://bugs.webkit.org/show_bug.cgi?id=235262
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/getArg.tentative.any-expected.txt (288064 => 288065)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/getArg.tentative.any-expected.txt 2022-01-15 21:17:40 UTC (rev 288064)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/getArg.tentative.any-expected.txt 2022-01-15 21:32:37 UTC (rev 288065)
@@ -1,11 +1,7 @@
-FAIL Missing arguments assert_throws_js: function "() => exn.getArg(tag)" threw object "RangeError: WebAssembly.Exception.getArg(): Index out of range" ("RangeError") expected instance of function "function TypeError() {
- [native code]
-}" ("TypeError")
+PASS Missing arguments
PASS Invalid exception argument
PASS Index out of bounds
-FAIL Getting out-of-range argument assert_throws_js: function "() => exn.getArg(tag, value)" threw object "RangeError: WebAssembly.Exception.getArg(): Index out of range" ("RangeError") expected instance of function "function TypeError() {
- [native code]
-}" ("TypeError")
+PASS Getting out-of-range argument
PASS getArg
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/getArg.tentative.any.js (288064 => 288065)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/getArg.tentative.any.js 2022-01-15 21:17:40 UTC (rev 288064)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/getArg.tentative.any.js 2022-01-15 21:32:37 UTC (rev 288065)
@@ -20,7 +20,7 @@
test(() => {
const tag = new WebAssembly.Tag({ parameters: [] });
const exn = new WebAssembly.Exception(tag, []);
- assert_throws_js(RangeError, () => exn.getArg(tag, 1));
+ assert_throws_js(TypeError, () => exn.getArg(tag, 1));
}, "Index out of bounds");
test(() => {
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/getArg.tentative.any.worker-expected.txt (288064 => 288065)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/getArg.tentative.any.worker-expected.txt 2022-01-15 21:17:40 UTC (rev 288064)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/getArg.tentative.any.worker-expected.txt 2022-01-15 21:32:37 UTC (rev 288065)
@@ -1,11 +1,7 @@
-FAIL Missing arguments assert_throws_js: function "() => exn.getArg(tag)" threw object "RangeError: WebAssembly.Exception.getArg(): Index out of range" ("RangeError") expected instance of function "function TypeError() {
- [native code]
-}" ("TypeError")
+PASS Missing arguments
PASS Invalid exception argument
PASS Index out of bounds
-FAIL Getting out-of-range argument assert_throws_js: function "() => exn.getArg(tag, value)" threw object "RangeError: WebAssembly.Exception.getArg(): Index out of range" ("RangeError") expected instance of function "function TypeError() {
- [native code]
-}" ("TypeError")
+PASS Getting out-of-range argument
PASS getArg
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/toString.tentative.any-expected.txt (288064 => 288065)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/toString.tentative.any-expected.txt 2022-01-15 21:17:40 UTC (rev 288064)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/toString.tentative.any-expected.txt 2022-01-15 21:32:37 UTC (rev 288065)
@@ -1,4 +1,4 @@
PASS Object.prototype.toString on an Exception
-FAIL @@toStringTag exists on the prototype with the appropriate descriptor assert_own_property: expected property symbol "Symbol(Symbol.toStringTag)" missing
+PASS @@toStringTag exists on the prototype with the appropriate descriptor
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/toString.tentative.any.worker-expected.txt (288064 => 288065)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/toString.tentative.any.worker-expected.txt 2022-01-15 21:17:40 UTC (rev 288064)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/toString.tentative.any.worker-expected.txt 2022-01-15 21:32:37 UTC (rev 288065)
@@ -1,4 +1,4 @@
PASS Object.prototype.toString on an Exception
-FAIL @@toStringTag exists on the prototype with the appropriate descriptor assert_own_property: expected property symbol "Symbol(Symbol.toStringTag)" missing
+PASS @@toStringTag exists on the prototype with the appropriate descriptor
Deleted: trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/type.tentative.any-expected.txt (288064 => 288065)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/type.tentative.any-expected.txt 2022-01-15 21:17:40 UTC (rev 288064)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/type.tentative.any-expected.txt 2022-01-15 21:32:37 UTC (rev 288065)
@@ -1,5 +0,0 @@
-
-FAIL [] WebAssembly.Exception constructor expects the first argument to be a WebAssembly.Tag
-FAIL [i32 i64] WebAssembly.Exception constructor expects the first argument to be a WebAssembly.Tag
-FAIL [i32 i64 f32 f64] WebAssembly.Exception constructor expects the first argument to be a WebAssembly.Tag
-
Deleted: trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/type.tentative.any.html (288064 => 288065)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/type.tentative.any.html 2022-01-15 21:17:40 UTC (rev 288064)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/type.tentative.any.html 2022-01-15 21:32:37 UTC (rev 288065)
@@ -1 +0,0 @@
-<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file
Deleted: trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/type.tentative.any.js (288064 => 288065)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/type.tentative.any.js 2022-01-15 21:17:40 UTC (rev 288064)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/type.tentative.any.js 2022-01-15 21:32:37 UTC (rev 288065)
@@ -1,21 +0,0 @@
-// META: global=window,dedicatedworker,jsshell
-// META: script=/wasm/jsapi/assertions.js
-
-function assert_type(argument) {
- const exception = new WebAssembly.Exception(argument);
- const exceptiontype = exception.type();
-
- assert_array_equals(exceptiontype.parameters, argument.parameters);
-}
-
-test(() => {
- assert_type({ "parameters": [] });
-}, "[]");
-
-test(() => {
- assert_type({ "parameters": ["i32", "i64"] });
-}, "[i32 i64]");
-
-test(() => {
- assert_type({ "parameters": ["i32", "i64", "f32", "f64"] });
-}, "[i32 i64 f32 f64]");
Deleted: trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/type.tentative.any.worker-expected.txt (288064 => 288065)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/type.tentative.any.worker-expected.txt 2022-01-15 21:17:40 UTC (rev 288064)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/type.tentative.any.worker-expected.txt 2022-01-15 21:32:37 UTC (rev 288065)
@@ -1,5 +0,0 @@
-
-FAIL [] WebAssembly.Exception constructor expects the first argument to be a WebAssembly.Tag
-FAIL [i32 i64] WebAssembly.Exception constructor expects the first argument to be a WebAssembly.Tag
-FAIL [i32 i64 f32 f64] WebAssembly.Exception constructor expects the first argument to be a WebAssembly.Tag
-
Deleted: trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/type.tentative.any.worker.html (288064 => 288065)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/type.tentative.any.worker.html 2022-01-15 21:17:40 UTC (rev 288064)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/type.tentative.any.worker.html 2022-01-15 21:32:37 UTC (rev 288065)
@@ -1 +0,0 @@
-<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file
Modified: trunk/Source/_javascript_Core/ChangeLog (288064 => 288065)
--- trunk/Source/_javascript_Core/ChangeLog 2022-01-15 21:17:40 UTC (rev 288064)
+++ trunk/Source/_javascript_Core/ChangeLog 2022-01-15 21:32:37 UTC (rev 288065)
@@ -1,5 +1,19 @@
2022-01-15 Yusuke Suzuki <[email protected]>
+ [JSC] Fix misc issues in WebAssembly.Exception
+ https://bugs.webkit.org/show_bug.cgi?id=235261
+
+ Reviewed by Alexey Shvayka.
+
+ 1. Add @toStringTag to WebAssembly.Exception.prototype.
+ 2. Add argument count check for WebAssembly.Exception methods (since it is specified in WebIDL and these methods do not have optional parameters).
+
+ * wasm/js/WebAssemblyExceptionPrototype.cpp:
+ (JSC::WebAssemblyExceptionPrototype::finishCreation):
+ (JSC::JSC_DEFINE_HOST_FUNCTION):
+
+2022-01-15 Yusuke Suzuki <[email protected]>
+
[JSC] Fix misc WebAssembly.Table issues
https://bugs.webkit.org/show_bug.cgi?id=235262
Modified: trunk/Source/_javascript_Core/wasm/js/WebAssemblyExceptionPrototype.cpp (288064 => 288065)
--- trunk/Source/_javascript_Core/wasm/js/WebAssemblyExceptionPrototype.cpp 2022-01-15 21:17:40 UTC (rev 288064)
+++ trunk/Source/_javascript_Core/wasm/js/WebAssemblyExceptionPrototype.cpp 2022-01-15 21:32:37 UTC (rev 288065)
@@ -47,7 +47,7 @@
/* Source for WebAssemblyExceptionPrototype.lut.h
@begin prototypeTableWebAssemblyException
getArg webAssemblyExceptionProtoFuncGetArg Function 2
- is webAssemblyExceptionProtoFuncIs Function 1
+ is webAssemblyExceptionProtoFuncIs Function 1
@end
*/
@@ -67,6 +67,7 @@
{
Base::finishCreation(vm);
ASSERT(inherits(vm, info()));
+ JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
}
WebAssemblyExceptionPrototype::WebAssemblyExceptionPrototype(VM& vm, Structure* structure)
@@ -106,13 +107,15 @@
return makeString("WebAssembly.Exception.getArg(): ", message);
};
const auto& typeError = [&](const auto& message) {
- throwTypeError(globalObject, throwScope, formatMessage(message));
- return encodedJSValue();
+ return throwVMTypeError(globalObject, throwScope, formatMessage(message));
};
JSWebAssemblyException* jsException = getException(globalObject, callFrame->thisValue());
- RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ RETURN_IF_EXCEPTION(throwScope, { });
+ if (UNLIKELY(callFrame->argumentCount() < 2))
+ return JSValue::encode(throwException(globalObject, throwScope, createNotEnoughArgumentsError(globalObject)));
+
JSWebAssemblyTag* tag = getTag(vm, callFrame->argument(0));
if (!tag)
return typeError("First argument must be a WebAssembly.Tag");
@@ -121,10 +124,8 @@
return typeError("First argument does not match the exception tag");
uint32_t index = callFrame->argument(1).toUInt32(globalObject);
- if (index >= tag->tag().parameterCount()) {
- throwRangeError(globalObject, throwScope, formatMessage("Index out of range"));
- return encodedJSValue();
- }
+ if (index >= tag->tag().parameterCount())
+ return typeError("Index out of range");
RELEASE_AND_RETURN(throwScope, JSValue::encode(jsException->getArg(globalObject, index)));
}
@@ -135,13 +136,14 @@
auto throwScope = DECLARE_THROW_SCOPE(vm);
JSWebAssemblyException* jsException = getException(globalObject, callFrame->thisValue());
- RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+ RETURN_IF_EXCEPTION(throwScope, { });
+ if (UNLIKELY(callFrame->argumentCount() < 1))
+ return JSValue::encode(throwException(globalObject, throwScope, createNotEnoughArgumentsError(globalObject)));
+
JSWebAssemblyTag* tag = getTag(vm, callFrame->argument(0));
- if (!tag) {
- throwTypeError(globalObject, throwScope, "WebAssembly.Exception.is(): First argument must be a WebAssembly.Tag");
- return encodedJSValue();
- }
+ if (!tag)
+ return throwVMTypeError(globalObject, throwScope, "WebAssembly.Exception.is(): First argument must be a WebAssembly.Tag");
RELEASE_AND_RETURN(throwScope, JSValue::encode(jsBoolean(jsException->tag() == tag->tag())));
}