Diff
Modified: trunk/JSTests/ChangeLog (272080 => 272081)
--- trunk/JSTests/ChangeLog 2021-01-29 22:55:07 UTC (rev 272080)
+++ trunk/JSTests/ChangeLog 2021-01-29 23:07:25 UTC (rev 272081)
@@ -1,3 +1,13 @@
+2021-01-29 Yusuke Suzuki <[email protected]>
+
+ [JSC] Fix WebAssembly.Global's error message and support "funcref"
+ https://bugs.webkit.org/show_bug.cgi?id=221157
+
+ Reviewed by Keith Miller.
+
+ * wasm/stress/global-wrong-type.js: Added.
+ (assert.throws):
+
2021-01-29 Dmitry Bezhetskov <[email protected]>
[JSC] WebAssembly.Global should support Funcref and Externref
Added: trunk/JSTests/wasm/stress/global-wrong-type.js (0 => 272081)
--- trunk/JSTests/wasm/stress/global-wrong-type.js (rev 0)
+++ trunk/JSTests/wasm/stress/global-wrong-type.js 2021-01-29 23:07:25 UTC (rev 272081)
@@ -0,0 +1,13 @@
+import * as assert from '../assert.js';
+
+assert.throws(() => {
+ new WebAssembly.Global({
+ value: 'cocoa'
+ });
+}, TypeError, `WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', 'f64', 'anyfunc', 'funcref', or 'externref'`);
+
+assert.throws(() => {
+ new WebAssembly.Global({
+ value: 'anyfunc'
+ }, {});
+}, WebAssembly.RuntimeError, `Funcref must be an exported wasm function`);
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (272080 => 272081)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-01-29 22:55:07 UTC (rev 272080)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2021-01-29 23:07:25 UTC (rev 272081)
@@ -1,3 +1,15 @@
+2021-01-29 Yusuke Suzuki <[email protected]>
+
+ [JSC] Fix WebAssembly.Global's error message and support "funcref"
+ https://bugs.webkit.org/show_bug.cgi?id=221157
+
+ Reviewed by Keith Miller.
+
+ We also update test expect files failing after r272074.
+
+ * web-platform-tests/wasm/jsapi/global/type.tentative.any-expected.txt:
+ * web-platform-tests/wasm/jsapi/global/type.tentative.any.worker-expected.txt:
+
2021-01-28 Martin Robinson <[email protected]>
Add support for logical variants of 'scroll-padding' and 'scroll-margin'
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/global/type.tentative.any-expected.txt (272080 => 272081)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/global/type.tentative.any-expected.txt 2021-01-29 22:55:07 UTC (rev 272080)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/global/type.tentative.any-expected.txt 2021-01-29 23:07:25 UTC (rev 272081)
@@ -7,9 +7,9 @@
FAIL f32, immutable undefined is not an object (evaluating 'myglobal.type.value')
FAIL f64, mutable undefined is not an object (evaluating 'myglobal.type.value')
FAIL f64, immutable undefined is not an object (evaluating 'myglobal.type.value')
-FAIL anyref, mutable WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', or 'f64'
-FAIL anyref, immutable WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', or 'f64'
-FAIL funcref, mutable WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', or 'f64'
-FAIL funcref, immutable WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', or 'f64'
+FAIL anyref, mutable undefined is not an object (evaluating 'myglobal.type.value')
+FAIL anyref, immutable undefined is not an object (evaluating 'myglobal.type.value')
+FAIL funcref, mutable undefined is not an object (evaluating 'myglobal.type.value')
+FAIL funcref, immutable undefined is not an object (evaluating 'myglobal.type.value')
FAIL key ordering undefined is not an object (evaluating 'Object.getOwnPropertyNames(myglobal.type)')
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/global/type.tentative.any.worker-expected.txt (272080 => 272081)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/global/type.tentative.any.worker-expected.txt 2021-01-29 22:55:07 UTC (rev 272080)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/global/type.tentative.any.worker-expected.txt 2021-01-29 23:07:25 UTC (rev 272081)
@@ -7,9 +7,9 @@
FAIL f32, immutable undefined is not an object (evaluating 'myglobal.type.value')
FAIL f64, mutable undefined is not an object (evaluating 'myglobal.type.value')
FAIL f64, immutable undefined is not an object (evaluating 'myglobal.type.value')
-FAIL anyref, mutable WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', or 'f64'
-FAIL anyref, immutable WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', or 'f64'
-FAIL funcref, mutable WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', or 'f64'
-FAIL funcref, immutable WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', or 'f64'
+FAIL anyref, mutable undefined is not an object (evaluating 'myglobal.type.value')
+FAIL anyref, immutable undefined is not an object (evaluating 'myglobal.type.value')
+FAIL funcref, mutable undefined is not an object (evaluating 'myglobal.type.value')
+FAIL funcref, immutable undefined is not an object (evaluating 'myglobal.type.value')
FAIL key ordering undefined is not an object (evaluating 'Object.getOwnPropertyNames(myglobal.type)')
Modified: trunk/Source/_javascript_Core/ChangeLog (272080 => 272081)
--- trunk/Source/_javascript_Core/ChangeLog 2021-01-29 22:55:07 UTC (rev 272080)
+++ trunk/Source/_javascript_Core/ChangeLog 2021-01-29 23:07:25 UTC (rev 272081)
@@ -1,3 +1,18 @@
+2021-01-29 Yusuke Suzuki <[email protected]>
+
+ [JSC] Fix WebAssembly.Global's error message and support "funcref"
+ https://bugs.webkit.org/show_bug.cgi?id=221157
+
+ Reviewed by Keith Miller.
+
+ Since it accepts "anyfunc" and "externref", we should update the error message.
+ And we should support "funcref" too.
+
+ * wasm/js/WebAssemblyGlobalConstructor.cpp:
+ (JSC::JSC_DEFINE_HOST_FUNCTION):
+ * wasm/js/WebAssemblyTableConstructor.cpp:
+ (JSC::JSC_DEFINE_HOST_FUNCTION):
+
2021-01-29 Dmitry Bezhetskov <[email protected]>
[WASM-References] Enable reference types by default
Modified: trunk/Source/_javascript_Core/wasm/js/WebAssemblyGlobalConstructor.cpp (272080 => 272081)
--- trunk/Source/_javascript_Core/wasm/js/WebAssemblyGlobalConstructor.cpp 2021-01-29 22:55:07 UTC (rev 272080)
+++ trunk/Source/_javascript_Core/wasm/js/WebAssemblyGlobalConstructor.cpp 2021-01-29 23:07:25 UTC (rev 272081)
@@ -86,20 +86,20 @@
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
String valueString = valueValue.toWTFString(globalObject);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
- if (valueString == "i32")
+ if (valueString == "i32"_s)
type = Wasm::Type::I32;
- else if (valueString == "i64")
+ else if (valueString == "i64"_s)
type = Wasm::Type::I64;
- else if (valueString == "f32")
+ else if (valueString == "f32"_s)
type = Wasm::Type::F32;
- else if (valueString == "f64")
+ else if (valueString == "f64"_s)
type = Wasm::Type::F64;
- else if (Options::useWebAssemblyReferences() && valueString == "anyfunc")
+ else if (Options::useWebAssemblyReferences() && (valueString == "anyfunc"_s || valueString == "funcref"_s))
type = Wasm::Type::Funcref;
- else if (Options::useWebAssemblyReferences() && valueString == "externref")
+ else if (Options::useWebAssemblyReferences() && valueString == "externref"_s)
type = Wasm::Type::Externref;
else
- return JSValue::encode(throwException(globalObject, throwScope, createTypeError(globalObject, "WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', or 'f64'"_s)));
+ return JSValue::encode(throwException(globalObject, throwScope, createTypeError(globalObject, "WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', 'f64', 'anyfunc', 'funcref', or 'externref'"_s)));
}
uint64_t initialValue = 0;
Modified: trunk/Source/_javascript_Core/wasm/js/WebAssemblyTableConstructor.cpp (272080 => 272081)
--- trunk/Source/_javascript_Core/wasm/js/WebAssemblyTableConstructor.cpp 2021-01-29 22:55:07 UTC (rev 272080)
+++ trunk/Source/_javascript_Core/wasm/js/WebAssemblyTableConstructor.cpp 2021-01-29 23:07:25 UTC (rev 272081)
@@ -76,9 +76,9 @@
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
String elementString = elementValue.toWTFString(globalObject);
RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
- if (elementString == "funcref" || elementString == "anyfunc")
+ if (elementString == "funcref"_s || elementString == "anyfunc"_s)
type = Wasm::TableElementType::Funcref;
- else if (elementString == "externref")
+ else if (elementString == "externref"_s)
type = Wasm::TableElementType::Externref;
else
return throwVMTypeError(globalObject, throwScope, "WebAssembly.Table expects its 'element' field to be the string 'funcref' or 'externref'"_s);