Title: [212983] trunk
Revision
212983
Author
jfbast...@apple.com
Date
2017-02-24 18:02:06 -0800 (Fri, 24 Feb 2017)

Log Message

WebAssembly: miscellaneous spec fixes
https://bugs.webkit.org/show_bug.cgi?id=168822

Reviewed by Saam Barati.

JSTests:

* wasm.yaml: mark some skip tests as normal, now that they pass
* wasm/Builder.js: error message was wrong, causing extra error if hit
* wasm/js-api/global-error.js: new tests
(assert.throws):
* wasm/spec-tests/call.wast.js: comment out stack check tests
* wasm/spec-tests/call_indirect.wast.js: comment out stack check tests
* wasm/spec-tests/fac.wast.js: comment out stack check tests
* wasm/spec-tests/float_exprs.wast.js: wabt is wrong, bug reported, we should update
* wasm/spec-tests/imports.wast.js: bug in old wabt, fixed in recent wabt
(assert_unlinkable):

Source/_javascript_Core:

* wasm/WasmModuleParser.cpp: "unknown" sections are now called "custom" sections
* wasm/WasmSections.h:
(JSC::Wasm::validateOrder):
(JSC::Wasm::makeString): fix ASSERT_UNREACHABLE bug in printing
* wasm/js/WebAssemblyInstanceConstructor.cpp:
(JSC::constructJSWebAssemblyInstance): disallow i64 import
* wasm/js/WebAssemblyModuleRecord.cpp:
(JSC::WebAssemblyModuleRecord::link): disallow i64 export
(JSC::WebAssemblyModuleRecord::evaluate):

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (212982 => 212983)


--- trunk/JSTests/ChangeLog	2017-02-25 01:17:15 UTC (rev 212982)
+++ trunk/JSTests/ChangeLog	2017-02-25 02:02:06 UTC (rev 212983)
@@ -1,3 +1,21 @@
+2017-02-24  JF Bastien  <jfbast...@apple.com>
+
+        WebAssembly: miscellaneous spec fixes
+        https://bugs.webkit.org/show_bug.cgi?id=168822
+
+        Reviewed by Saam Barati.
+
+        * wasm.yaml: mark some skip tests as normal, now that they pass
+        * wasm/Builder.js: error message was wrong, causing extra error if hit
+        * wasm/js-api/global-error.js: new tests
+        (assert.throws):
+        * wasm/spec-tests/call.wast.js: comment out stack check tests
+        * wasm/spec-tests/call_indirect.wast.js: comment out stack check tests
+        * wasm/spec-tests/fac.wast.js: comment out stack check tests
+        * wasm/spec-tests/float_exprs.wast.js: wabt is wrong, bug reported, we should update
+        * wasm/spec-tests/imports.wast.js: bug in old wabt, fixed in recent wabt
+        (assert_unlinkable):
+
 2017-02-23  Saam Barati  <sbar...@apple.com>
 
         Intrinsicify parseInt

Modified: trunk/JSTests/wasm/Builder.js (212982 => 212983)


--- trunk/JSTests/wasm/Builder.js	2017-02-25 01:17:15 UTC (rev 212982)
+++ trunk/JSTests/wasm/Builder.js	2017-02-25 02:02:06 UTC (rev 212983)
@@ -192,7 +192,7 @@
     else if (mutability === "immutable")
         return 0;
     else
-        throw new Error(`mutability should be either "mutable" or "immutable", but got ${global.mutablity}`);
+        throw new Error(`mutability should be either "mutable" or "immutable", but got ${mutability}`);
 };
 
 const _exportGlobalContinuation = (builder, section, nextBuilder) => {

Modified: trunk/JSTests/wasm/js-api/global-error.js (212982 => 212983)


--- trunk/JSTests/wasm/js-api/global-error.js	2017-02-25 01:17:15 UTC (rev 212982)
+++ trunk/JSTests/wasm/js-api/global-error.js	2017-02-25 02:02:06 UTC (rev 212983)
@@ -187,3 +187,26 @@
     const module = new WebAssembly.Module(bin.get());
     assert.throws(() => new WebAssembly.Instance(module, { imp: { global: imp } }), WebAssembly.LinkError, "imported global must be a number (evaluating 'new WebAssembly.Instance(module, { imp: { global: imp } })')");
 }
+
+{
+    const builder = new Builder()
+        .Type().End()
+        .Global().I64(0, "immutable").End()
+        .Export()
+            .Global("bigInt", 0)
+        .End();
+    const module = new WebAssembly.Module(builder.WebAssembly().get());
+    assert.throws(() => new WebAssembly.Instance(module), WebAssembly.LinkError, "exported global cannot be an i64 (evaluating 'new WebAssembly.Instance(module)')");
+}
+
+{
+    const builder = new Builder()
+        .Type().End()
+        .Import()
+            .Global().I64("imp", "global", "immutable").End()
+        .End()
+        .Function().End()
+        .Global().GetGlobal("i64", 0, "immutable").End();
+    const module = new WebAssembly.Module(builder.WebAssembly().get());
+    assert.throws(() => new WebAssembly.Instance(module, { imp: { global: undefined } }), WebAssembly.LinkError, "imported global cannot be an i64 (evaluating 'new WebAssembly.Instance(module, { imp: { global: undefined } })')");
+}

Modified: trunk/JSTests/wasm/spec-tests/call.wast.js (212982 => 212983)


--- trunk/JSTests/wasm/spec-tests/call.wast.js	2017-02-25 01:17:15 UTC (rev 212982)
+++ trunk/JSTests/wasm/spec-tests/call.wast.js	2017-02-25 02:02:06 UTC (rev 212983)
@@ -126,8 +126,9 @@
 assert_return(() => $$.exports["assert_21"]());
 assert_return(() => $$.exports["assert_22"]());
 assert_return(() => $$.exports["assert_23"]());
-assert_trap(() => $$.exports["runaway"]());
-assert_trap(() => $$.exports["mutual-runaway"]());
+// FIXME do stack checks https://bugs.webkit.org/show_bug.cgi?id=165546
+//assert_trap(() => $$.exports["runaway"]());
+//assert_trap(() => $$.exports["mutual-runaway"]());
 assert_invalid("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x04\x01\x60\x00\x00\x03\x03\x02\x00\x00\x0a\x0a\x02\x05\x00\x10\x01\x45\x0b\x02\x00\x0b");
 assert_invalid("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x08\x02\x60\x00\x00\x60\x00\x01\x7e\x03\x03\x02\x00\x01\x0a\x0c\x02\x05\x00\x10\x01\x45\x0b\x04\x00\x42\x01\x0b");
 assert_invalid("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x08\x02\x60\x00\x00\x60\x01\x7f\x00\x03\x03\x02\x00\x01\x0a\x09\x02\x04\x00\x10\x01\x0b\x02\x00\x0b");

Modified: trunk/JSTests/wasm/spec-tests/call_indirect.wast.js (212982 => 212983)


--- trunk/JSTests/wasm/spec-tests/call_indirect.wast.js	2017-02-25 01:17:15 UTC (rev 212982)
+++ trunk/JSTests/wasm/spec-tests/call_indirect.wast.js	2017-02-25 02:02:06 UTC (rev 212983)
@@ -139,8 +139,9 @@
 assert_return(() => $$.exports["odd"](1), 44);
 assert_return(() => $$.exports["odd"](200), 99);
 assert_return(() => $$.exports["odd"](77), 44);
-assert_trap(() => $$.exports["runaway"]());
-assert_trap(() => $$.exports["mutual-runaway"]());
+// FIXME do stack checks https://bugs.webkit.org/show_bug.cgi?id=165546
+//assert_trap(() => $$.exports["runaway"]());
+//assert_trap(() => $$.exports["mutual-runaway"]());
 assert_invalid("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x04\x01\x60\x00\x00\x03\x02\x01\x00\x0a\x09\x01\x07\x00\x41\x00\x11\x00\x00\x0b");
 assert_invalid("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x04\x01\x60\x00\x00\x03\x02\x01\x00\x04\x04\x01\x70\x00\x00\x0a\x0a\x01\x08\x00\x41\x00\x11\x00\x00\x45\x0b");
 assert_invalid("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x08\x02\x60\x00\x01\x7e\x60\x00\x00\x03\x02\x01\x01\x04\x04\x01\x70\x00\x00\x0a\x0a\x01\x08\x00\x41\x00\x11\x00\x00\x45\x0b");

Modified: trunk/JSTests/wasm/spec-tests/fac.wast.js (212982 => 212983)


--- trunk/JSTests/wasm/spec-tests/fac.wast.js	2017-02-25 01:17:15 UTC (rev 212982)
+++ trunk/JSTests/wasm/spec-tests/fac.wast.js	2017-02-25 02:02:06 UTC (rev 212983)
@@ -98,4 +98,5 @@
 assert_return(() => $$.exports["assert_2"]());
 assert_return(() => $$.exports["assert_3"]());
 assert_return(() => $$.exports["assert_4"]());
-assert_trap(() => $$.exports["assert_5"]());
+// FIXME do stack checks https://bugs.webkit.org/show_bug.cgi?id=165546
+//assert_trap(() => $$.exports["assert_5"]());

Modified: trunk/JSTests/wasm/spec-tests/float_exprs.wast.js (212982 => 212983)


--- trunk/JSTests/wasm/spec-tests/float_exprs.wast.js	2017-02-25 01:17:15 UTC (rev 212982)
+++ trunk/JSTests/wasm/spec-tests/float_exprs.wast.js	2017-02-25 02:02:06 UTC (rev 212983)
@@ -132,8 +132,11 @@
 assert_return(() => $$.exports["f64.no_fold_mul_zero"](-2.0), -0.0);
 assert_return(() => $$.exports["assert_1"]());
 $$ = instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x0e\x03\x60\x01\x7d\x01\x7d\x60\x01\x7c\x01\x7c\x60\x00\x00\x03\x05\x04\x00\x01\x02\x02\x07\x43\x04\x13\x66\x33\x32\x2e\x6e\x6f\x5f\x66\x6f\x6c\x64\x5f\x6d\x75\x6c\x5f\x6f\x6e\x65\x00\x00\x13\x66\x36\x34\x2e\x6e\x6f\x5f\x66\x6f\x6c\x64\x5f\x6d\x75\x6c\x5f\x6f\x6e\x65\x00\x01\x08\x61\x73\x73\x65\x72\x74\x5f\x30\x00\x02\x08\x61\x73\x73\x65\x72\x74\x5f\x31\x00\x03\x0a\x57\x04\x0a\x00\x20\x00\x43\x00\x00\x80\x3f\x94\x0b\x0e\x00\x20\x00\x44\x00\x00\x00\x00\x00\x00\xf0\x3f\xa2\x0b\x19\x00\x02\x40\x43\x00\x00\xa0\x7f\x10\x00\xbc\x43\x00\x00\xe0\x7f\xbc\x46\x45\x0d\x00\x0f\x0b\x00\x0b\x21\x00\x02\x40\x44\x00\x00\x00\x00\x00\x00\xf4\x7f\x10\x01\xbd\x44\x00\x00\x00\x00\x00\x00\xfc\x7f\xbd\x51\x45\x0d\x00\x0f\x0b\x00\x0b");
-assert_return(() => $$.exports["assert_0"]());
-assert_return(() => $$.exports["assert_1"]());
+// FIXME The following spec tests seem to mistranslate with wabt:
+//   (assert_return (invoke "f32.no_fold_mul_one" (f32.const nan:0x200000)) (f32.const nan:0x600000))
+//   (assert_return (invoke "f64.no_fold_mul_one" (f64.const nan:0x4000000000000)) (f64.const nan:0xc000000000000))
+//assert_return(() => $$.exports["assert_0"]());
+//assert_return(() => $$.exports["assert_1"]());
 $$ = instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x0e\x03\x60\x01\x7d\x01\x7d\x60\x01\x7c\x01\x7c\x60\x00\x00\x03\x07\x06\x00\x01\x02\x02\x02\x02\x07\x5b\x06\x14\x66\x33\x32\x2e\x6e\x6f\x5f\x66\x6f\x6c\x64\x5f\x7a\x65\x72\x6f\x5f\x64\x69\x76\x00\x00\x14\x66\x36\x34\x2e\x6e\x6f\x5f\x66\x6f\x6c\x64\x5f\x7a\x65\x72\x6f\x5f\x64\x69\x76\x00\x01\x08\x61\x73\x73\x65\x72\x74\x5f\x30\x00\x02\x08\x61\x73\x73\x65\x72\x74\x5f\x31\x00\x03\x08\x61\x73\x73\x65\x72\x74\x5f\x32\x00\x04\x08\x61\x73\x73\x65\x72\x74\x5f\x33\x00\x05\x0a\x93\x01\x06\x0a\x00\x43\x00\x00\x00\x00\x20\x00\x95\x0b\x0e\x00\x44\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\xa3\x0b\x19\x00\x02\x40\x43\x00\x00\xc0\x7f\x10\x00\xbc\x43\x00\x00\xc0\x7f\xbc\x46\x45\x0d\x00\x0f\x0b\x00\x0b\x19\x00\x02\x40\x43\x00\x00\xa0\x7f\x10\x00\xbc\x43\x00\x00\xe0\x7f\xbc\x46\x45\x0d\x00\x0f\x0b\x00\x0b\x21\x00\x02\x40\x44\x00\x00\x00\x00\x00\x00\xf8\x7f\x10\x01\xbd\x44\x00\x00\x00\x00\x00\x00\xf8\x7f\xbd\x51\x45\x
 0d\x00\x0f\x0b\x00\x0b\x21\x00\x02\x40\x44\x00\x00\x00\x00\x00\x00\xf4\x7f\x10\x01\xbd\x44\x00\x00\x00\x00\x00\x00\xfc\x7f\xbd\x51\x45\x0d\x00\x0f\x0b\x00\x0b");
 assert_return_nan(() => $$.exports["f32.no_fold_zero_div"](f32(0.0)));
 assert_return_nan(() => $$.exports["f32.no_fold_zero_div"](f32(-0.0)));
@@ -375,7 +378,9 @@
 assert_return(() => $$.exports["no_fold_demote_promote"](-4.7074160416121775e-27), -4.7074161331556024e-27);
 assert_return(() => $$.exports["no_fold_demote_promote"](2.335945149795088e+31), 2.3359452224542198e+31);
 $$ = instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x09\x02\x60\x01\x7d\x01\x7d\x60\x00\x00\x03\x03\x02\x00\x01\x07\x25\x02\x16\x6e\x6f\x5f\x66\x6f\x6c\x64\x5f\x70\x72\x6f\x6d\x6f\x74\x65\x5f\x64\x65\x6d\x6f\x74\x65\x00\x00\x08\x61\x73\x73\x65\x72\x74\x5f\x30\x00\x01\x0a\x22\x02\x06\x00\x20\x00\xbb\xb6\x0b\x19\x00\x02\x40\x43\x00\x00\xa0\x7f\x10\x00\xbc\x43\x00\x00\xe0\x7f\xbc\x46\x45\x0d\x00\x0f\x0b\x00\x0b");
-assert_return(() => $$.exports["assert_0"]());
+// FIXME The following spec tests seem to mistranslate with wabt:
+//   (assert_return (invoke "no_fold_promote_demote" (f32.const nan:0x200000)) (f32.const nan:0x600000))
+//assert_return(() => $$.exports["assert_0"]());
 assert_return(() => $$.exports["no_fold_promote_demote"](f32(0.0)), f32(0.0));
 assert_return(() => $$.exports["no_fold_promote_demote"](f32(-0.0)), f32(-0.0));
 assert_return(() => $$.exports["no_fold_promote_demote"](f32(1.40129846432e-45)), f32(1.40129846432e-45));

Modified: trunk/JSTests/wasm/spec-tests/imports.wast.js (212982 => 212983)


--- trunk/JSTests/wasm/spec-tests/imports.wast.js	2017-02-25 01:17:15 UTC (rev 212982)
+++ trunk/JSTests/wasm/spec-tests/imports.wast.js	2017-02-25 02:02:06 UTC (rev 212983)
@@ -56,7 +56,7 @@
 function assert_unlinkable(bytes) {
   let mod = module(bytes);
   try { new WebAssembly.Instance(mod, registry) } catch (e) {
-    if (e instanceof TypeError) return;
+      if (e instanceof WebAssembly.LinkError) return; // Note: this is fixed in tip-of-tree wabt.
   }
   throw new Error("Wasm linking failure expected");
 }
@@ -94,9 +94,10 @@
 
 $$ = instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x1e\x07\x60\x00\x00\x60\x01\x7f\x00\x60\x01\x7d\x00\x60\x00\x01\x7f\x60\x00\x01\x7d\x60\x01\x7f\x01\x7f\x60\x01\x7e\x01\x7e\x03\x08\x07\x00\x01\x02\x03\x04\x05\x06\x04\x04\x01\x70\x00\x0a\x05\x03\x01\x00\x02\x06\x0e\x02\x7f\x00\x41\x37\x0b\x7d\x00\x43\x00\x00\x30\x42\x0b\x07\x8e\x01\x0b\x04\x66\x75\x6e\x63\x00\x00\x08\x66\x75\x6e\x63\x2d\x69\x33\x32\x00\x01\x08\x66\x75\x6e\x63\x2d\x66\x33\x32\x00\x02\x09\x66\x75\x6e\x63\x2d\x3e\x69\x33\x32\x00\x03\x09\x66\x75\x6e\x63\x2d\x3e\x66\x33\x32\x00\x04\x0d\x66\x75\x6e\x63\x2d\x69\x33\x32\x2d\x3e\x69\x33\x32\x00\x05\x0d\x66\x75\x6e\x63\x2d\x69\x36\x34\x2d\x3e\x69\x36\x34\x00\x06\x0a\x67\x6c\x6f\x62\x61\x6c\x2d\x69\x33\x32\x03\x00\x0a\x67\x6c\x6f\x62\x61\x6c\x2d\x66\x33\x32\x03\x01\x0c\x74\x61\x62\x6c\x65\x2d\x31\x30\x2d\x69\x6e\x66\x01\x00\x0c\x6d\x65\x6d\x6f\x72\x79\x2d\x32\x2d\x69\x6e\x66\x02\x00\x0a\x21\x07\x02\x00\x0b\x02\x00\x0b\x02\x00\x0b\x04\x00\
 x41\x16\x0b\x07\x00\x43\x00\x00\x30\x41\x0b\x04\x00\x20\x00\x0b\x04\x00\x20\x00\x0b");
 register("test", $$)
-$$ = instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x23\x08\x60\x01\x7f\x00\x60\x01\x7e\x00\x60\x01\x7d\x00\x60\x01\x7c\x00\x60\x02\x7f\x7d\x00\x60\x02\x7c\x7c\x00\x60\x01\x7e\x01\x7e\x60\x00\x00\x02\xc0\x01\x0b\x08\x73\x70\x65\x63\x74\x65\x73\x74\x05\x70\x72\x69\x6e\x74\x00\x00\x08\x73\x70\x65\x63\x74\x65\x73\x74\x05\x70\x72\x69\x6e\x74\x00\x01\x08\x73\x70\x65\x63\x74\x65\x73\x74\x05\x70\x72\x69\x6e\x74\x00\x00\x08\x73\x70\x65\x63\x74\x65\x73\x74\x05\x70\x72\x69\x6e\x74\x00\x01\x08\x73\x70\x65\x63\x74\x65\x73\x74\x05\x70\x72\x69\x6e\x74\x00\x02\x08\x73\x70\x65\x63\x74\x65\x73\x74\x05\x70\x72\x69\x6e\x74\x00\x03\x08\x73\x70\x65\x63\x74\x65\x73\x74\x05\x70\x72\x69\x6e\x74\x00\x04\x08\x73\x70\x65\x63\x74\x65\x73\x74\x05\x70\x72\x69\x6e\x74\x00\x05\x08\x73\x70\x65\x63\x74\x65\x73\x74\x05\x70\x72\x69\x6e\x74\x00\x00\x08\x73\x70\x65\x63\x74\x65\x73\x74\x05\x70\x72\x69\x6e\x74\x00\x03\x04\x74\x65\x73\x74\x0d\x66\x75\x6e\x63\x2d\x69\x36\x34\x2d\x3e\x69\x36\x34\x00\
 x06\x03\x04\x03\x00\x01\x07\x04\x05\x01\x70\x01\x02\x02\x07\x20\x03\x07\x70\x72\x69\x6e\x74\x33\x32\x00\x0b\x07\x70\x72\x69\x6e\x74\x36\x34\x00\x0c\x08\x61\x73\x73\x65\x72\x74\x5f\x30\x00\x0d\x09\x08\x01\x00\x41\x00\x0b\x02\x02\x05\x0a\x70\x03\x2c\x01\x01\x7d\x20\x00\xb2\x21\x01\x20\x00\x10\x00\x20\x00\x41\x01\x6a\x43\x00\x00\x28\x42\x10\x06\x20\x00\x10\x02\x20\x00\x10\x08\x20\x01\x10\x04\x20\x00\x41\x00\x11\x00\x00\x0b\x35\x01\x01\x7c\x20\x00\x10\x0a\xb9\x21\x01\x20\x00\x10\x01\x20\x01\x44\x00\x00\x00\x00\x00\x00\xf0\x3f\xa0\x44\x00\x00\x00\x00\x00\x80\x4a\x40\x10\x07\x20\x01\x10\x05\x20\x01\x10\x09\x20\x01\x41\x01\x11\x03\x00\x0b\x0b\x00\x02\x40\x42\x18\x10\x0c\x0f\x0b\x00\x0b");
-assert_return(() => $$.exports["print32"](13));
-assert_return(() => $$.exports["assert_0"]());
+// FIXME re-exporting an import isn't implemented. https://bugs.webkit.org/show_bug.cgi?id=165510
+//$$ = instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x23\x08\x60\x01\x7f\x00\x60\x01\x7e\x00\x60\x01\x7d\x00\x60\x01\x7c\x00\x60\x02\x7f\x7d\x00\x60\x02\x7c\x7c\x00\x60\x01\x7e\x01\x7e\x60\x00\x00\x02\xc0\x01\x0b\x08\x73\x70\x65\x63\x74\x65\x73\x74\x05\x70\x72\x69\x6e\x74\x00\x00\x08\x73\x70\x65\x63\x74\x65\x73\x74\x05\x70\x72\x69\x6e\x74\x00\x01\x08\x73\x70\x65\x63\x74\x65\x73\x74\x05\x70\x72\x69\x6e\x74\x00\x00\x08\x73\x70\x65\x63\x74\x65\x73\x74\x05\x70\x72\x69\x6e\x74\x00\x01\x08\x73\x70\x65\x63\x74\x65\x73\x74\x05\x70\x72\x69\x6e\x74\x00\x02\x08\x73\x70\x65\x63\x74\x65\x73\x74\x05\x70\x72\x69\x6e\x74\x00\x03\x08\x73\x70\x65\x63\x74\x65\x73\x74\x05\x70\x72\x69\x6e\x74\x00\x04\x08\x73\x70\x65\x63\x74\x65\x73\x74\x05\x70\x72\x69\x6e\x74\x00\x05\x08\x73\x70\x65\x63\x74\x65\x73\x74\x05\x70\x72\x69\x6e\x74\x00\x00\x08\x73\x70\x65\x63\x74\x65\x73\x74\x05\x70\x72\x69\x6e\x74\x00\x03\x04\x74\x65\x73\x74\x0d\x66\x75\x6e\x63\x2d\x69\x36\x34\x2d\x3e\x69\x36\x34\x00\x06\x03\x0
 4\x03\x00\x01\x07\x04\x05\x01\x70\x01\x02\x02\x07\x20\x03\x07\x70\x72\x69\x6e\x74\x33\x32\x00\x0b\x07\x70\x72\x69\x6e\x74\x36\x34\x00\x0c\x08\x61\x73\x73\x65\x72\x74\x5f\x30\x00\x0d\x09\x08\x01\x00\x41\x00\x0b\x02\x02\x05\x0a\x70\x03\x2c\x01\x01\x7d\x20\x00\xb2\x21\x01\x20\x00\x10\x00\x20\x00\x41\x01\x6a\x43\x00\x00\x28\x42\x10\x06\x20\x00\x10\x02\x20\x00\x10\x08\x20\x01\x10\x04\x20\x00\x41\x00\x11\x00\x00\x0b\x35\x01\x01\x7c\x20\x00\x10\x0a\xb9\x21\x01\x20\x00\x10\x01\x20\x01\x44\x00\x00\x00\x00\x00\x00\xf0\x3f\xa0\x44\x00\x00\x00\x00\x00\x80\x4a\x40\x10\x07\x20\x01\x10\x05\x20\x01\x10\x09\x20\x01\x41\x01\x11\x03\x00\x0b\x0b\x00\x02\x40\x42\x18\x10\x0c\x0f\x0b\x00\x0b");
+//assert_return(() => $$.exports["print32"](13));
+//assert_return(() => $$.exports["assert_0"]());
 $$ = instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x04\x01\x60\x00\x00\x02\x0d\x01\x04\x74\x65\x73\x74\x04\x66\x75\x6e\x63\x00\x00");
 $$ = instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x05\x01\x60\x01\x7f\x00\x02\x11\x01\x04\x74\x65\x73\x74\x08\x66\x75\x6e\x63\x2d\x69\x33\x32\x00\x00");
 $$ = instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x05\x01\x60\x01\x7d\x00\x02\x11\x01\x04\x74\x65\x73\x74\x08\x66\x75\x6e\x63\x2d\x66\x33\x32\x00\x00");
@@ -128,11 +129,12 @@
 assert_unlinkable("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x04\x01\x60\x00\x00\x02\x13\x01\x08\x73\x70\x65\x63\x74\x65\x73\x74\x06\x67\x6c\x6f\x62\x61\x6c\x00\x00");
 assert_unlinkable("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x04\x01\x60\x00\x00\x02\x12\x01\x08\x73\x70\x65\x63\x74\x65\x73\x74\x05\x74\x61\x62\x6c\x65\x00\x00");
 assert_unlinkable("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x04\x01\x60\x00\x00\x02\x13\x01\x08\x73\x70\x65\x63\x74\x65\x73\x74\x06\x6d\x65\x6d\x6f\x72\x79\x00\x00");
-$$ = instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x05\x01\x60\x00\x01\x7f\x02\x86\x01\x07\x08\x73\x70\x65\x63\x74\x65\x73\x74\x06\x67\x6c\x6f\x62\x61\x6c\x03\x7f\x00\x08\x73\x70\x65\x63\x74\x65\x73\x74\x06\x67\x6c\x6f\x62\x61\x6c\x03\x7f\x00\x08\x73\x70\x65\x63\x74\x65\x73\x74\x06\x67\x6c\x6f\x62\x61\x6c\x03\x7f\x00\x08\x73\x70\x65\x63\x74\x65\x73\x74\x06\x67\x6c\x6f\x62\x61\x6c\x03\x7f\x00\x08\x73\x70\x65\x63\x74\x65\x73\x74\x06\x67\x6c\x6f\x62\x61\x6c\x03\x7e\x00\x08\x73\x70\x65\x63\x74\x65\x73\x74\x06\x67\x6c\x6f\x62\x61\x6c\x03\x7d\x00\x08\x73\x70\x65\x63\x74\x65\x73\x74\x06\x67\x6c\x6f\x62\x61\x6c\x03\x7c\x00\x03\x05\x04\x00\x00\x00\x00\x07\x21\x04\x05\x67\x65\x74\x2d\x30\x00\x00\x05\x67\x65\x74\x2d\x31\x00\x01\x05\x67\x65\x74\x2d\x78\x00\x02\x05\x67\x65\x74\x2d\x79\x00\x03\x0a\x15\x04\x04\x00\x23\x00\x0b\x04\x00\x23\x01\x0b\x04\x00\x23\x02\x0b\x04\x00\x23\x03\x0b");
-assert_return(() => $$.exports["get-0"](), 666);
-assert_return(() => $$.exports["get-1"](), 666);
-assert_return(() => $$.exports["get-x"](), 666);
-assert_return(() => $$.exports["get-y"](), 666);
+// FIXME i64 global was fixed in ToT spec repo. Update spec tests for newer version. https://bugs.webkit.org/show_bug.cgi?id=168784
+//$$ = instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x05\x01\x60\x00\x01\x7f\x02\x86\x01\x07\x08\x73\x70\x65\x63\x74\x65\x73\x74\x06\x67\x6c\x6f\x62\x61\x6c\x03\x7f\x00\x08\x73\x70\x65\x63\x74\x65\x73\x74\x06\x67\x6c\x6f\x62\x61\x6c\x03\x7f\x00\x08\x73\x70\x65\x63\x74\x65\x73\x74\x06\x67\x6c\x6f\x62\x61\x6c\x03\x7f\x00\x08\x73\x70\x65\x63\x74\x65\x73\x74\x06\x67\x6c\x6f\x62\x61\x6c\x03\x7f\x00\x08\x73\x70\x65\x63\x74\x65\x73\x74\x06\x67\x6c\x6f\x62\x61\x6c\x03\x7e\x00\x08\x73\x70\x65\x63\x74\x65\x73\x74\x06\x67\x6c\x6f\x62\x61\x6c\x03\x7d\x00\x08\x73\x70\x65\x63\x74\x65\x73\x74\x06\x67\x6c\x6f\x62\x61\x6c\x03\x7c\x00\x03\x05\x04\x00\x00\x00\x00\x07\x21\x04\x05\x67\x65\x74\x2d\x30\x00\x00\x05\x67\x65\x74\x2d\x31\x00\x01\x05\x67\x65\x74\x2d\x78\x00\x02\x05\x67\x65\x74\x2d\x79\x00\x03\x0a\x15\x04\x04\x00\x23\x00\x0b\x04\x00\x23\x01\x0b\x04\x00\x23\x02\x0b\x04\x00\x23\x03\x0b");
+//assert_return(() => $$.exports["get-0"](), 666);
+//assert_return(() => $$.exports["get-1"](), 666);
+//assert_return(() => $$.exports["get-x"](), 666);
+//assert_return(() => $$.exports["get-y"](), 666);
 $$ = instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x02\x14\x01\x04\x74\x65\x73\x74\x0a\x67\x6c\x6f\x62\x61\x6c\x2d\x69\x33\x32\x03\x7f\x00");
 $$ = instance("\x00\x61\x73\x6d\x01\x00\x00\x00\x02\x14\x01\x04\x74\x65\x73\x74\x0a\x67\x6c\x6f\x62\x61\x6c\x2d\x66\x33\x32\x03\x7d\x00");
 assert_unlinkable("\x00\x61\x73\x6d\x01\x00\x00\x00\x02\x11\x01\x04\x74\x65\x73\x74\x07\x75\x6e\x6b\x6e\x6f\x77\x6e\x03\x7f\x00");

Modified: trunk/JSTests/wasm.yaml (212982 => 212983)


--- trunk/JSTests/wasm.yaml	2017-02-25 01:17:15 UTC (rev 212982)
+++ trunk/JSTests/wasm.yaml	2017-02-25 02:02:06 UTC (rev 212983)
@@ -52,10 +52,10 @@
   cmd: runWebAssemblySpecTest :normal
 
 - path: wasm/spec-tests/call.wast.js
-  cmd: runWebAssemblySpecTest :skip
+  cmd: runWebAssemblySpecTest :normal
 
 - path: wasm/spec-tests/call_indirect.wast.js
-  cmd: runWebAssemblySpecTest :skip
+  cmd: runWebAssemblySpecTest :normal
 
 - path: wasm/spec-tests/comments.wast.js
   cmd: runWebAssemblySpecTest :normal
@@ -64,7 +64,7 @@
   cmd: runWebAssemblySpecTest :normal
 
 - path: wasm/spec-tests/custom_section.wast.js
-  cmd: runWebAssemblySpecTest :skip
+  cmd: runWebAssemblySpecTest :normal
 
 - path: wasm/spec-tests/endianness.wast.js
   cmd: runWebAssemblySpecTest :normal
@@ -85,10 +85,10 @@
   cmd: runWebAssemblySpecTest :normal
 
 - path: wasm/spec-tests/fac.wast.js
-  cmd: runWebAssemblySpecTest :skip
+  cmd: runWebAssemblySpecTest :normal
 
 - path: wasm/spec-tests/float_exprs.wast.js
-  cmd: runWebAssemblySpecTest :skip
+  cmd: runWebAssemblySpecTest :normal
 
 - path: wasm/spec-tests/float_literals.wast.js
   cmd: runWebAssemblySpecTest :normal
@@ -121,7 +121,7 @@
   cmd: runWebAssemblySpecTest :normal
 
 - path: wasm/spec-tests/imports.wast.js
-  cmd: runWebAssemblySpecTest :skip
+  cmd: runWebAssemblySpecTest :normal
 
 - path: wasm/spec-tests/int_exprs.wast.js
   cmd: runWebAssemblySpecTest :normal

Modified: trunk/Source/_javascript_Core/ChangeLog (212982 => 212983)


--- trunk/Source/_javascript_Core/ChangeLog	2017-02-25 01:17:15 UTC (rev 212982)
+++ trunk/Source/_javascript_Core/ChangeLog	2017-02-25 02:02:06 UTC (rev 212983)
@@ -1,3 +1,20 @@
+2017-02-24  JF Bastien  <jfbast...@apple.com>
+
+        WebAssembly: miscellaneous spec fixes
+        https://bugs.webkit.org/show_bug.cgi?id=168822
+
+        Reviewed by Saam Barati.
+
+        * wasm/WasmModuleParser.cpp: "unknown" sections are now called "custom" sections
+        * wasm/WasmSections.h:
+        (JSC::Wasm::validateOrder):
+        (JSC::Wasm::makeString): fix ASSERT_UNREACHABLE bug in printing
+        * wasm/js/WebAssemblyInstanceConstructor.cpp:
+        (JSC::constructJSWebAssemblyInstance): disallow i64 import
+        * wasm/js/WebAssemblyModuleRecord.cpp:
+        (JSC::WebAssemblyModuleRecord::link): disallow i64 export
+        (JSC::WebAssemblyModuleRecord::evaluate):
+
 2017-02-24  Filip Pizlo  <fpi...@apple.com>
 
         Move Arg::Type and Arg::Width out into the B3 namespace, since they are general concepts

Modified: trunk/Source/_javascript_Core/wasm/WasmModuleParser.cpp (212982 => 212983)


--- trunk/Source/_javascript_Core/wasm/WasmModuleParser.cpp	2017-02-25 01:17:15 UTC (rev 212982)
+++ trunk/Source/_javascript_Core/wasm/WasmModuleParser.cpp	2017-02-25 02:02:06 UTC (rev 212983)
@@ -59,13 +59,13 @@
     if (versionNumber != 0xD) // FIXME Stop supporting version 0xD temporarily. https://bugs.webkit.org/show_bug.cgi?id=168788
         WASM_PARSER_FAIL_IF(versionNumber != expectedVersionNumber, "unexpected version number ", versionNumber, " expected ", expectedVersionNumber);
 
-    Section previousSection = Section::Unknown;
+    Section previousSection = Section::Custom;
     while (m_offset < length()) {
         uint8_t sectionByte;
 
         WASM_PARSER_FAIL_IF(!parseUInt7(sectionByte), "can't get section byte");
 
-        Section section = Section::Unknown;
+        Section section = Section::Custom;
         if (sectionByte) {
             if (isValidSection(sectionByte))
                 section = static_cast<Section>(sectionByte);
@@ -87,7 +87,7 @@
         FOR_EACH_WASM_SECTION(WASM_SECTION_PARSE)
 #undef WASM_SECTION_PARSE
 
-        case Section::Unknown: {
+        case Section::Custom: {
             WASM_FAIL_IF_HELPER_FAILS(parseCustom(sectionLength));
             break;
         }

Modified: trunk/Source/_javascript_Core/wasm/WasmSections.h (212982 => 212983)


--- trunk/Source/_javascript_Core/wasm/WasmSections.h	2017-02-25 01:17:15 UTC (rev 212982)
+++ trunk/Source/_javascript_Core/wasm/WasmSections.h	2017-02-25 02:02:06 UTC (rev 212983)
@@ -46,7 +46,7 @@
 #define DEFINE_WASM_SECTION_ENUM(NAME, ID, DESCRIPTION) NAME = ID,
     FOR_EACH_WASM_SECTION(DEFINE_WASM_SECTION_ENUM)
 #undef DEFINE_WASM_SECTION_ENUM
-    Unknown
+    Custom
 };
 
 template<typename Int>
@@ -63,7 +63,7 @@
 
 static inline bool validateOrder(Section previous, Section next)
 {
-    if (previous == Section::Unknown)
+    if (previous == Section::Custom)
         return true;
     return static_cast<uint8_t>(previous) < static_cast<uint8_t>(next);
 }
@@ -71,12 +71,11 @@
 static inline const char* makeString(Section section)
 {
     switch (section) {
+    case Section::Custom:
+        return "Custom";
 #define STRINGIFY_SECTION_NAME(NAME, ID, DESCRIPTION) case Section::NAME: return #NAME;
         FOR_EACH_WASM_SECTION(STRINGIFY_SECTION_NAME)
 #undef STRINGIFY_SECTION_NAME
-    default:
-        RELEASE_ASSERT_NOT_REACHED();
-        return "?";
     }
 }
 

Modified: trunk/Source/_javascript_Core/wasm/js/WebAssemblyInstanceConstructor.cpp (212982 => 212983)


--- trunk/Source/_javascript_Core/wasm/js/WebAssemblyInstanceConstructor.cpp	2017-02-25 01:17:15 UTC (rev 212982)
+++ trunk/Source/_javascript_Core/wasm/js/WebAssemblyInstanceConstructor.cpp	2017-02-25 02:02:06 UTC (rev 212983)
@@ -203,7 +203,9 @@
             // 5. If i is a global import:
             // i. If i is not an immutable global, throw a TypeError.
             ASSERT(moduleInformation.globals[import.kindIndex].mutability == Wasm::Global::Immutable);
-            // ii. If Type(v) is not Number, throw a TypeError.
+            // ii. If the global_type of i is i64 or Type(v) is not Number, throw a WebAssembly.LinkError.
+            if (moduleInformation.globals[import.kindIndex].type == Wasm::I64)
+                return JSValue::encode(throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, vm, ASCIILiteral("imported global cannot be an i64"))));
             if (!value.isNumber())
                 return JSValue::encode(throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, vm, ASCIILiteral("imported global must be a number"))));
             // iii. Append ToWebAssemblyValue(v) to imports.

Modified: trunk/Source/_javascript_Core/wasm/js/WebAssemblyModuleRecord.cpp (212982 => 212983)


--- trunk/Source/_javascript_Core/wasm/js/WebAssemblyModuleRecord.cpp	2017-02-25 01:17:15 UTC (rev 212982)
+++ trunk/Source/_javascript_Core/wasm/js/WebAssemblyModuleRecord.cpp	2017-02-25 02:02:06 UTC (rev 212983)
@@ -148,6 +148,10 @@
                 exportedValue = JSValue(instance->loadI32Global(exp.kindIndex));
                 break;
 
+            case Wasm::I64:
+                throwException(state, scope, createJSWebAssemblyLinkError(state, vm, ASCIILiteral("exported global cannot be an i64")));
+                return;
+
             case Wasm::F32:
                 exportedValue = JSValue(instance->loadF32Global(exp.kindIndex));
                 break;
@@ -238,7 +242,7 @@
                 JSWebAssemblyCallee* wasmEntrypointCallee = module->wasmEntrypointCalleeFromFunctionIndexSpace(functionIndex);
                 Wasm::SignatureIndex signatureIndex = module->signatureIndexFromFunctionIndexSpace(functionIndex);
                 const Wasm::Signature* signature = Wasm::SignatureInformation::get(&vm, signatureIndex);
-                // FIXME: Say we export local function "foo" at funciton index 0.
+                // FIXME: Say we export local function "foo" at function index 0.
                 // What if we also set it to the table an Element w/ index 0.
                 // Does (new Instance(...)).exports.foo === table.get(0)?
                 // https://bugs.webkit.org/show_bug.cgi?id=165825
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to