Title: [208634] trunk/JSTests
Revision
208634
Author
[email protected]
Date
2016-11-11 18:25:48 -0800 (Fri, 11 Nov 2016)

Log Message

Relocate wasm tests and actually add them to the test runner
https://bugs.webkit.org/show_bug.cgi?id=164668

Reviewed by Yusuke Suzuki.

This moves the Wasm tests from their current location down a level.
Without relocating, the tests cannot properly be run by the wasm test runner.

* wasm.yaml:
* wasm/Builder.js: Fix typos, yay lazy synatx checking!
* wasm/LowLevelBinary.js: Fix typos, yay lazy synatx checking!
(export.default.LowLevelBinary.prototype.get return):
* wasm/function-tests/add-12.js: Renamed from JSTests/wasm/js-api/function-tests/add-12.js.
* wasm/function-tests/br-if-loop-less-than.js: Renamed from JSTests/wasm/js-api/function-tests/br-if-loop-less-than.js.
* wasm/function-tests/brTableAsIf.js: Renamed from JSTests/wasm/js-api/function-tests/brTableAsIf.js.
* wasm/function-tests/brTableManyValues.js: Renamed from JSTests/wasm/js-api/function-tests/brTableManyValues.js.
* wasm/function-tests/brTableWithLoop.js: Renamed from JSTests/wasm/js-api/function-tests/brTableWithLoop.js.
* wasm/function-tests/dumb-eq-if-then-else.js: Renamed from JSTests/wasm/js-api/function-tests/dumb-eq-if-then-else.js.
* wasm/function-tests/dumb-less-than-fallthrough.js: Renamed from JSTests/wasm/js-api/function-tests/dumb-less-than-fallthrough.js.
* wasm/function-tests/dumb-less-than-ite.js: Renamed from JSTests/wasm/js-api/function-tests/dumb-less-than-ite.js.
* wasm/function-tests/factorial.js: Renamed from JSTests/wasm/js-api/function-tests/factorial.js.
* wasm/function-tests/float-sub.js: Renamed from JSTests/wasm/js-api/function-tests/float-sub.js.
* wasm/function-tests/i32-load.js: Renamed from JSTests/wasm/js-api/function-tests/i32-load.js.
* wasm/function-tests/i32-load8-s.js: Renamed from JSTests/wasm/js-api/function-tests/i32-load8-s.js.
* wasm/function-tests/if-then-else-fallthrough.js: Renamed from JSTests/wasm/js-api/function-tests/if-then-else-fallthrough.js.
* wasm/function-tests/if-then-fallthrough.js: Renamed from JSTests/wasm/js-api/function-tests/if-then-fallthrough.js.
* wasm/function-tests/loop-mult.js: Renamed from JSTests/wasm/js-api/function-tests/loop-mult.js.
* wasm/function-tests/loop-sum.js: Renamed from JSTests/wasm/js-api/function-tests/loop-sum.js.
* wasm/function-tests/ret5.js: Renamed from JSTests/wasm/js-api/function-tests/ret5.js.
* wasm/self-test/test_BuilderJSON.js: Rebasline

Modified Paths

Added Paths

Removed Paths

  • trunk/JSTests/wasm/js-api/function-tests/

Diff

Modified: trunk/JSTests/ChangeLog (208633 => 208634)


--- trunk/JSTests/ChangeLog	2016-11-12 01:18:22 UTC (rev 208633)
+++ trunk/JSTests/ChangeLog	2016-11-12 02:25:48 UTC (rev 208634)
@@ -1,5 +1,38 @@
 2016-11-11  Keith Miller  <[email protected]>
 
+        Relocate wasm tests and actually add them to the test runner
+        https://bugs.webkit.org/show_bug.cgi?id=164668
+
+        Reviewed by Yusuke Suzuki.
+
+        This moves the Wasm tests from their current location down a level.
+        Without relocating, the tests cannot properly be run by the wasm test runner.
+
+        * wasm.yaml:
+        * wasm/Builder.js: Fix typos, yay lazy synatx checking!
+        * wasm/LowLevelBinary.js: Fix typos, yay lazy synatx checking!
+        (export.default.LowLevelBinary.prototype.get return):
+        * wasm/function-tests/add-12.js: Renamed from JSTests/wasm/js-api/function-tests/add-12.js.
+        * wasm/function-tests/br-if-loop-less-than.js: Renamed from JSTests/wasm/js-api/function-tests/br-if-loop-less-than.js.
+        * wasm/function-tests/brTableAsIf.js: Renamed from JSTests/wasm/js-api/function-tests/brTableAsIf.js.
+        * wasm/function-tests/brTableManyValues.js: Renamed from JSTests/wasm/js-api/function-tests/brTableManyValues.js.
+        * wasm/function-tests/brTableWithLoop.js: Renamed from JSTests/wasm/js-api/function-tests/brTableWithLoop.js.
+        * wasm/function-tests/dumb-eq-if-then-else.js: Renamed from JSTests/wasm/js-api/function-tests/dumb-eq-if-then-else.js.
+        * wasm/function-tests/dumb-less-than-fallthrough.js: Renamed from JSTests/wasm/js-api/function-tests/dumb-less-than-fallthrough.js.
+        * wasm/function-tests/dumb-less-than-ite.js: Renamed from JSTests/wasm/js-api/function-tests/dumb-less-than-ite.js.
+        * wasm/function-tests/factorial.js: Renamed from JSTests/wasm/js-api/function-tests/factorial.js.
+        * wasm/function-tests/float-sub.js: Renamed from JSTests/wasm/js-api/function-tests/float-sub.js.
+        * wasm/function-tests/i32-load.js: Renamed from JSTests/wasm/js-api/function-tests/i32-load.js.
+        * wasm/function-tests/i32-load8-s.js: Renamed from JSTests/wasm/js-api/function-tests/i32-load8-s.js.
+        * wasm/function-tests/if-then-else-fallthrough.js: Renamed from JSTests/wasm/js-api/function-tests/if-then-else-fallthrough.js.
+        * wasm/function-tests/if-then-fallthrough.js: Renamed from JSTests/wasm/js-api/function-tests/if-then-fallthrough.js.
+        * wasm/function-tests/loop-mult.js: Renamed from JSTests/wasm/js-api/function-tests/loop-mult.js.
+        * wasm/function-tests/loop-sum.js: Renamed from JSTests/wasm/js-api/function-tests/loop-sum.js.
+        * wasm/function-tests/ret5.js: Renamed from JSTests/wasm/js-api/function-tests/ret5.js.
+        * wasm/self-test/test_BuilderJSON.js: Rebasline
+
+2016-11-11  Keith Miller  <[email protected]>
+
         Move Wasm tests to JS
         https://bugs.webkit.org/show_bug.cgi?id=164611
 

Modified: trunk/JSTests/wasm/Builder.js (208633 => 208634)


--- trunk/JSTests/wasm/Builder.js	2016-11-12 01:18:22 UTC (rev 208633)
+++ trunk/JSTests/wasm/Builder.js	2016-11-12 02:25:48 UTC (rev 208634)
@@ -155,7 +155,7 @@
 };
 
 const _checkStackArgs = (op, param) => {
-    for (let expect of paramn) {
+    for (let expect of param) {
         if (WASM.isValidValueType(expect)) {
             // FIXME implement stack checks for arguments. https://bugs.webkit.org/show_bug.cgi?id=163421
         } else {
@@ -195,7 +195,7 @@
     }
 };
 
-const _checkImms = (op, imms, expectedImms) => {
+const _checkImms = (op, imms, expectedImms, ret) => {
     assert.eq(imms.length, expectedImms.length, `"${op}" expects ${expectedImms.length} immediates, got ${imms.length}`);
     for (let idx = 0; idx !== expectedImms.length; ++idx) {
         const got = imms[idx];
@@ -257,7 +257,7 @@
             const continuation = args[args.length - 1];
             const hasContinuation = typeof(continuation) === "function";
             const imms = hasContinuation ? args.slice(0, -1) : args; // FIXME: allow passing in stack values, as-if code were a stack machine. Just check for a builder to this function, and drop. https://bugs.webkit.org/show_bug.cgi?id=163422
-            checkImms(op, imms, imm);
+            checkImms(op, imms, imm, ret);
             checkStackArgs(op, param);
             checkStackReturn(op, ret);
             const stackArgs = []; // FIXME https://bugs.webkit.org/show_bug.cgi?id=162706

Modified: trunk/JSTests/wasm/LowLevelBinary.js (208633 => 208634)


--- trunk/JSTests/wasm/LowLevelBinary.js	2016-11-12 01:18:22 UTC (rev 208633)
+++ trunk/JSTests/wasm/LowLevelBinary.js	2016-11-12 02:25:48 UTC (rev 208634)
@@ -80,7 +80,6 @@
     trim() { this._buf = this._buf.slice(0, this._used); }
 
     hexdump() { return _hexdump(this._buf, this._used); }
-    trim() { this._buf = this._buf.slice(0, this._used); }
     _maybeGrow(bytes) {
         const allocated = this._buf.length;
         if (allocated - this._used < bytes) {

Copied: trunk/JSTests/wasm/function-tests/add-12.js (from rev 208633, trunk/JSTests/wasm/js-api/function-tests/add-12.js) (0 => 208634)


--- trunk/JSTests/wasm/function-tests/add-12.js	                        (rev 0)
+++ trunk/JSTests/wasm/function-tests/add-12.js	2016-11-12 02:25:48 UTC (rev 208634)
@@ -0,0 +1,61 @@
+import Builder from '../Builder.js'
+
+const b = new Builder();
+b.setChecked(false);
+b.Type().End()
+    .Function().End()
+    .Code()
+    .Function({ params: ["i32", "i32", "i32", "i32", "i32", "i32", "i32", "i32", "i32", "i32", "i32", "i32"], ret: "i32" }, [])
+    .GetLocal(0)
+    .GetLocal(1)
+    .I32Add()
+    .GetLocal(2)
+    .I32Add()
+    .GetLocal(3)
+    .I32Add()
+    .GetLocal(4)
+    .I32Add()
+    .GetLocal(5)
+    .I32Add()
+    .GetLocal(6)
+    .I32Add()
+    .GetLocal(7)
+    .I32Add()
+    .GetLocal(8)
+    .I32Add()
+    .GetLocal(9)
+    .I32Add()
+    .GetLocal(10)
+    .I32Add()
+    .GetLocal(11)
+    .I32Add()
+    .Return()
+    .End()
+
+    .Function({ params: ["i32"], ret: "i32" })
+    .GetLocal(0)
+    .GetLocal(0)
+    .GetLocal(0)
+    .GetLocal(0)
+    .GetLocal(0)
+    .GetLocal(0)
+    .GetLocal(0)
+    .GetLocal(0)
+    .GetLocal(0)
+    .GetLocal(0)
+    .GetLocal(0)
+    .GetLocal(0)
+    .Call(0)
+    .End()
+
+const bin = b.WebAssembly()
+bin.trim();
+testWasmModuleFunctions(bin.get(), 2,
+                        [[{ type: "i32", value: 78 }, [{ type: "i32", value: 1 }, { type: "i32", value: 2 }, { type: "i32", value: 3 }, { type: "i32", value: 4 }, { type: "i32", value: 5 }, { type: "i32", value: 6 }, { type: "i32", value: 7 }, { type: "i32", value: 8 }, { type: "i32", value: 9 }, { type: "i32", value: 10 }, { type: "i32", value: 11 }, { type: "i32", value: 12 }]],
+                         [{ type: "i32", value: 166 }, [{ type: "i32", value: 1 }, { type: "i32", value: 2 }, { type: "i32", value: 3 }, { type: "i32", value: 4 }, { type: "i32", value: 5 }, { type: "i32", value: 6 }, { type: "i32", value: 7 }, { type: "i32", value: 8 }, { type: "i32", value: 9 }, { type: "i32", value: 10 }, { type: "i32", value: 11 }, { type: "i32", value: 100 }]]
+                        ],
+                        [[{ type: "i32", value: 12 }, [{ type: "i32", value: 1 }]],
+                         [{ type: "i32", value: 1200 }, [{ type: "i32", value: 100 }]],
+                         [{ type: "i32", value: 0 }, [{ type: "i32", value: 0 }]],
+                        ]
+                       );

Copied: trunk/JSTests/wasm/function-tests/br-if-loop-less-than.js (from rev 208633, trunk/JSTests/wasm/js-api/function-tests/br-if-loop-less-than.js) (0 => 208634)


--- trunk/JSTests/wasm/function-tests/br-if-loop-less-than.js	                        (rev 0)
+++ trunk/JSTests/wasm/function-tests/br-if-loop-less-than.js	2016-11-12 02:25:48 UTC (rev 208634)
@@ -0,0 +1,51 @@
+import Builder from '../Builder.js'
+
+const b = new Builder();
+b.setChecked(false);
+b.Type().End()
+    .Function().End()
+    .Code()
+    .Function({ params: ["i32", "i32"], ret: "i32" }, [])
+    .Loop("void")
+    .Block("void", b =>
+           b.Block("void", b =>
+                   b.GetLocal(0)
+                   .GetLocal(1)
+                   .I32Eq()
+                   .BrIf(0)
+                   .Br(1)
+                  )
+           .I32Const(0)
+           .Return()
+          )
+    .Block("void", b =>
+           b.Block("void", b =>
+                   b.GetLocal(0)
+                   .I32Const(0)
+                   .I32Eq()
+                   .BrIf(0)
+                   .Br(1)
+                  )
+           .I32Const(1)
+           .Return()
+          )
+    .GetLocal(0)
+    .I32Const(1)
+    .I32Sub()
+    .SetLocal(0)
+    .Br(0)
+    .End()
+    .Unreachable()
+    .End()
+
+const bin = b.WebAssembly()
+bin.trim();
+testWasmModuleFunctions(bin.get(), 1, [[{type: "i32", value: 1 }, [{ type: "i32", value: 0 }, { type: "i32", value: 1 }]],
+                                       [{type: "i32", value: 0 }, [{ type: "i32", value: 1 }, { type: "i32", value: 0 }]],
+                                       [{type: "i32", value: 0 }, [{ type: "i32", value: 2 }, { type: "i32", value: 1 }]],
+                                       [{type: "i32", value: 1 }, [{ type: "i32", value: 1 }, { type: "i32", value: 2 }]],
+                                       [{type: "i32", value: 0 }, [{ type: "i32", value: 2 }, { type: "i32", value: 2 }]],
+                                       [{type: "i32", value: 0 }, [{ type: "i32", value: 1 }, { type: "i32", value: 1 }]],
+                                       [{type: "i32", value: 1 }, [{ type: "i32", value: 2 }, { type: "i32", value: 6 }]],
+                                       [{type: "i32", value: 0 }, [{ type: "i32", value: 100 }, { type: "i32", value: 6 }]]
+                                      ]);
\ No newline at end of file

Copied: trunk/JSTests/wasm/function-tests/brTableAsIf.js (from rev 208633, trunk/JSTests/wasm/js-api/function-tests/brTableAsIf.js) (0 => 208634)


--- trunk/JSTests/wasm/function-tests/brTableAsIf.js	                        (rev 0)
+++ trunk/JSTests/wasm/function-tests/brTableAsIf.js	2016-11-12 02:25:48 UTC (rev 208634)
@@ -0,0 +1,26 @@
+import Builder from '../Builder.js'
+
+const b = new Builder();
+b.setChecked(false);
+b.Type().End()
+    .Function().End()
+    .Code()
+    .Function({ params: ["i32"], ret: "i32" }, ["i32"])
+    .Block("void", (b) =>
+           b.Block("void", (b) =>
+                   b.GetLocal(0)
+                   .BrTable(1, 0)
+                   .I32Const(21)
+                   .Return()
+                  ).I32Const(20)
+           .Return()
+          ).I32Const(22)
+    .End()
+
+const bin = b.WebAssembly()
+bin.trim();
+testWasmModuleFunctions(bin.get(), 1, [[{type: "i32", value: 22 }, [{ type: "i32", value: 0 }]],
+                                       [{type: "i32", value: 20 }, [{ type: "i32", value: 1 }]],
+                                       [{type: "i32", value: 20 }, [{ type: "i32", value: 11 }]],
+                                       [{type: "i32", value: 20 }, [{ type: "i32", value: -100 }]]
+                                      ]);
\ No newline at end of file

Copied: trunk/JSTests/wasm/function-tests/brTableManyValues.js (from rev 208633, trunk/JSTests/wasm/js-api/function-tests/brTableManyValues.js) (0 => 208634)


--- trunk/JSTests/wasm/function-tests/brTableManyValues.js	                        (rev 0)
+++ trunk/JSTests/wasm/function-tests/brTableManyValues.js	2016-11-12 02:25:48 UTC (rev 208634)
@@ -0,0 +1,43 @@
+import Builder from '../Builder.js'
+
+const b = new Builder();
+b.setChecked(false);
+b.Type().End()
+    .Function().End()
+    .Code()
+    .Function({ params: ["i32"], ret: "i32" }, ["i32"])
+    .Block("i32", (b) =>
+           b.Block("i32", (b) =>
+                   b.Block("i32", (b) =>
+                           b.Block("i32", (b) =>
+                                   b.Block("i32", (b) =>
+                                           b.I32Const(200)
+                                           .GetLocal(0)
+                                           .BrTable(3, 2, 1, 0, 4)
+                                          ).I32Const(10)
+                                   .I32Add()
+                                   .Return()
+                                  ).I32Const(11)
+                           .I32Add()
+                           .Return()
+                          ).I32Const(12)
+                   .I32Add()
+                   .Return()
+                  ).I32Const(13)
+           .I32Add()
+           .Return()
+          ).I32Const(14)
+    .I32Add()
+    .Return()
+    .End()
+const bin = b.WebAssembly()
+bin.trim();
+testWasmModuleFunctions(bin.get(), 1, [[{type: "i32", value: 213 }, [{ type: "i32", value: 0 }]],
+                                       [{type: "i32", value: 212 }, [{ type: "i32", value: 1 }]],
+                                       [{type: "i32", value: 211 }, [{ type: "i32", value: 2 }]],
+                                       [{type: "i32", value: 210 }, [{ type: "i32", value: 3 }]],
+                                       [{type: "i32", value: 214 }, [{ type: "i32", value: 4 }]],
+                                       [{type: "i32", value: 214 }, [{ type: "i32", value: 5 }]],
+                                       [{type: "i32", value: 214 }, [{ type: "i32", value: -1 }]],
+                                       [{type: "i32", value: 214 }, [{ type: "i32", value: -1000 }]]
+                                      ]);
\ No newline at end of file

Copied: trunk/JSTests/wasm/function-tests/brTableWithLoop.js (from rev 208633, trunk/JSTests/wasm/js-api/function-tests/brTableWithLoop.js) (0 => 208634)


--- trunk/JSTests/wasm/function-tests/brTableWithLoop.js	                        (rev 0)
+++ trunk/JSTests/wasm/function-tests/brTableWithLoop.js	2016-11-12 02:25:48 UTC (rev 208634)
@@ -0,0 +1,30 @@
+import Builder from '../Builder.js'
+
+const b = new Builder();
+b.setChecked(false);
+b.Type().End()
+    .Function().End()
+    .Code()
+    .Function({ params: ["i32"], ret: "i32" }, ["i32"])
+    .Loop("void")
+    .Block("void", (b) =>
+
+           b.GetLocal(0)
+           .GetLocal(1)
+           .I32Const(1)
+           .I32Add()
+           .SetLocal(1)
+           .GetLocal(0)
+           .I32Const(1)
+           .I32Sub()
+           .SetLocal(0)
+           .BrTable(0, 1))
+
+    .End()
+    .GetLocal(1)
+    .End()
+const bin = b.WebAssembly()
+bin.trim();
+testWasmModuleFunctions(bin.get(), 1, [[{type: "i32", value: 1 }, [{ type: "i32", value: 0 }]],
+                                       [{type: "i32", value: 2 }, [{ type: "i32", value: 1 }]]
+                                      ]);
\ No newline at end of file

Copied: trunk/JSTests/wasm/function-tests/dumb-eq-if-then-else.js (from rev 208633, trunk/JSTests/wasm/js-api/function-tests/dumb-eq-if-then-else.js) (0 => 208634)


--- trunk/JSTests/wasm/function-tests/dumb-eq-if-then-else.js	                        (rev 0)
+++ trunk/JSTests/wasm/function-tests/dumb-eq-if-then-else.js	2016-11-12 02:25:48 UTC (rev 208634)
@@ -0,0 +1,34 @@
+import Builder from '../Builder.js'
+
+const b = new Builder();
+b.setChecked(false);
+b.Type().End()
+    .Function().End()
+    .Memory().InitialMaxPages(1, 1).End()
+    .Code()
+    .Function({ params: ["i32", "i32"], ret: "i32" }, [])
+    .GetLocal(0)
+    .GetLocal(1)
+    .I32Eq()
+    .If("void", b =>
+        b.Br(0)
+        .Else()
+            .I32Const(1)
+        .Return()
+       )
+        .I32Const(0)
+    .Return()
+    .End()
+
+const bin = b.WebAssembly()
+bin.trim();
+testWasmModuleFunctions(bin.get(), 1, [[{type: "i32", value: 1 }, [{ type: "i32", value: 0 }, { type: "i32", value: 1 }]],
+                                       [{type: "i32", value: 1 }, [{ type: "i32", value: 1 }, { type: "i32", value: 0 }]],
+                                       [{type: "i32", value: 1 }, [{ type: "i32", value: 2 }, { type: "i32", value: 1 }]],
+                                       [{type: "i32", value: 1 }, [{ type: "i32", value: 1 }, { type: "i32", value: 2 }]],
+                                       [{type: "i32", value: 0 }, [{ type: "i32", value: 2 }, { type: "i32", value: 2 }]],
+                                       [{type: "i32", value: 0 }, [{ type: "i32", value: 1 }, { type: "i32", value: 1 }]],
+                                       [{type: "i32", value: 0 }, [{ type: "i32", value: 0 }, { type: "i32", value: 0 }]],
+                                       [{type: "i32", value: 1 }, [{ type: "i32", value: 2 }, { type: "i32", value: 6 }]],
+                                       [{type: "i32", value: 1 }, [{ type: "i32", value: 100 }, { type: "i32", value: 6 }]]
+                                      ]);
\ No newline at end of file

Copied: trunk/JSTests/wasm/function-tests/dumb-less-than-fallthrough.js (from rev 208633, trunk/JSTests/wasm/js-api/function-tests/dumb-less-than-fallthrough.js) (0 => 208634)


--- trunk/JSTests/wasm/function-tests/dumb-less-than-fallthrough.js	                        (rev 0)
+++ trunk/JSTests/wasm/function-tests/dumb-less-than-fallthrough.js	2016-11-12 02:25:48 UTC (rev 208634)
@@ -0,0 +1,39 @@
+import Builder from '../Builder.js'
+
+const b = new Builder();
+b.setChecked(false);
+b.Type().End()
+    .Function().End()
+    .Code()
+    .Function({ params: ["i32", "i32"], ret: "i32" }, [])
+    .Loop("i32", b =>
+          b.GetLocal(0)
+          .GetLocal(1)
+          .I32Eq()
+          .If("i32", b =>
+              b.I32Const(0)
+              .Return()
+              .Else()
+                  .GetLocal(0)
+              .GetLocal(0)
+              .I32Const(1)
+              .I32Sub()
+              .SetLocal(0)
+              .I32Const(0)
+              .I32Ne()
+              .BrIf(1)
+              .I32Const(1)
+          )
+    ).End()
+
+const bin = b.WebAssembly()
+bin.trim();
+testWasmModuleFunctions(bin.get(), 1, [[{type: "i32", value: 1 }, [{ type: "i32", value: 0 }, { type: "i32", value: 1 }]],
+                                       [{type: "i32", value: 0 }, [{ type: "i32", value: 1 }, { type: "i32", value: 0 }]],
+                                       [{type: "i32", value: 0 }, [{ type: "i32", value: 2 }, { type: "i32", value: 1 }]],
+                                       [{type: "i32", value: 1 }, [{ type: "i32", value: 1 }, { type: "i32", value: 2 }]],
+                                       [{type: "i32", value: 0 }, [{ type: "i32", value: 2 }, { type: "i32", value: 2 }]],
+                                       [{type: "i32", value: 0 }, [{ type: "i32", value: 1 }, { type: "i32", value: 1 }]],
+                                       [{type: "i32", value: 1 }, [{ type: "i32", value: 2 }, { type: "i32", value: 6 }]],
+                                       [{type: "i32", value: 0 }, [{ type: "i32", value: 100 }, { type: "i32", value: 6 }]]
+                                      ]);
\ No newline at end of file

Copied: trunk/JSTests/wasm/function-tests/dumb-less-than-ite.js (from rev 208633, trunk/JSTests/wasm/js-api/function-tests/dumb-less-than-ite.js) (0 => 208634)


--- trunk/JSTests/wasm/function-tests/dumb-less-than-ite.js	                        (rev 0)
+++ trunk/JSTests/wasm/function-tests/dumb-less-than-ite.js	2016-11-12 02:25:48 UTC (rev 208634)
@@ -0,0 +1,45 @@
+import Builder from '../Builder.js'
+
+const b = new Builder();
+b.setChecked(false);
+b.Type().End()
+    .Function().End()
+    .Code()
+    .Function({ params: ["i32", "i32"], ret: "i32" }, [])
+    .Loop("void")
+    .GetLocal(0)
+    .GetLocal(1)
+    .I32Eq()
+    .If("void", b =>
+        b.I32Const(0)
+        .Return()
+        .Else()
+            .GetLocal(0)
+        .I32Const(0)
+        .I32Eq()
+        .If("void", b =>
+            b.I32Const(1)
+            .Return()
+           )
+            )
+        .GetLocal(0)
+    .I32Const(1)
+    .I32Sub()
+    .SetLocal(0)
+    .Br(0)
+    .End()
+    .Unreachable()
+    .End()
+
+const bin = b.WebAssembly()
+bin.trim();
+testWasmModuleFunctions(bin.get(), 1, [[{type: "i32", value: 1 }, [{ type: "i32", value: 0 }, { type: "i32", value: 1 }]],
+                                       [{type: "i32", value: 0 }, [{ type: "i32", value: 1 }, { type: "i32", value: 0 }]],
+                                       [{type: "i32", value: 0 }, [{ type: "i32", value: 2 }, { type: "i32", value: 1 }]],
+                                       [{type: "i32", value: 1 }, [{ type: "i32", value: 1 }, { type: "i32", value: 2 }]],
+                                       [{type: "i32", value: 0 }, [{ type: "i32", value: 2 }, { type: "i32", value: 2 }]],
+                                       [{type: "i32", value: 0 }, [{ type: "i32", value: 1 }, { type: "i32", value: 1 }]],
+                                       [{type: "i32", value: 0 }, [{ type: "i32", value: 0 }, { type: "i32", value: 0 }]],
+                                       [{type: "i32", value: 1 }, [{ type: "i32", value: 2 }, { type: "i32", value: 6 }]],
+                                       [{type: "i32", value: 0 }, [{ type: "i32", value: 100 }, { type: "i32", value: 6 }]]
+                                      ]);
\ No newline at end of file

Copied: trunk/JSTests/wasm/function-tests/factorial.js (from rev 208633, trunk/JSTests/wasm/js-api/function-tests/factorial.js) (0 => 208634)


--- trunk/JSTests/wasm/function-tests/factorial.js	                        (rev 0)
+++ trunk/JSTests/wasm/function-tests/factorial.js	2016-11-12 02:25:48 UTC (rev 208634)
@@ -0,0 +1,31 @@
+import Builder from '../Builder.js'
+
+const b = new Builder();
+b.setChecked(false);
+b.Type().End()
+    .Function().End()
+    .Code()
+    .Function({ params: ["i32"], ret: "i32" }, [])
+    .GetLocal(0)
+    .I32Const(0)
+    .I32Eq()
+    .If("void", b =>
+        b.I32Const(1)
+        .Return()
+       )
+        .GetLocal(0)
+    .GetLocal(0)
+    .I32Const(1)
+    .I32Sub()
+    .Call(0)
+    .I32Mul()
+    .Return()
+    .End()
+
+const bin = b.WebAssembly()
+bin.trim();
+testWasmModuleFunctions(bin.get(), 1, [[{type: "i32", value: 1 }, [{ type: "i32", value: 0 }]],
+                                       [{type: "i32", value: 1 }, [{ type: "i32", value: 1 }]],
+                                       [{type: "i32", value: 2 }, [{ type: "i32", value: 2 }]],
+                                       [{type: "i32", value: 24 }, [{ type: "i32", value: 4 }]],
+                                      ]);
\ No newline at end of file

Copied: trunk/JSTests/wasm/function-tests/float-sub.js (from rev 208633, trunk/JSTests/wasm/js-api/function-tests/float-sub.js) (0 => 208634)


--- trunk/JSTests/wasm/function-tests/float-sub.js	                        (rev 0)
+++ trunk/JSTests/wasm/function-tests/float-sub.js	2016-11-12 02:25:48 UTC (rev 208634)
@@ -0,0 +1,31 @@
+import Builder from '../Builder.js'
+
+const b = new Builder();
+b.setChecked(false);
+b.Type().End()
+    .Function().End()
+    .Code()
+    .Function({ params: ["f32", "f32"], ret: "f32" }, [])
+    .GetLocal(0)
+    .GetLocal(1)
+    .F32Sub()
+    .Return()
+    .End()
+
+    .Function({ params: ["f32", "f32"], ret: "f32" }, [])
+    .GetLocal(0)
+    .GetLocal(1)
+    .Call(0)
+    .Return()
+    .End()
+
+const bin = b.WebAssembly()
+bin.trim();
+testWasmModuleFunctions(bin.get(), 2,
+                        [[{type: "f32", value: -1.5 }, [{ type: "f32", value: 0 }, { type: "f32", value: 1.5 }]],
+                         [{type: "f32", value: 87.6234 }, [{ type: "f32", value: 100.1234 }, { type: "f32", value: 12.5 }]]
+                        ],
+                        [[{type: "f32", value: -1.5 }, [{ type: "f32", value: 0 }, { type: "f32", value: 1.5 }]],
+                         [{type: "f32", value: 87.6234 }, [{ type: "f32", value: 100.1234 }, { type: "f32", value: 12.5 }]]
+                        ]
+                       );
\ No newline at end of file

Copied: trunk/JSTests/wasm/function-tests/i32-load.js (from rev 208633, trunk/JSTests/wasm/js-api/function-tests/i32-load.js) (0 => 208634)


--- trunk/JSTests/wasm/function-tests/i32-load.js	                        (rev 0)
+++ trunk/JSTests/wasm/function-tests/i32-load.js	2016-11-12 02:25:48 UTC (rev 208634)
@@ -0,0 +1,23 @@
+import Builder from '../Builder.js'
+
+const b = new Builder();
+b.setChecked(false);
+b.Type().End()
+    .Function().End()
+    .Memory().InitialMaxPages(1, 1).End()
+    .Code()
+    .Function({ params: ["i32", "i32"], ret: "i32" }, [])
+    .GetLocal(1)
+    .GetLocal(0)
+    .I32Store(2, 0)
+    .GetLocal(1)
+    .I32Load(2, 0)
+    .Return()
+    .End()
+
+const bin = b.WebAssembly()
+bin.trim();
+testWasmModuleFunctions(bin.get(), 1, [[{type: "i32", value: 0 }, [{ type: "i32", value: 0 }, { type: "i32", value: 10 }]],
+                                       [{type: "i32", value: 100 }, [{ type: "i32", value: 100 }, { type: "i32", value: 112 }]],
+                                       [{type: "i32", value: 1000000 }, [{ type: "i32", value: 1000000 }, { type: "i32", value: 10 }]]
+                                      ]);
\ No newline at end of file

Copied: trunk/JSTests/wasm/function-tests/i32-load8-s.js (from rev 208633, trunk/JSTests/wasm/js-api/function-tests/i32-load8-s.js) (0 => 208634)


--- trunk/JSTests/wasm/function-tests/i32-load8-s.js	                        (rev 0)
+++ trunk/JSTests/wasm/function-tests/i32-load8-s.js	2016-11-12 02:25:48 UTC (rev 208634)
@@ -0,0 +1,23 @@
+import Builder from '../Builder.js'
+
+const b = new Builder();
+b.setChecked(false);
+b.Type().End()
+    .Function().End()
+    .Memory().InitialMaxPages(1, 1).End()
+    .Code()
+    .Function({ params: ["i32", "i32"], ret: "i32" }, [])
+    .GetLocal(1)
+    .GetLocal(0)
+    .I32Store(2, 0)
+    .GetLocal(1)
+    .I32Load8S(2, 0)
+    .Return()
+    .End()
+
+const bin = b.WebAssembly()
+bin.trim();
+testWasmModuleFunctions(bin.get(), 1, [[{type: "i32", value: 0 }, [{ type: "i32", value: 0 }, { type: "i32", value: 10 }]],
+                                       [{type: "i32", value: 100 }, [{ type: "i32", value: 100 }, { type: "i32", value: 112 }]],
+                                       [{type: "i32", value: 0x40 }, [{ type: "i32", value: 1000000 }, { type: "i32", value: 10 }]]
+                                      ]);
\ No newline at end of file

Copied: trunk/JSTests/wasm/function-tests/if-then-else-fallthrough.js (from rev 208633, trunk/JSTests/wasm/js-api/function-tests/if-then-else-fallthrough.js) (0 => 208634)


--- trunk/JSTests/wasm/function-tests/if-then-else-fallthrough.js	                        (rev 0)
+++ trunk/JSTests/wasm/function-tests/if-then-else-fallthrough.js	2016-11-12 02:25:48 UTC (rev 208634)
@@ -0,0 +1,25 @@
+import Builder from '../Builder.js'
+
+const b = new Builder();
+b.setChecked(false);
+b.Type().End()
+    .Function().End()
+    .Code()
+    .Function({ params: ["i32"], ret: "i32" }, [])
+    .Block("i32", (b) =>
+           b.GetLocal(0)
+           .I32Const(0)
+           .I32Eq()
+           .If("i32")
+               .I32Const(1)
+           .Else()
+               .I32Const(2)
+           .Br(1)
+           .End()
+          ).End()
+
+const bin = b.WebAssembly()
+bin.trim();
+testWasmModuleFunctions(bin.get(), 1, [[{type: "i32", value: 1 }, [{ type: "i32", value: 0 }]],
+                                       [{type: "i32", value: 2 }, [{ type: "i32", value: 1 }]]
+                                      ]);
\ No newline at end of file

Copied: trunk/JSTests/wasm/function-tests/if-then-fallthrough.js (from rev 208633, trunk/JSTests/wasm/js-api/function-tests/if-then-fallthrough.js) (0 => 208634)


--- trunk/JSTests/wasm/function-tests/if-then-fallthrough.js	                        (rev 0)
+++ trunk/JSTests/wasm/function-tests/if-then-fallthrough.js	2016-11-12 02:25:48 UTC (rev 208634)
@@ -0,0 +1,25 @@
+import Builder from '../Builder.js'
+
+const b = new Builder();
+b.setChecked(false);
+b.Type().End()
+    .Function().End()
+    .Code()
+    .Function({ params: ["i32"], ret: "i32" }, [])
+    .Block("i32", (b) =>
+           b.GetLocal(0)
+           .I32Const(0)
+           .I32Eq()
+           .If("i32")
+               .I32Const(1)
+           .Else()
+               .I32Const(2)
+           .Br(1)
+           .End()
+          ).End()
+
+const bin = b.WebAssembly()
+bin.trim();
+testWasmModuleFunctions(bin.get(), 1, [[{type: "i32", value: 1 }, [{ type: "i32", value: 0 }]],
+                                       [{type: "i32", value: 2 }, [{ type: "i32", value: 1 }]]
+                                      ]);
\ No newline at end of file

Copied: trunk/JSTests/wasm/function-tests/loop-mult.js (from rev 208633, trunk/JSTests/wasm/js-api/function-tests/loop-mult.js) (0 => 208634)


--- trunk/JSTests/wasm/function-tests/loop-mult.js	                        (rev 0)
+++ trunk/JSTests/wasm/function-tests/loop-mult.js	2016-11-12 02:25:48 UTC (rev 208634)
@@ -0,0 +1,38 @@
+import Builder from '../Builder.js'
+
+const b = new Builder();
+b.setChecked(false);
+b.Type().End()
+    .Function().End()
+    .Code()
+    .Function({ params: ["i32"], ret: "i32" }, ["i32"])
+    .I32Const(0)
+    .SetLocal(1)
+    .Loop("void")
+    .Block("void", b =>
+           b.GetLocal(0)
+           .I32Const(0)
+           .I32Eq()
+           .BrIf(0)
+           .GetLocal(0)
+           .GetLocal(1)
+           .I32Add()
+           .SetLocal(1)
+           .GetLocal(0)
+           .I32Const(1)
+           .I32Sub()
+           .SetLocal(0)
+           .Br(1)
+          )
+    .End()
+    .GetLocal(1)
+    .Return()
+    .End()
+
+const bin = b.WebAssembly()
+bin.trim();
+testWasmModuleFunctions(bin.get(), 1, [[{type: "i32", value: 0 }, [{ type: "i32", value: 0 }]],
+                                       [{type: "i32", value: 1 }, [{ type: "i32", value: 1 }]],
+                                       [{type: "i32", value: 3 }, [{ type: "i32", value: 2 }]],
+                                       [{type: "i32", value: 5050 }, [{ type: "i32", value: 100 }]]
+                                      ]);
\ No newline at end of file

Copied: trunk/JSTests/wasm/function-tests/loop-sum.js (from rev 208633, trunk/JSTests/wasm/js-api/function-tests/loop-sum.js) (0 => 208634)


--- trunk/JSTests/wasm/function-tests/loop-sum.js	                        (rev 0)
+++ trunk/JSTests/wasm/function-tests/loop-sum.js	2016-11-12 02:25:48 UTC (rev 208634)
@@ -0,0 +1,38 @@
+import Builder from '../Builder.js'
+
+const b = new Builder();
+b.setChecked(false);
+b.Type().End()
+    .Function().End()
+    .Code()
+    .Function({ params: ["i32"], ret: "i32" }, ["i32"])
+    .I32Const(0)
+    .SetLocal(1)
+    .Loop("void")
+    .Block("void", b =>
+           b.GetLocal(0)
+           .I32Const(0)
+           .I32Eq()
+           .BrIf(0)
+           .GetLocal(0)
+           .GetLocal(1)
+           .I32Add()
+           .SetLocal(1)
+           .GetLocal(0)
+           .I32Const(1)
+           .I32Sub()
+           .SetLocal(0)
+           .Br(1)
+          )
+    .End()
+    .GetLocal(1)
+    .Return()
+    .End()
+
+const bin = b.WebAssembly()
+bin.trim();
+testWasmModuleFunctions(bin.get(), 1, [[{type: "i32", value: 0 }, [{ type: "i32", value: 0 }]],
+                                       [{type: "i32", value: 1 }, [{ type: "i32", value: 1 }]],
+                                       [{type: "i32", value: 3 }, [{ type: "i32", value: 2 }]],
+                                       [{type: "i32", value: 5050 }, [{ type: "i32", value: 100 }]]
+                                      ]);
\ No newline at end of file

Copied: trunk/JSTests/wasm/function-tests/ret5.js (from rev 208633, trunk/JSTests/wasm/js-api/function-tests/ret5.js) (0 => 208634)


--- trunk/JSTests/wasm/function-tests/ret5.js	                        (rev 0)
+++ trunk/JSTests/wasm/function-tests/ret5.js	2016-11-12 02:25:48 UTC (rev 208634)
@@ -0,0 +1,16 @@
+import Builder from '../Builder.js'
+
+const b = new Builder();
+b.setChecked(false);
+let code = b.Type().End()
+    .Function().End()
+    .Code();
+
+code.Function({ params: [], ret: "i32" })
+    .I32Const(5)
+    .Return()
+    .End()
+    .End();
+const bin = b.WebAssembly();
+bin.trim();
+testWasmModuleFunctions(bin.get(), 1, [[{type: "i32", value: 5 }, []]]);
\ No newline at end of file

Modified: trunk/JSTests/wasm/self-test/test_BuilderJSON.js (208633 => 208634)


--- trunk/JSTests/wasm/self-test/test_BuilderJSON.js	2016-11-12 01:18:22 UTC (rev 208633)
+++ trunk/JSTests/wasm/self-test/test_BuilderJSON.js	2016-11-12 02:25:48 UTC (rev 208634)
@@ -140,12 +140,12 @@
 
 (function ImportFunctionWithoutTypeSection() {
     const i = (new Builder()).Import();
-    assert.throws(() => i.Function("foo", "bar", 0), Error, `Shouldn't be undefined: Can't use type 0 if a type section isn't present`);
+    assert.throws(() => i.Function("foo", "bar", 0), Error, `Shouldn't be undefined: Can not use type 0 if a type section is not present`);
 })();
 
 (function ImportFunctionWithInvalidType() {
     const i = (new Builder()).Type().End().Import();
-    assert.throws(() => i.Function("foo", "bar", 0), Error, `Shouldn't be undefined: Type 0 doesn't exist in type section`);
+    assert.throws(() => i.Function("foo", "bar", 0), Error, `Shouldn't be undefined: Type 0 does not exist in type section`);
 })();
 
 (function ImportFunction() {
@@ -211,12 +211,12 @@
 
 (function ExportFunctionWithoutTypeSection() {
     const e = (new Builder()).Export();
-    assert.throws(() => e.Function("foo", 0, 0), Error, `Shouldn't be undefined: Can't use type 0 if a type section isn't present`);
+    assert.throws(() => e.Function("foo", 0, 0), Error, `Shouldn't be undefined: Can not use type 0 if a type section is not present`);
 })();
 
 (function ExportFunctionWithInvalidType() {
     const e = (new Builder()).Type().End().Export();
-    assert.throws(() => e.Function("foo", 0, 0), Error, `Shouldn't be undefined: Type 0 doesn't exist in type section`);
+    assert.throws(() => e.Function("foo", 0, 0), Error, `Shouldn't be undefined: Type 0 does not exist in type section`);
 })();
 
 (function ExportAnImport() {

Modified: trunk/JSTests/wasm.yaml (208633 => 208634)


--- trunk/JSTests/wasm.yaml	2016-11-12 01:18:22 UTC (rev 208633)
+++ trunk/JSTests/wasm.yaml	2016-11-12 02:25:48 UTC (rev 208634)
@@ -25,3 +25,5 @@
   cmd: runWebAssembly
 - path: wasm/js-api/
   cmd: runWebAssembly
+- path: wasm/function-tests
+  cmd: runWebAssembly
\ No newline at end of file
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to