Title: [269790] trunk
Revision
269790
Author
[email protected]
Date
2020-11-13 13:39:02 -0800 (Fri, 13 Nov 2020)

Log Message

WebAssembly: opcodes for table.grow and table.size are mixed up
https://bugs.webkit.org/show_bug.cgi?id=218644

Patch by Sergey Rubanov <[email protected]> on 2020-11-13
Reviewed by Yusuke Suzuki.

JSTests:

* wasm/stress/table-grow-table-size.js: Added.
(async test):
* wasm/wasm.json:

Source/_javascript_Core:

* wasm/wasm.json:

LayoutTests:

* workers/wasm-references/test.js:

Modified Paths

Added Paths

Diff

Modified: trunk/JSTests/ChangeLog (269789 => 269790)


--- trunk/JSTests/ChangeLog	2020-11-13 21:19:45 UTC (rev 269789)
+++ trunk/JSTests/ChangeLog	2020-11-13 21:39:02 UTC (rev 269790)
@@ -1,5 +1,16 @@
 2020-11-13  Sergey Rubanov  <[email protected]>
 
+        WebAssembly: opcodes for table.grow and table.size are mixed up
+        https://bugs.webkit.org/show_bug.cgi?id=218644
+
+        Reviewed by Yusuke Suzuki.
+
+        * wasm/stress/table-grow-table-size.js: Added.
+        (async test):
+        * wasm/wasm.json:
+
+2020-11-13  Sergey Rubanov  <[email protected]>
+
         WebAssembly: update wabt.js
         https://bugs.webkit.org/show_bug.cgi?id=218876
 

Added: trunk/JSTests/wasm/stress/table-grow-table-size.js (0 => 269790)


--- trunk/JSTests/wasm/stress/table-grow-table-size.js	                        (rev 0)
+++ trunk/JSTests/wasm/stress/table-grow-table-size.js	2020-11-13 21:39:02 UTC (rev 269790)
@@ -0,0 +1,22 @@
+//@ requireOptions("--useWebAssemblyReferences=1")
+import { instantiate } from "../wabt-wrapper.js";
+import * as assert from "../assert.js";
+
+let wat = `
+(module
+  (table $table 0 externref)
+  (func (export "size") (result i32) (table.size $table))
+  (func (export "grow") (param $sz i32) (result i32) 
+    (table.grow $table (ref.null extern) (local.get $sz))
+  )
+)
+`;
+async function test() {
+    const instance = await instantiate(wat, {}, {reference_types: true});
+    const {size, grow} = instance.exports;
+    assert.eq(size(), 0);
+    assert.eq(grow(42), 0);
+    assert.eq(size(), 42);
+}
+
+assert.asyncTest(test());

Modified: trunk/JSTests/wasm/wasm.json (269789 => 269790)


--- trunk/JSTests/wasm/wasm.json	2020-11-13 21:19:45 UTC (rev 269789)
+++ trunk/JSTests/wasm/wasm.json	2020-11-13 21:39:02 UTC (rev 269790)
@@ -69,9 +69,9 @@
         "set_global":          { "category": "special",    "value":  36, "return": [],                               "parameter": ["any"],                        "immediate": [{"name": "global_index",   "type": "varuint32"}],                                             "description": "write a global variable" },
         "table.get":           { "category": "special",    "value":  37, "return": ["externref"],                    "parameter": ["i32"],                        "immediate": [{"name": "table_index",    "type": "varuint32"}],                                             "description": "get a table value" },
         "table.set":           { "category": "special",    "value":  38, "return": [],                               "parameter": ["i32", "externref"],           "immediate": [{"name": "table_index",    "type": "varuint32"}],                                             "description": "set a table value" },
-        "table.size":          { "category": "exttable",   "value":  252, "return": ["i32"],                         "parameter": [],                             "immediate": [{"name": "table_index",    "type": "varuint32"}],                                             "description": "get the size of a table", "extendedOp": 15 },
-        "table.grow":          { "category": "exttable",   "value":  252, "return": ["i32"],                         "parameter": ["externref", "i32"],           "immediate": [{"name": "table_index",    "type": "varuint32"}],                                             "description": "grow a table by the given delta and return the previous size, or -1 if enough space cannot be allocated", "extendedOp": 16 },
-        "table.fill":          { "category": "exttable",   "value":  252, "return": ["i32"],                         "parameter": ["i32", "externref", "i32"],    "immediate": [{"name": "table_index",    "type": "varuint32"}],                                             "description": "fill entries [i,i+n) with the given value", "extendedOp": 17 },
+        "table.grow":          { "category": "exttable",   "value":  252, "return": ["i32"],                         "parameter": ["externref", "i32"],           "immediate": [{"name": "table_index",    "type": "varuint32"}],                                             "description": "grow a table by the given delta and return the previous size, or -1 if enough space cannot be allocated", "extendedOp": 15 },
+        "table.size":          { "category": "exttable",   "value":  252, "return": ["i32"],                         "parameter": [],                             "immediate": [{"name": "table_index",    "type": "varuint32"}],                                             "description": "get the size of a table", "extendedOp": 16 },
+        "table.fill":           { "category": "exttable",   "value":  252, "return": ["i32"],                         "parameter": ["i32", "externref", "i32"],    "immediate": [{"name": "table_index",    "type": "varuint32"}],                                             "description": "fill entries [i,i+n) with the given value", "extendedOp": 17 },
         "call":                { "category": "call",       "value":  16, "return": ["call"],                         "parameter": ["call"],                       "immediate": [{"name": "function_index", "type": "varuint32"}],                                             "description": "call a function by its index" },
         "call_indirect":       { "category": "call",       "value":  17, "return": ["call"],                         "parameter": ["call"],                       "immediate": [{"name": "type_index",     "type": "varuint32"}, {"name": "table_index","type": "varuint32"}],"description": "call a function indirect with an expected signature" },
         "i32.load8_s":         { "category": "memory",     "value":  44, "return": ["i32"],                          "parameter": ["addr"],                       "immediate": [{"name": "flags",          "type": "varuint32"}, {"name": "offset",   "type": "varuint32"}], "description": "load from memory" },

Modified: trunk/LayoutTests/ChangeLog (269789 => 269790)


--- trunk/LayoutTests/ChangeLog	2020-11-13 21:19:45 UTC (rev 269789)
+++ trunk/LayoutTests/ChangeLog	2020-11-13 21:39:02 UTC (rev 269790)
@@ -1,3 +1,12 @@
+2020-11-13  Sergey Rubanov  <[email protected]>
+
+        WebAssembly: opcodes for table.grow and table.size are mixed up
+        https://bugs.webkit.org/show_bug.cgi?id=218644
+
+        Reviewed by Yusuke Suzuki.
+
+        * workers/wasm-references/test.js:
+
 2020-11-12  Darin Adler  <[email protected]>
 
         Remove unused advanced plug-in features: snapshotting and plug-in load policy

Modified: trunk/LayoutTests/workers/wasm-references/test.js (269789 => 269790)


--- trunk/LayoutTests/workers/wasm-references/test.js	2020-11-13 21:19:45 UTC (rev 269789)
+++ trunk/LayoutTests/workers/wasm-references/test.js	2020-11-13 21:39:02 UTC (rev 269790)
@@ -239,8 +239,8 @@
         "set_global":          { "category": "special",    "value":  36, "return": [],           "parameter": ["any"],                  "immediate": [{"name": "global_index",   "type": "varuint32"}],                                            "description": "write a global variable" },
         "table.get":           { "category": "special",    "value":  37, "return": ["externref"],   "parameter": ["i32"],                  "immediate": [{"name": "table_index",    "type": "varuint32"}],                                            "description": "get a table value" },
         "table.set":           { "category": "special",    "value":  38, "return": [],           "parameter": ["i32", "externref"],        "immediate": [{"name": "table_index",    "type": "varuint32"}],                                            "description": "set a table value" },
-        "table.size":          { "category": "exttable",   "value":  252, "return": ["i32"],     "parameter": [],                       "immediate": [{"name": "global_index",   "type": "varuint32"}],                                            "description": "get the size of a table", "extendedOp": 15 },
-        "table.grow":          { "category": "exttable",   "value":  252, "return": ["i32"],     "parameter": ["externref", "i32"],        "immediate": [{"name": "global_index",   "type": "varuint32"}],                                            "description": "grow a table by the given delta and return the previous size, or -1 if enough space cannot be allocated", "extendedOp": 16 },
+        "table.grow":          { "category": "exttable",   "value":  252, "return": ["i32"],     "parameter": ["externref", "i32"],        "immediate": [{"name": "global_index",   "type": "varuint32"}],                                            "description": "grow a table by the given delta and return the previous size, or -1 if enough space cannot be allocated", "extendedOp": 15 },
+        "table.size":          { "category": "exttable",   "value":  252, "return": ["i32"],     "parameter": [],                       "immediate": [{"name": "global_index",   "type": "varuint32"}],                                            "description": "get the size of a table", "extendedOp": 16 },
         "table.fill":          { "category": "exttable",   "value":  252, "return": ["i32"],     "parameter": ["i32", "externref", "i32"], "immediate": [{"name": "global_index",   "type": "varuint32"}],                                            "description": "fill entries [i,i+n) with the given value", "extendedOp": 17 },
         "call":                { "category": "call",       "value":  16, "return": ["call"],     "parameter": ["call"],                 "immediate": [{"name": "function_index", "type": "varuint32"}],                                            "description": "call a function by its index" },
         "call_indirect":       { "category": "call",       "value":  17, "return": ["call"],     "parameter": ["call"],                 "immediate": [{"name": "type_index",     "type": "varuint32"}, {"name": "table_index","type": "varuint32"}],"description": "call a function indirect with an expected signature" },

Modified: trunk/Source/_javascript_Core/ChangeLog (269789 => 269790)


--- trunk/Source/_javascript_Core/ChangeLog	2020-11-13 21:19:45 UTC (rev 269789)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-11-13 21:39:02 UTC (rev 269790)
@@ -1,3 +1,12 @@
+2020-11-13  Sergey Rubanov  <[email protected]>
+
+        WebAssembly: opcodes for table.grow and table.size are mixed up
+        https://bugs.webkit.org/show_bug.cgi?id=218644
+
+        Reviewed by Yusuke Suzuki.
+
+        * wasm/wasm.json:
+
 2020-11-12  Devin Rousso  <[email protected]>
 
         Web Inspector: ensure that `JSON::ArrayOf<T>` doesn't allow `addItem` to be called with a type other than `T`

Modified: trunk/Source/_javascript_Core/wasm/wasm.json (269789 => 269790)


--- trunk/Source/_javascript_Core/wasm/wasm.json	2020-11-13 21:19:45 UTC (rev 269789)
+++ trunk/Source/_javascript_Core/wasm/wasm.json	2020-11-13 21:39:02 UTC (rev 269790)
@@ -69,9 +69,9 @@
         "set_global":          { "category": "special",    "value":  36, "return": [],                               "parameter": ["any"],                        "immediate": [{"name": "global_index",   "type": "varuint32"}],                                             "description": "write a global variable" },
         "table.get":           { "category": "special",    "value":  37, "return": ["externref"],                    "parameter": ["i32"],                        "immediate": [{"name": "table_index",    "type": "varuint32"}],                                             "description": "get a table value" },
         "table.set":           { "category": "special",    "value":  38, "return": [],                               "parameter": ["i32", "externref"],           "immediate": [{"name": "table_index",    "type": "varuint32"}],                                             "description": "set a table value" },
-        "table.size":          { "category": "exttable",   "value":  252, "return": ["i32"],                         "parameter": [],                             "immediate": [{"name": "table_index",    "type": "varuint32"}],                                             "description": "get the size of a table", "extendedOp": 15 },
-        "table.grow":          { "category": "exttable",   "value":  252, "return": ["i32"],                         "parameter": ["externref", "i32"],           "immediate": [{"name": "table_index",    "type": "varuint32"}],                                             "description": "grow a table by the given delta and return the previous size, or -1 if enough space cannot be allocated", "extendedOp": 16 },
-        "table.fill":          { "category": "exttable",   "value":  252, "return": ["i32"],                         "parameter": ["i32", "externref", "i32"],    "immediate": [{"name": "table_index",    "type": "varuint32"}],                                             "description": "fill entries [i,i+n) with the given value", "extendedOp": 17 },
+        "table.grow":          { "category": "exttable",   "value":  252, "return": ["i32"],                         "parameter": ["externref", "i32"],           "immediate": [{"name": "table_index",    "type": "varuint32"}],                                             "description": "grow a table by the given delta and return the previous size, or -1 if enough space cannot be allocated", "extendedOp": 15 },
+        "table.size":          { "category": "exttable",   "value":  252, "return": ["i32"],                         "parameter": [],                             "immediate": [{"name": "table_index",    "type": "varuint32"}],                                             "description": "get the size of a table", "extendedOp": 16 },
+        "table.fill":           { "category": "exttable",   "value":  252, "return": ["i32"],                         "parameter": ["i32", "externref", "i32"],    "immediate": [{"name": "table_index",    "type": "varuint32"}],                                             "description": "fill entries [i,i+n) with the given value", "extendedOp": 17 },
         "call":                { "category": "call",       "value":  16, "return": ["call"],                         "parameter": ["call"],                       "immediate": [{"name": "function_index", "type": "varuint32"}],                                             "description": "call a function by its index" },
         "call_indirect":       { "category": "call",       "value":  17, "return": ["call"],                         "parameter": ["call"],                       "immediate": [{"name": "type_index",     "type": "varuint32"}, {"name": "table_index","type": "varuint32"}],"description": "call a function indirect with an expected signature" },
         "i32.load8_s":         { "category": "memory",     "value":  44, "return": ["i32"],                          "parameter": ["addr"],                       "immediate": [{"name": "flags",          "type": "varuint32"}, {"name": "offset",   "type": "varuint32"}], "description": "load from memory" },
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to