Changeset 212983 in webkit


Ignore:
Timestamp:
Feb 24, 2017 6:02:06 PM (7 years ago)
Author:
jfbastien@apple.com
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/JavaScriptCore:

  • 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):

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r212939 r212983  
     12017-02-24  JF Bastien  <jfbastien@apple.com>
     2
     3        WebAssembly: miscellaneous spec fixes
     4        https://bugs.webkit.org/show_bug.cgi?id=168822
     5
     6        Reviewed by Saam Barati.
     7
     8        * wasm.yaml: mark some skip tests as normal, now that they pass
     9        * wasm/Builder.js: error message was wrong, causing extra error if hit
     10        * wasm/js-api/global-error.js: new tests
     11        (assert.throws):
     12        * wasm/spec-tests/call.wast.js: comment out stack check tests
     13        * wasm/spec-tests/call_indirect.wast.js: comment out stack check tests
     14        * wasm/spec-tests/fac.wast.js: comment out stack check tests
     15        * wasm/spec-tests/float_exprs.wast.js: wabt is wrong, bug reported, we should update
     16        * wasm/spec-tests/imports.wast.js: bug in old wabt, fixed in recent wabt
     17        (assert_unlinkable):
     18
    1192017-02-23  Saam Barati  <sbarati@apple.com>
    220
  • trunk/JSTests/wasm.yaml

    r210244 r212983  
    5353
    5454- path: wasm/spec-tests/call.wast.js
    55   cmd: runWebAssemblySpecTest :skip
     55  cmd: runWebAssemblySpecTest :normal
    5656
    5757- path: wasm/spec-tests/call_indirect.wast.js
    58   cmd: runWebAssemblySpecTest :skip
     58  cmd: runWebAssemblySpecTest :normal
    5959
    6060- path: wasm/spec-tests/comments.wast.js
     
    6565
    6666- path: wasm/spec-tests/custom_section.wast.js
    67   cmd: runWebAssemblySpecTest :skip
     67  cmd: runWebAssemblySpecTest :normal
    6868
    6969- path: wasm/spec-tests/endianness.wast.js
     
    8686
    8787- path: wasm/spec-tests/fac.wast.js
    88   cmd: runWebAssemblySpecTest :skip
     88  cmd: runWebAssemblySpecTest :normal
    8989
    9090- path: wasm/spec-tests/float_exprs.wast.js
    91   cmd: runWebAssemblySpecTest :skip
     91  cmd: runWebAssemblySpecTest :normal
    9292
    9393- path: wasm/spec-tests/float_literals.wast.js
     
    122122
    123123- path: wasm/spec-tests/imports.wast.js
    124   cmd: runWebAssemblySpecTest :skip
     124  cmd: runWebAssemblySpecTest :normal
    125125
    126126- path: wasm/spec-tests/int_exprs.wast.js
  • trunk/JSTests/wasm/Builder.js

    r210282 r212983  
    193193        return 0;
    194194    else
    195         throw new Error(`mutability should be either "mutable" or "immutable", but got ${global.mutablity}`);
     195        throw new Error(`mutability should be either "mutable" or "immutable", but got ${mutability}`);
    196196};
    197197
  • trunk/JSTests/wasm/js-api/global-error.js

    r210090 r212983  
    188188    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 } })')");
    189189}
     190
     191{
     192    const builder = new Builder()
     193        .Type().End()
     194        .Global().I64(0, "immutable").End()
     195        .Export()
     196            .Global("bigInt", 0)
     197        .End();
     198    const module = new WebAssembly.Module(builder.WebAssembly().get());
     199    assert.throws(() => new WebAssembly.Instance(module), WebAssembly.LinkError, "exported global cannot be an i64 (evaluating 'new WebAssembly.Instance(module)')");
     200}
     201
     202{
     203    const builder = new Builder()
     204        .Type().End()
     205        .Import()
     206            .Global().I64("imp", "global", "immutable").End()
     207        .End()
     208        .Function().End()
     209        .Global().GetGlobal("i64", 0, "immutable").End();
     210    const module = new WebAssembly.Module(builder.WebAssembly().get());
     211    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 } })')");
     212}
  • trunk/JSTests/wasm/spec-tests/call.wast.js

    r212922 r212983  
    127127assert_return(() => $$.exports["assert_22"]());
    128128assert_return(() => $$.exports["assert_23"]());
    129 assert_trap(() => $$.exports["runaway"]());
    130 assert_trap(() => $$.exports["mutual-runaway"]());
     129// FIXME do stack checks https://bugs.webkit.org/show_bug.cgi?id=165546
     130//assert_trap(() => $$.exports["runaway"]());
     131//assert_trap(() => $$.exports["mutual-runaway"]());
    131132assert_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");
    132133assert_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");
  • trunk/JSTests/wasm/spec-tests/call_indirect.wast.js

    r212922 r212983  
    140140assert_return(() => $$.exports["odd"](200), 99);
    141141assert_return(() => $$.exports["odd"](77), 44);
    142 assert_trap(() => $$.exports["runaway"]());
    143 assert_trap(() => $$.exports["mutual-runaway"]());
     142// FIXME do stack checks https://bugs.webkit.org/show_bug.cgi?id=165546
     143//assert_trap(() => $$.exports["runaway"]());
     144//assert_trap(() => $$.exports["mutual-runaway"]());
    144145assert_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");
    145146assert_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");
  • trunk/JSTests/wasm/spec-tests/fac.wast.js

    r212922 r212983  
    9999assert_return(() => $$.exports["assert_3"]());
    100100assert_return(() => $$.exports["assert_4"]());
    101 assert_trap(() => $$.exports["assert_5"]());
     101// FIXME do stack checks https://bugs.webkit.org/show_bug.cgi?id=165546
     102//assert_trap(() => $$.exports["assert_5"]());
  • trunk/JSTests/wasm/spec-tests/float_exprs.wast.js

    r212922 r212983  
    133133assert_return(() => $$.exports["assert_1"]());
    134134$$ = 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");
    135 assert_return(() => $$.exports["assert_0"]());
    136 assert_return(() => $$.exports["assert_1"]());
     135// FIXME The following spec tests seem to mistranslate with wabt:
     136//   (assert_return (invoke "f32.no_fold_mul_one" (f32.const nan:0x200000)) (f32.const nan:0x600000))
     137//   (assert_return (invoke "f64.no_fold_mul_one" (f64.const nan:0x4000000000000)) (f64.const nan:0xc000000000000))
     138//assert_return(() => $$.exports["assert_0"]());
     139//assert_return(() => $$.exports["assert_1"]());
    137140$$ = 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\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");
    138141assert_return_nan(() => $$.exports["f32.no_fold_zero_div"](f32(0.0)));
     
    376379assert_return(() => $$.exports["no_fold_demote_promote"](2.335945149795088e+31), 2.3359452224542198e+31);
    377380$$ = 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");
    378 assert_return(() => $$.exports["assert_0"]());
     381// FIXME The following spec tests seem to mistranslate with wabt:
     382//   (assert_return (invoke "no_fold_promote_demote" (f32.const nan:0x200000)) (f32.const nan:0x600000))
     383//assert_return(() => $$.exports["assert_0"]());
    379384assert_return(() => $$.exports["no_fold_promote_demote"](f32(0.0)), f32(0.0));
    380385assert_return(() => $$.exports["no_fold_promote_demote"](f32(-0.0)), f32(-0.0));
  • trunk/JSTests/wasm/spec-tests/imports.wast.js

    r212922 r212983  
    5757  let mod = module(bytes);
    5858  try { new WebAssembly.Instance(mod, registry) } catch (e) {
    59     if (e instanceof TypeError) return;
     59      if (e instanceof WebAssembly.LinkError) return; // Note: this is fixed in tip-of-tree wabt.
    6060  }
    6161  throw new Error("Wasm linking failure expected");
     
    9595$$ = 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");
    9696register("test", $$)
    97 $$ = 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");
    98 assert_return(() => $$.exports["print32"](13));
    99 assert_return(() => $$.exports["assert_0"]());
     97// FIXME re-exporting an import isn't implemented. https://bugs.webkit.org/show_bug.cgi?id=165510
     98//$$ = 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");
     99//assert_return(() => $$.exports["print32"](13));
     100//assert_return(() => $$.exports["assert_0"]());
    100101$$ = 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");
    101102$$ = 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");
     
    129130assert_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");
    130131assert_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");
    131 $$ = 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");
    132 assert_return(() => $$.exports["get-0"](), 666);
    133 assert_return(() => $$.exports["get-1"](), 666);
    134 assert_return(() => $$.exports["get-x"](), 666);
    135 assert_return(() => $$.exports["get-y"](), 666);
     132// FIXME i64 global was fixed in ToT spec repo. Update spec tests for newer version. https://bugs.webkit.org/show_bug.cgi?id=168784
     133//$$ = 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");
     134//assert_return(() => $$.exports["get-0"](), 666);
     135//assert_return(() => $$.exports["get-1"](), 666);
     136//assert_return(() => $$.exports["get-x"](), 666);
     137//assert_return(() => $$.exports["get-y"](), 666);
    136138$$ = 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");
    137139$$ = 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");
  • trunk/Source/JavaScriptCore/ChangeLog

    r212970 r212983  
     12017-02-24  JF Bastien  <jfbastien@apple.com>
     2
     3        WebAssembly: miscellaneous spec fixes
     4        https://bugs.webkit.org/show_bug.cgi?id=168822
     5
     6        Reviewed by Saam Barati.
     7
     8        * wasm/WasmModuleParser.cpp: "unknown" sections are now called "custom" sections
     9        * wasm/WasmSections.h:
     10        (JSC::Wasm::validateOrder):
     11        (JSC::Wasm::makeString): fix ASSERT_UNREACHABLE bug in printing
     12        * wasm/js/WebAssemblyInstanceConstructor.cpp:
     13        (JSC::constructJSWebAssemblyInstance): disallow i64 import
     14        * wasm/js/WebAssemblyModuleRecord.cpp:
     15        (JSC::WebAssemblyModuleRecord::link): disallow i64 export
     16        (JSC::WebAssemblyModuleRecord::evaluate):
     17
    1182017-02-24  Filip Pizlo  <fpizlo@apple.com>
    219
  • trunk/Source/JavaScriptCore/wasm/WasmModuleParser.cpp

    r212922 r212983  
    6060        WASM_PARSER_FAIL_IF(versionNumber != expectedVersionNumber, "unexpected version number ", versionNumber, " expected ", expectedVersionNumber);
    6161
    62     Section previousSection = Section::Unknown;
     62    Section previousSection = Section::Custom;
    6363    while (m_offset < length()) {
    6464        uint8_t sectionByte;
     
    6666        WASM_PARSER_FAIL_IF(!parseUInt7(sectionByte), "can't get section byte");
    6767
    68         Section section = Section::Unknown;
     68        Section section = Section::Custom;
    6969        if (sectionByte) {
    7070            if (isValidSection(sectionByte))
     
    8888#undef WASM_SECTION_PARSE
    8989
    90         case Section::Unknown: {
     90        case Section::Custom: {
    9191            WASM_FAIL_IF_HELPER_FAILS(parseCustom(sectionLength));
    9292            break;
  • trunk/Source/JavaScriptCore/wasm/WasmSections.h

    r209880 r212983  
    4747    FOR_EACH_WASM_SECTION(DEFINE_WASM_SECTION_ENUM)
    4848#undef DEFINE_WASM_SECTION_ENUM
    49     Unknown
     49    Custom
    5050};
    5151
     
    6464static inline bool validateOrder(Section previous, Section next)
    6565{
    66     if (previous == Section::Unknown)
     66    if (previous == Section::Custom)
    6767        return true;
    6868    return static_cast<uint8_t>(previous) < static_cast<uint8_t>(next);
     
    7272{
    7373    switch (section) {
     74    case Section::Custom:
     75        return "Custom";
    7476#define STRINGIFY_SECTION_NAME(NAME, ID, DESCRIPTION) case Section::NAME: return #NAME;
    7577        FOR_EACH_WASM_SECTION(STRINGIFY_SECTION_NAME)
    7678#undef STRINGIFY_SECTION_NAME
    77     default:
    78         RELEASE_ASSERT_NOT_REACHED();
    79         return "?";
    8079    }
    8180}
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp

    r211247 r212983  
    204204            // i. If i is not an immutable global, throw a TypeError.
    205205            ASSERT(moduleInformation.globals[import.kindIndex].mutability == Wasm::Global::Immutable);
    206             // ii. If Type(v) is not Number, throw a TypeError.
     206            // ii. If the global_type of i is i64 or Type(v) is not Number, throw a WebAssembly.LinkError.
     207            if (moduleInformation.globals[import.kindIndex].type == Wasm::I64)
     208                return JSValue::encode(throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, vm, ASCIILiteral("imported global cannot be an i64"))));
    207209            if (!value.isNumber())
    208210                return JSValue::encode(throwException(exec, throwScope, createJSWebAssemblyLinkError(exec, vm, ASCIILiteral("imported global must be a number"))));
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleRecord.cpp

    r211247 r212983  
    149149                break;
    150150
     151            case Wasm::I64:
     152                throwException(state, scope, createJSWebAssemblyLinkError(state, vm, ASCIILiteral("exported global cannot be an i64")));
     153                return;
     154
    151155            case Wasm::F32:
    152156                exportedValue = JSValue(instance->loadF32Global(exp.kindIndex));
     
    239243                Wasm::SignatureIndex signatureIndex = module->signatureIndexFromFunctionIndexSpace(functionIndex);
    240244                const Wasm::Signature* signature = Wasm::SignatureInformation::get(&vm, signatureIndex);
    241                 // FIXME: Say we export local function "foo" at funciton index 0.
     245                // FIXME: Say we export local function "foo" at function index 0.
    242246                // What if we also set it to the table an Element w/ index 0.
    243247                // Does (new Instance(...)).exports.foo === table.get(0)?
Note: See TracChangeset for help on using the changeset viewer.