Title: [271039] trunk
Revision
271039
Author
[email protected]
Date
2020-12-21 13:31:23 -0800 (Mon, 21 Dec 2020)

Log Message

Source/_javascript_Core:
[JSC] Add minimum parameter to the WASM JS-API for Memory & Table.
https://bugs.webkit.org/show_bug.cgi?id=219600

Patch by Jessica Tallon <[email protected]> on 2020-12-21
Reviewed by Yusuke Suzuki.

This patch adds a "minimum" perameter to the constructor of both WebAssembly.Memory and
WebAssembly.Table. This represents the same value as the "initial" perameter. The new
perameter name is outlined here [1]. It is part of the JS type reflection proposal.

[1]: https://github.com/WebAssembly/js-types/blob/master/proposals/js-types/Overview.md#naming-of-size-limits

* JSTests/wasm/js-api/table.js:
* JSTests/wasm/js-api/test_memory_constructor.js:
* Source/_javascript_Core/wasm/js/WebAssemblyMemoryConstructor.cpp:
* Source/_javascript_Core/wasm/js/WebAssemblyTableConstructor.cpp:

LayoutTests:
[JSC] Fix expectation for WASM JS-type reflection WPTs
https://bugs.webkit.org/show_bug.cgi?id=219600

Patch by Jessica Tallon <[email protected]> on 2020-12-21
Reviewed by Yusuke Suzuki.

Changed the expectations for the WASM JS-Type reflections constructor
tests as we now support the minimum parameter.

* LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/memory/constructor-types.tentative.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/table/constructor-types.tentative.any-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/memory/constructor-types.tentative.any.worker-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/table/constructor-types.tentative.any.worker-expected.txt:

Modified Paths

Diff

Modified: trunk/JSTests/wasm/js-api/table.js (271038 => 271039)


--- trunk/JSTests/wasm/js-api/table.js	2020-12-21 20:48:53 UTC (rev 271038)
+++ trunk/JSTests/wasm/js-api/table.js	2020-12-21 21:31:23 UTC (rev 271039)
@@ -364,3 +364,29 @@
     assert.eq(instance.exports.table0.length, 0);
     assert.truthy(instance.exports.table instanceof WebAssembly.Table);
 }
+
+{
+    const args = {minimum: 5, element: "funcref"}
+    let minimum = false
+    const proxy = new Proxy(args, {
+        get(target, prop, receiver) {
+            if (prop === "minimum") {
+                minimum = true;
+            }
+            return Reflect.get(...arguments);
+        }
+    })
+    const table = new WebAssembly.Table(proxy);
+    assert.eq(table.length, 5);
+    assert.truthy(minimum);
+
+    let threw = false;
+    try {
+        new WebAssembly.Table({minimum: 5, initial: 5, element: "funcref"});
+    } catch (e) {
+        assert.truthy(e instanceof TypeError);
+        assert.eq(e.message, "WebAssembly.Table 'initial' and 'minimum' options are specified at the same time")
+        threw = true;
+    }
+    assert.truthy(threw);
+}

Modified: trunk/JSTests/wasm/js-api/test_memory_constructor.js (271038 => 271039)


--- trunk/JSTests/wasm/js-api/test_memory_constructor.js	2020-12-21 20:48:53 UTC (rev 271038)
+++ trunk/JSTests/wasm/js-api/test_memory_constructor.js	2020-12-21 21:31:23 UTC (rev 271039)
@@ -81,3 +81,29 @@
     }
     assert(threw);
 }
+
+{
+    const args = {minimum: 5};
+    let minimum = false;
+    const proxy = new Proxy(args, {
+        get(target, prop, receiver) {
+            if (prop === "minimum") {
+                minimum = true;
+            }
+            return Reflect.get(...arguments);
+        }
+    })
+    const mem = new WebAssembly.Memory(proxy);
+    assert(mem.buffer.byteLength === 5 * pageSize);
+    assert(minimum);
+
+    let threw = false;
+    try {
+        new WebAssembly.Memory({minimum: 5, initial: 5});
+    } catch (e) {
+        assert(e instanceof TypeError);
+        assert(e.message === "WebAssembly.Memory 'initial' and 'minimum' options are specified at the same time");
+        threw = true;
+    }
+    assert(threw);
+}

Modified: trunk/LayoutTests/ChangeLog (271038 => 271039)


--- trunk/LayoutTests/ChangeLog	2020-12-21 20:48:53 UTC (rev 271038)
+++ trunk/LayoutTests/ChangeLog	2020-12-21 21:31:23 UTC (rev 271039)
@@ -1,3 +1,18 @@
+2020-12-21  Jessica Tallon  <[email protected]>
+
+        [JSC] Fix expectation for WASM JS-type reflection WPTs
+        https://bugs.webkit.org/show_bug.cgi?id=219600
+
+        Reviewed by Yusuke Suzuki.
+
+        Changed the expectations for the WASM JS-Type reflections constructor
+        tests as we now support the minimum parameter.
+
+        * LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/memory/constructor-types.tentative.any-expected.txt:
+        * LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/table/constructor-types.tentative.any-expected.txt:
+        * LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/memory/constructor-types.tentative.any.worker-expected.txt:
+        * LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/table/constructor-types.tentative.any.worker-expected.txt:
+
 2020-12-21  Alicia Boya GarcĂ­a  <[email protected]>
 
         [MSE] Fix allSamplesInTrackEnqueued() handling

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/memory/constructor-types.tentative.any-expected.txt (271038 => 271039)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/memory/constructor-types.tentative.any-expected.txt	2020-12-21 20:48:53 UTC (rev 271038)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/memory/constructor-types.tentative.any-expected.txt	2020-12-21 21:31:23 UTC (rev 271039)
@@ -1,5 +1,5 @@
 
-FAIL Initializing with both initial and minimum assert_throws_js: function "() => new WebAssembly.Memory(argument)" did not throw
-FAIL Zero minimum Expect an integer argument in the range: [0, 2^32 - 1]
-FAIL Non-zero minimum Expect an integer argument in the range: [0, 2^32 - 1]
+PASS Initializing with both initial and minimum
+PASS Zero minimum
+PASS Non-zero minimum
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/memory/constructor-types.tentative.any.worker-expected.txt (271038 => 271039)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/memory/constructor-types.tentative.any.worker-expected.txt	2020-12-21 20:48:53 UTC (rev 271038)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/memory/constructor-types.tentative.any.worker-expected.txt	2020-12-21 21:31:23 UTC (rev 271039)
@@ -1,5 +1,5 @@
 
-FAIL Initializing with both initial and minimum assert_throws_js: function "() => new WebAssembly.Memory(argument)" did not throw
-FAIL Zero minimum Expect an integer argument in the range: [0, 2^32 - 1]
-FAIL Non-zero minimum Expect an integer argument in the range: [0, 2^32 - 1]
+PASS Initializing with both initial and minimum
+PASS Zero minimum
+PASS Non-zero minimum
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/table/constructor-types.tentative.any-expected.txt (271038 => 271039)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/table/constructor-types.tentative.any-expected.txt	2020-12-21 20:48:53 UTC (rev 271038)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/table/constructor-types.tentative.any-expected.txt	2020-12-21 21:31:23 UTC (rev 271039)
@@ -1,5 +1,5 @@
 
-FAIL Initializing with both initial and minimum assert_throws_js: function "() => new WebAssembly.Table(argument)" did not throw
-FAIL Zero minimum Expect an integer argument in the range: [0, 2^32 - 1]
-FAIL Non-zero minimum Expect an integer argument in the range: [0, 2^32 - 1]
+PASS Initializing with both initial and minimum
+PASS Zero minimum
+PASS Non-zero minimum
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/table/constructor-types.tentative.any.worker-expected.txt (271038 => 271039)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/table/constructor-types.tentative.any.worker-expected.txt	2020-12-21 20:48:53 UTC (rev 271038)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/table/constructor-types.tentative.any.worker-expected.txt	2020-12-21 21:31:23 UTC (rev 271039)
@@ -1,5 +1,5 @@
 
-FAIL Initializing with both initial and minimum assert_throws_js: function "() => new WebAssembly.Table(argument)" did not throw
-FAIL Zero minimum Expect an integer argument in the range: [0, 2^32 - 1]
-FAIL Non-zero minimum Expect an integer argument in the range: [0, 2^32 - 1]
+PASS Initializing with both initial and minimum
+PASS Zero minimum
+PASS Non-zero minimum
 

Modified: trunk/Source/_javascript_Core/ChangeLog (271038 => 271039)


--- trunk/Source/_javascript_Core/ChangeLog	2020-12-21 20:48:53 UTC (rev 271038)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-12-21 21:31:23 UTC (rev 271039)
@@ -1,3 +1,21 @@
+2020-12-21  Jessica Tallon  <[email protected]>
+
+        [JSC] Add minimum parameter to the WASM JS-API for Memory & Table.
+        https://bugs.webkit.org/show_bug.cgi?id=219600
+
+        Reviewed by Yusuke Suzuki.
+
+        This patch adds a "minimum" perameter to the constructor of both WebAssembly.Memory and
+        WebAssembly.Table. This represents the same value as the "initial" perameter. The new
+        perameter name is outlined here [1]. It is part of the JS type reflection proposal.
+
+        [1]: https://github.com/WebAssembly/js-types/blob/master/proposals/js-types/Overview.md#naming-of-size-limits
+
+        * JSTests/wasm/js-api/table.js:
+        * JSTests/wasm/js-api/test_memory_constructor.js:
+        * Source/_javascript_Core/wasm/js/WebAssemblyMemoryConstructor.cpp:
+        * Source/_javascript_Core/wasm/js/WebAssemblyTableConstructor.cpp:
+
 2020-12-21  Keith Miller  <[email protected]>
 
         DFG should make sure replacement watchpoint is fired before folding to PutByOffset

Modified: trunk/Source/_javascript_Core/wasm/js/WebAssemblyMemoryConstructor.cpp (271038 => 271039)


--- trunk/Source/_javascript_Core/wasm/js/WebAssemblyMemoryConstructor.cpp	2020-12-21 20:48:53 UTC (rev 271038)
+++ trunk/Source/_javascript_Core/wasm/js/WebAssemblyMemoryConstructor.cpp	2020-12-21 21:31:23 UTC (rev 271039)
@@ -68,8 +68,18 @@
     Wasm::PageCount initialPageCount;
     {
         Identifier initial = Identifier::fromString(vm, "initial");
-        JSValue minSizeValue = memoryDescriptor->get(globalObject, initial);
+        JSValue initSizeValue = memoryDescriptor->get(globalObject, initial);
         RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+        Identifier minimum = Identifier::fromString(vm, "minimum");
+        JSValue minSizeValue = memoryDescriptor->get(globalObject, minimum);
+        RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+        if (!minSizeValue.isUndefined() && !initSizeValue.isUndefined()) {
+            // Error because both specified.
+            return throwVMTypeError(globalObject, throwScope, "WebAssembly.Memory 'initial' and 'minimum' options are specified at the same time");
+        }
+        if (!initSizeValue.isUndefined())
+            minSizeValue = initSizeValue;
+
         uint32_t size = toNonWrappingUint32(globalObject, minSizeValue);
         RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
         if (!Wasm::PageCount::isValid(size))

Modified: trunk/Source/_javascript_Core/wasm/js/WebAssemblyTableConstructor.cpp (271038 => 271039)


--- trunk/Source/_javascript_Core/wasm/js/WebAssemblyTableConstructor.cpp	2020-12-21 20:48:53 UTC (rev 271038)
+++ trunk/Source/_javascript_Core/wasm/js/WebAssemblyTableConstructor.cpp	2020-12-21 21:31:23 UTC (rev 271039)
@@ -81,6 +81,15 @@
     Identifier initialIdent = Identifier::fromString(vm, "initial");
     JSValue initialSizeValue = memoryDescriptor->get(globalObject, initialIdent);
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+    Identifier minimumIdent = Identifier::fromString(vm, "minimum");
+    JSValue minSizeValue = memoryDescriptor->get(globalObject, minimumIdent);
+    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
+    if (!initialSizeValue.isUndefined() && !minSizeValue.isUndefined())
+        return throwVMTypeError(globalObject, throwScope, "WebAssembly.Table 'initial' and 'minimum' options are specified at the same time");
+
+    if (!minSizeValue.isUndefined())
+        initialSizeValue = minSizeValue;
+
     uint32_t initial = toNonWrappingUint32(globalObject, initialSizeValue);
     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to