Changeset 247457 in webkit


Ignore:
Timestamp:
Jul 15, 2019 3:41:54 PM (5 years ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Improve wasm wpt test results by fixing miscellaneous issues
https://bugs.webkit.org/show_bug.cgi?id=199783

Reviewed by Mark Lam.

JSTests:

Fix our spec tests.

  • wasm/js-api/Module-compile.js:
  • wasm/js-api/test_basic_api.js:

(const.c.in.constructorProperties.switch):

  • wasm/js-api/validate.js:
  • wasm/js-api/web-assembly-instantiate.js:
  • wasm/spec-tests/jsapi.js:

(testJSAPI.get test):
(testJSAPI.set test):

LayoutTests/imported/w3c:

Import web-platform-tests/wasm/jsapi. Some of tests are failing just because imported wpt tests are old.
They are fixed in the upstream. When upgrading wpt tests, we can mark them PASS.

  • resources/import-expectations.json:
  • web-platform-tests/wasm/jsapi/assertions.js: Added.

(assert_function_name):
(assert_function_length):

  • web-platform-tests/wasm/jsapi/bad-imports.js: Added.

(test_bad_imports):

  • web-platform-tests/wasm/jsapi/constructor/instantiate-bad-imports.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/constructor/instantiate-bad-imports.any.html: Added.
  • web-platform-tests/wasm/jsapi/constructor/instantiate-bad-imports.any.js: Added.

(test_bad_imports):

  • web-platform-tests/wasm/jsapi/constructor/instantiate-bad-imports.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/constructor/instantiate-bad-imports.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/constructor/w3c-import.log: Added.
  • web-platform-tests/wasm/jsapi/global/constructor.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/global/constructor.any.html: Added.
  • web-platform-tests/wasm/jsapi/global/constructor.any.js: Added.

(assert_Global):
(test):
(test.get assert_array_equals):
(string_appeared_here.test):
(string_appeared_here.toString):
(string_appeared_here.valueOf):
(string_appeared_here.name.format_value):

  • web-platform-tests/wasm/jsapi/global/constructor.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/global/constructor.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/global/toString.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/global/toString.any.html: Added.
  • web-platform-tests/wasm/jsapi/global/toString.any.js: Added.

(test):

  • web-platform-tests/wasm/jsapi/global/toString.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/global/toString.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/global/value-set.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/global/value-set.any.html: Added.
  • web-platform-tests/wasm/jsapi/global/value-set.any.js: Added.

(test):
(string_appeared_here.name.of.immutableOptions.test):
(string_appeared_here.name.of.mutableOptions.test):

  • web-platform-tests/wasm/jsapi/global/value-set.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/global/value-set.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/global/valueOf.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/global/valueOf.any.html: Added.
  • web-platform-tests/wasm/jsapi/global/valueOf.any.js: Added.

(test):

  • web-platform-tests/wasm/jsapi/global/valueOf.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/global/valueOf.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/global/w3c-import.log: Added.
  • web-platform-tests/wasm/jsapi/instance/constructor-bad-imports.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/instance/constructor-bad-imports.any.html: Added.
  • web-platform-tests/wasm/jsapi/instance/constructor-bad-imports.any.js: Added.

(test_bad_imports):

  • web-platform-tests/wasm/jsapi/instance/constructor-bad-imports.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/instance/constructor-bad-imports.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/instance/constructor.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/instance/constructor.any.html: Added.
  • web-platform-tests/wasm/jsapi/instance/constructor.any.js: Added.

(assert_exported_function):

  • web-platform-tests/wasm/jsapi/instance/constructor.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/instance/constructor.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/instance/exports.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/instance/exports.any.html: Added.
  • web-platform-tests/wasm/jsapi/instance/exports.any.js: Added.

(setup):
(test):

  • web-platform-tests/wasm/jsapi/instance/exports.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/instance/exports.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/instance/toString.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/instance/toString.any.html: Added.
  • web-platform-tests/wasm/jsapi/instance/toString.any.js: Added.

(test):

  • web-platform-tests/wasm/jsapi/instance/toString.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/instance/toString.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/instance/w3c-import.log: Added.
  • web-platform-tests/wasm/jsapi/interface.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/interface.any.html: Added.
  • web-platform-tests/wasm/jsapi/interface.any.js: Added.

(test_operations):
(test):
(const.name.of.interfaces.test):

  • web-platform-tests/wasm/jsapi/interface.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/interface.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/memory/buffer.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/memory/buffer.any.html: Added.
  • web-platform-tests/wasm/jsapi/memory/buffer.any.js: Added.

(test):

  • web-platform-tests/wasm/jsapi/memory/buffer.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/memory/buffer.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/memory/constructor.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/memory/constructor.any.html: Added.
  • web-platform-tests/wasm/jsapi/memory/constructor.any.js: Added.

(assert_Memory):
(test):
(const.value.of.outOfRangeValues.test):
(test.get new):
(test.get assert_array_equals):

  • web-platform-tests/wasm/jsapi/memory/constructor.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/memory/constructor.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/memory/grow.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/memory/grow.any.html: Added.
  • web-platform-tests/wasm/jsapi/memory/grow.any.js: Added.

(assert_ArrayBuffer):
(test):
(valueOf):
(const.value.of.outOfRangeValues.test):

  • web-platform-tests/wasm/jsapi/memory/grow.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/memory/grow.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/memory/toString.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/memory/toString.any.html: Added.
  • web-platform-tests/wasm/jsapi/memory/toString.any.js: Added.

(test):

  • web-platform-tests/wasm/jsapi/memory/toString.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/memory/toString.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/memory/w3c-import.log: Added.
  • web-platform-tests/wasm/jsapi/module/constructor.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/module/constructor.any.html: Added.
  • web-platform-tests/wasm/jsapi/module/constructor.any.js: Added.

(setup):
(test):

  • web-platform-tests/wasm/jsapi/module/constructor.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/module/constructor.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/module/customSections.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/module/customSections.any.html: Added.
  • web-platform-tests/wasm/jsapi/module/customSections.any.js: Added.

(assert_ArrayBuffer):
(assert_sections):
(setup):
(test):

  • web-platform-tests/wasm/jsapi/module/customSections.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/module/customSections.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/module/exports.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/module/exports.any.html: Added.
  • web-platform-tests/wasm/jsapi/module/exports.any.js: Added.

(setup):
(assert_ModuleExportDescriptor):
(assert_exports):
(test):

  • web-platform-tests/wasm/jsapi/module/exports.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/module/exports.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/module/imports.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/module/imports.any.html: Added.
  • web-platform-tests/wasm/jsapi/module/imports.any.js: Added.

(assert_ModuleImportDescriptor):
(assert_imports):
(setup):
(test):

  • web-platform-tests/wasm/jsapi/module/imports.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/module/imports.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/module/toString.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/module/toString.any.html: Added.
  • web-platform-tests/wasm/jsapi/module/toString.any.js: Added.

(test):

  • web-platform-tests/wasm/jsapi/module/toString.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/module/toString.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/module/w3c-import.log: Added.
  • web-platform-tests/wasm/jsapi/table/assertions.js: Added.

(assert_equal_to_array):

  • web-platform-tests/wasm/jsapi/table/constructor.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/table/constructor.any.html: Added.
  • web-platform-tests/wasm/jsapi/table/constructor.any.js: Added.

(assert_Table):
(test):
(const.value.of.outOfRangeValues.test):
(test.get const):

  • web-platform-tests/wasm/jsapi/table/constructor.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/table/constructor.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/table/get-set.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/table/get-set.any.html: Added.
  • web-platform-tests/wasm/jsapi/table/get-set.any.js: Added.

(setup):
(test):
(test.set assert_equal_to_array):
(test.const.fn):
(valueOf):
(const.value.of.outOfRangeValues.test):

  • web-platform-tests/wasm/jsapi/table/get-set.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/table/get-set.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/table/grow.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/table/grow.any.html: Added.
  • web-platform-tests/wasm/jsapi/table/grow.any.js: Added.

(nulls):
(test):
(valueOf):
(const.value.of.outOfRangeValues.test):

  • web-platform-tests/wasm/jsapi/table/grow.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/table/grow.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/table/length.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/table/length.any.html: Added.
  • web-platform-tests/wasm/jsapi/table/length.any.js: Added.

(test):

  • web-platform-tests/wasm/jsapi/table/length.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/table/length.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/table/toString.any-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/table/toString.any.html: Added.
  • web-platform-tests/wasm/jsapi/table/toString.any.js: Added.

(test):

  • web-platform-tests/wasm/jsapi/table/toString.any.worker-expected.txt: Added.
  • web-platform-tests/wasm/jsapi/table/toString.any.worker.html: Added.
  • web-platform-tests/wasm/jsapi/table/w3c-import.log: Added.
  • web-platform-tests/wasm/jsapi/w3c-import.log: Added.
  • web-platform-tests/wasm/jsapi/wasm-constants.js: Added.

(bytes):
(bytesWithHeader):
(makeSig):
(makeSig_v_x):
(makeSig_v_xx):
(makeSig_r_v):
(makeSig_r_x):
(makeSig_r_xx):
(assertTraps):
(assertWasmThrows):

  • web-platform-tests/wasm/jsapi/wasm-module-builder.js: Added.

(Binary.prototype.emit_u8):
(Binary.prototype.emit_u16):
(Binary.prototype.emit_u32):
(Binary.prototype.emit_u32v):
(Binary.prototype.emit_bytes):
(Binary.prototype.emit_string):
(Binary.prototype.emit_header):
(Binary.prototype.emit_section):
(Binary):
(WasmFunctionBuilder):
(WasmFunctionBuilder.prototype.exportAs):
(WasmFunctionBuilder.prototype.exportFunc):
(WasmFunctionBuilder.prototype.addBody):
(WasmFunctionBuilder.prototype.addLocals):
(WasmFunctionBuilder.prototype.end):
(WasmGlobalBuilder):
(WasmGlobalBuilder.prototype.exportAs):
(WasmModuleBuilder):
(WasmModuleBuilder.prototype.addStart):
(WasmModuleBuilder.prototype.addMemory):
(WasmModuleBuilder.prototype.addExplicitSection):
(WasmModuleBuilder.prototype.addType):
(WasmModuleBuilder.prototype.addGlobal):
(WasmModuleBuilder.prototype.addFunction):
(WasmModuleBuilder.prototype.addImport):
(WasmModuleBuilder.prototype.addImportedGlobal):
(WasmModuleBuilder.prototype.addImportedMemory):
(WasmModuleBuilder.prototype.addImportedTable):
(WasmModuleBuilder.prototype.addExport):
(WasmModuleBuilder.prototype.addExportOfKind):
(WasmModuleBuilder.prototype.addDataSegment):
(WasmModuleBuilder.prototype.exportMemoryAs):
(WasmModuleBuilder.prototype.addFunctionTableInit):
(WasmModuleBuilder.prototype.appendToTable):
(WasmModuleBuilder.prototype.setFunctionTableLength):
(WasmModuleBuilder.prototype.toArray):
(WasmModuleBuilder.prototype.toBuffer):
(WasmModuleBuilder.prototype.instantiate):

Source/JavaScriptCore:

This patch fixes miscellaneous issues in our Wasm JS API implementation to improve WPT score.
I picked trivial ones in this patch to make this easily reviewable.

  1. Remove WebAssemblyPrototype. It does not exist in the spec. Merging WebAssemblyPrototype into JSWebAssembly.
  2. Fix various attributes. It does not match to the usual JSC builtin's convention. But this change is correct because they are changed to be matched against WebIDL definition, and WebAssembly implementation follows WebIDL. In the future, we could move WebCore WebIDL things into WTF layer and even use (or leverage some of utility functions) in our WebAssembly JS API implementation.
  3. Fix how we interpret "present" in WebAssembly spec. This does not mean HasProperty? result. It follows to WebIDL spec, and it means that Get? result is not undefined.
  4. Add argument count check to Module.customSections, which is required because the method is defined in WebIDL.
  5. Fix toNonWrappingUint32 to match it to WebIDL's conversion rule.
  • CMakeLists.txt:
  • DerivedSources-input.xcfilelist:
  • DerivedSources-output.xcfilelist:
  • DerivedSources.make:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • Sources.txt:
  • builtins/WebAssembly.js: Renamed from Source/JavaScriptCore/builtins/WebAssemblyPrototype.js.
  • jit/Repatch.cpp:
  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::init):

  • runtime/JSModuleLoader.cpp:

(JSC::moduleLoaderParseModule):

  • wasm/js/JSWebAssembly.cpp:

(JSC::JSWebAssembly::create):
(JSC::JSWebAssembly::finishCreation):
(JSC::reject):
(JSC::webAssemblyModuleValidateAsyncInternal):
(JSC::webAssemblyCompileFunc):
(JSC::resolve):
(JSC::JSWebAssembly::webAssemblyModuleValidateAsync):
(JSC::instantiate):
(JSC::compileAndInstantiate):
(JSC::JSWebAssembly::instantiate):
(JSC::webAssemblyModuleInstantinateAsyncInternal):
(JSC::JSWebAssembly::webAssemblyModuleInstantinateAsync):
(JSC::webAssemblyInstantiateFunc):
(JSC::webAssemblyValidateFunc):
(JSC::webAssemblyCompileStreamingInternal):
(JSC::webAssemblyInstantiateStreamingInternal):

  • wasm/js/JSWebAssembly.h:
  • wasm/js/JSWebAssemblyHelpers.h:

(JSC::toNonWrappingUint32):

  • wasm/js/WebAssemblyCompileErrorConstructor.cpp:

(JSC::WebAssemblyCompileErrorConstructor::finishCreation):

  • wasm/js/WebAssemblyInstanceConstructor.cpp:

(JSC::WebAssemblyInstanceConstructor::finishCreation):

  • wasm/js/WebAssemblyInstancePrototype.cpp:
  • wasm/js/WebAssemblyLinkErrorConstructor.cpp:

(JSC::WebAssemblyLinkErrorConstructor::finishCreation):

  • wasm/js/WebAssemblyMemoryConstructor.cpp:

(JSC::constructJSWebAssemblyMemory):
(JSC::WebAssemblyMemoryConstructor::finishCreation):

  • wasm/js/WebAssemblyMemoryPrototype.cpp:
  • wasm/js/WebAssemblyModuleConstructor.cpp:

(JSC::webAssemblyModuleCustomSections):
(JSC::WebAssemblyModuleConstructor::finishCreation):

  • wasm/js/WebAssemblyPrototype.cpp: Removed.
  • wasm/js/WebAssemblyPrototype.h: Removed.
  • wasm/js/WebAssemblyRuntimeErrorConstructor.cpp:

(JSC::WebAssemblyRuntimeErrorConstructor::finishCreation):

  • wasm/js/WebAssemblyTableConstructor.cpp:

(JSC::constructJSWebAssemblyTable):
(JSC::WebAssemblyTableConstructor::finishCreation):

  • wasm/js/WebAssemblyTablePrototype.cpp:

Source/WebCore:

Remove WebAssemblyPrototype.

Tests: imported/w3c/web-platform-tests/wasm/jsapi/constructor/instantiate-bad-imports.any.html

imported/w3c/web-platform-tests/wasm/jsapi/constructor/instantiate-bad-imports.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/global/constructor.any.html
imported/w3c/web-platform-tests/wasm/jsapi/global/constructor.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/global/toString.any.html
imported/w3c/web-platform-tests/wasm/jsapi/global/toString.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/global/value-set.any.html
imported/w3c/web-platform-tests/wasm/jsapi/global/value-set.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/global/valueOf.any.html
imported/w3c/web-platform-tests/wasm/jsapi/global/valueOf.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/instance/constructor-bad-imports.any.html
imported/w3c/web-platform-tests/wasm/jsapi/instance/constructor-bad-imports.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/instance/constructor.any.html
imported/w3c/web-platform-tests/wasm/jsapi/instance/constructor.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/instance/exports.any.html
imported/w3c/web-platform-tests/wasm/jsapi/instance/exports.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/instance/toString.any.html
imported/w3c/web-platform-tests/wasm/jsapi/instance/toString.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/interface.any.html
imported/w3c/web-platform-tests/wasm/jsapi/interface.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/memory/buffer.any.html
imported/w3c/web-platform-tests/wasm/jsapi/memory/buffer.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/memory/constructor.any.html
imported/w3c/web-platform-tests/wasm/jsapi/memory/constructor.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/memory/grow.any.html
imported/w3c/web-platform-tests/wasm/jsapi/memory/grow.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/memory/toString.any.html
imported/w3c/web-platform-tests/wasm/jsapi/memory/toString.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/module/constructor.any.html
imported/w3c/web-platform-tests/wasm/jsapi/module/constructor.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/module/customSections.any.html
imported/w3c/web-platform-tests/wasm/jsapi/module/customSections.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/module/exports.any.html
imported/w3c/web-platform-tests/wasm/jsapi/module/exports.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/module/imports.any.html
imported/w3c/web-platform-tests/wasm/jsapi/module/imports.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/module/toString.any.html
imported/w3c/web-platform-tests/wasm/jsapi/module/toString.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/table/constructor.any.html
imported/w3c/web-platform-tests/wasm/jsapi/table/constructor.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/table/get-set.any.html
imported/w3c/web-platform-tests/wasm/jsapi/table/get-set.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/table/grow.any.html
imported/w3c/web-platform-tests/wasm/jsapi/table/grow.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/table/length.any.html
imported/w3c/web-platform-tests/wasm/jsapi/table/length.any.worker.html
imported/w3c/web-platform-tests/wasm/jsapi/table/toString.any.html
imported/w3c/web-platform-tests/wasm/jsapi/table/toString.any.worker.html

  • bindings/js/JSDOMWindowBase.cpp:

(WebCore::JSDOMWindowBase::compileStreaming):
(WebCore::JSDOMWindowBase::instantiateStreaming):

LayoutTests:

  • platform/ios-simulator/TestExpectations:
  • platform/win/TestExpectations:
Location:
trunk
Files:
139 added
2 deleted
36 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r247445 r247457  
     12019-07-15  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Improve wasm wpt test results by fixing miscellaneous issues
     4        https://bugs.webkit.org/show_bug.cgi?id=199783
     5
     6        Reviewed by Mark Lam.
     7
     8        Fix our spec tests.
     9
     10        * wasm/js-api/Module-compile.js:
     11        * wasm/js-api/test_basic_api.js:
     12        (const.c.in.constructorProperties.switch):
     13        * wasm/js-api/validate.js:
     14        * wasm/js-api/web-assembly-instantiate.js:
     15        * wasm/spec-tests/jsapi.js:
     16        (testJSAPI.get test):
     17        (testJSAPI.set test):
     18
    1192019-07-15  Michael Catanzaro  <mcatanzaro@igalia.com>
    220
  • trunk/JSTests/wasm/js-api/Module-compile.js

    r247445 r247457  
    33
    44assert.isFunction(WebAssembly.compile);
    5 assert.isFunction(WebAssembly.__proto__.compile);
     5assert.truthy(WebAssembly.hasOwnProperty('compile'));
    66assert.eq(WebAssembly.compile.length, 1);
    77
  • trunk/JSTests/wasm/js-api/test_basic_api.js

    r247445 r247457  
    7979            assert.throws(() => new WebAssembly[c](new WebAssembly.Module(emptyModuleArray), invalid), TypeError, `second argument to WebAssembly.Instance must be undefined or an Object (evaluating 'new WebAssembly[c](new WebAssembly.Module(emptyModuleArray), invalid)')`);
    8080        assert.isNotUndef(instance.exports);
    81         checkAccessorOwnPropertyDescriptor(WebAssembly.Instance.prototype, "exports", { configurable: true, enumerable: false });
     81        checkAccessorOwnPropertyDescriptor(WebAssembly.Instance.prototype, "exports", { configurable: true, enumerable: true });
    8282        assert.throws(() => WebAssembly.Instance.prototype.exports = undefined, TypeError, `Attempted to assign to readonly property.`);
    8383        assert.throws(() => WebAssembly.Instance.prototype.exports, TypeError, `expected |this| value to be an instance of WebAssembly.Instance`);
  • trunk/JSTests/wasm/js-api/validate.js

    r247445 r247457  
    33
    44assert.isFunction(WebAssembly.validate);
    5 assert.isFunction(WebAssembly.__proto__.validate);
     5assert.truthy(WebAssembly.hasOwnProperty('validate'));
    66assert.eq(WebAssembly.validate.length, 1);
    77
  • trunk/JSTests/wasm/js-api/web-assembly-instantiate.js

    r247445 r247457  
    33
    44assert.isFunction(WebAssembly.instantiate);
    5 assert.isFunction(WebAssembly.__proto__.instantiate);
     5assert.truthy(WebAssembly.hasOwnProperty('instantiate'));
    66assert.eq(WebAssembly.instantiate.length, 1);
    77
  • trunk/JSTests/wasm/spec-tests/jsapi.js

    r247445 r247457  
    231231    assert_equals(typeof moduleImportsDesc.value, "function");
    232232    assert_equals(moduleImportsDesc.writable, true);
    233     assert_equals(moduleImportsDesc.enumerable, false);
     233    assert_equals(moduleImportsDesc.enumerable, true);
    234234    assert_equals(moduleImportsDesc.configurable, true);
    235235}, "'WebAssembly.Module.imports' data property");
     
    266266    assert_equals(typeof moduleExportsDesc.value, "function");
    267267    assert_equals(moduleExportsDesc.writable, true);
    268     assert_equals(moduleExportsDesc.enumerable, false);
     268    assert_equals(moduleExportsDesc.enumerable, true);
    269269    assert_equals(moduleExportsDesc.configurable, true);
    270270}, "'WebAssembly.Module.exports' data property");
     
    297297    assert_equals(typeof customSectionsDesc.value, "function");
    298298    assert_equals(customSectionsDesc.writable, true);
    299     assert_equals(customSectionsDesc.enumerable, false);
     299    assert_equals(customSectionsDesc.enumerable, true);
    300300    assert_equals(customSectionsDesc.configurable, true);
    301301}, "'WebAssembly.Module.customSections' data property");
     
    308308    assertThrows(() => moduleCustomSections(undefined), TypeError);
    309309    assertThrows(() => moduleCustomSections({}), TypeError);
    310     var arr = moduleCustomSections(emptyModule);
     310    var arr = moduleCustomSections(emptyModule, undefined);
    311311    assert_equals(arr instanceof Array, true);
    312312    assert_equals(arr.length, 0);
     
    368368    assert_equals(typeof exportsDesc.get, "function");
    369369    assert_equals(exportsDesc.set, undefined);
    370     assert_equals(exportsDesc.enumerable, false);
     370    assert_equals(exportsDesc.enumerable, true);
    371371    assert_equals(exportsDesc.configurable, true);
    372372    const exportsGetter = exportsDesc.get;
     
    416416    assertThrows(() => new Memory(1), TypeError);
    417417    assertThrows(() => new Memory({initial:{valueOf() { throw new Error("here")}}}), Error);
    418     assertThrows(() => new Memory({initial:-1}), RangeError);
    419     assertThrows(() => new Memory({initial:Math.pow(2,32)}), RangeError);
     418    assertThrows(() => new Memory({initial:-1}), TypeError);
     419    assertThrows(() => new Memory({initial:Math.pow(2,32)}), TypeError);
    420420    assertThrows(() => new Memory({initial:1, maximum: Math.pow(2,32)/Math.pow(2,14) }), RangeError);
    421421    assertThrows(() => new Memory({initial:2, maximum:1 }), RangeError);
    422     assertThrows(() => new Memory({maximum: -1 }), RangeError);
     422    assertThrows(() => new Memory({maximum: -1 }), TypeError);
    423423    assert_equals(new Memory({initial:1}) instanceof Memory, true);
    424424    assert_equals(new Memory({initial:1.5}).buffer.byteLength, WasmPage);
     
    452452    assert_equals(typeof bufferDesc.get, "function");
    453453    assert_equals(bufferDesc.set, undefined);
    454     assert_equals(bufferDesc.enumerable, false);
     454    assert_equals(bufferDesc.enumerable, true);
    455455    assert_equals(bufferDesc.configurable, true);
    456456}, "'WebAssembly.Memory.prototype.buffer' accessor property");
     
    468468    const memGrowDesc = Object.getOwnPropertyDescriptor(memoryProto, 'grow');
    469469    assert_equals(typeof memGrowDesc.value, "function");
    470     assert_equals(memGrowDesc.enumerable, false);
     470    assert_equals(memGrowDesc.enumerable, true);
    471471    assert_equals(memGrowDesc.configurable, true);
    472472}, "'WebAssembly.Memory.prototype.grow' data property");
     
    478478    assertThrows(() => memGrow.call(), TypeError);
    479479    assertThrows(() => memGrow.call({}), TypeError);
    480     assertThrows(() => memGrow.call(mem1, -1), RangeError);
    481     assertThrows(() => memGrow.call(mem1, Math.pow(2,32)), RangeError);
     480    assertThrows(() => memGrow.call(mem1, -1), TypeError);
     481    assertThrows(() => memGrow.call(mem1, Math.pow(2,32)), TypeError);
    482482    var mem = new Memory({initial:1, maximum:2});
    483483    var buf = mem.buffer;
     
    517517    assertThrows(() => new Table({initial:1, element:{valueOf() { return "funcref" }}}), TypeError);
    518518    assertThrows(() => new Table({initial:{valueOf() { throw new Error("here")}}, element:"funcref"}), Error);
    519     assertThrows(() => new Table({initial:-1, element:"funcref"}), RangeError);
    520     assertThrows(() => new Table({initial:Math.pow(2,32), element:"funcref"}), RangeError);
     519    assertThrows(() => new Table({initial:-1, element:"funcref"}), TypeError);
     520    assertThrows(() => new Table({initial:Math.pow(2,32), element:"funcref"}), TypeError);
    521521    assertThrows(() => new Table({initial:2, maximum:1, element:"funcref"}), RangeError);
    522     assertThrows(() => new Table({initial:2, maximum:Math.pow(2,32), element:"funcref"}), RangeError);
     522    assertThrows(() => new Table({initial:2, maximum:Math.pow(2,32), element:"funcref"}), TypeError);
    523523    assert_equals(new Table({initial:1, element:"funcref"}) instanceof Table, true);
    524524    assert_equals(new Table({initial:1.5, element:"funcref"}) instanceof Table, true);
     
    554554    assert_equals(typeof lengthDesc.get, "function");
    555555    assert_equals(lengthDesc.set, undefined);
    556     assert_equals(lengthDesc.enumerable, false);
     556    assert_equals(lengthDesc.enumerable, true);
    557557    assert_equals(lengthDesc.configurable, true);
    558558}, "'WebAssembly.Table.prototype.length' accessor data property");
     
    571571    const getDesc = Object.getOwnPropertyDescriptor(tableProto, 'get');
    572572    assert_equals(typeof getDesc.value, "function");
    573     assert_equals(getDesc.enumerable, false);
     573    assert_equals(getDesc.enumerable, true);
    574574    assert_equals(getDesc.configurable, true);
    575575}, "'WebAssembly.Table.prototype.get' data property");
     
    586586    assertThrows(() => get.call(tbl1, 2), RangeError);
    587587    assertThrows(() => get.call(tbl1, 2.5), RangeError);
    588     assertThrows(() => get.call(tbl1, -1), RangeError);
    589     assertThrows(() => get.call(tbl1, Math.pow(2,33)), RangeError);
     588    assertThrows(() => get.call(tbl1, -1), TypeError);
     589    assertThrows(() => get.call(tbl1, Math.pow(2,33)), TypeError);
    590590    assertThrows(() => get.call(tbl1, {valueOf() { throw new Error("hi") }}), Error);
    591591}, "'WebAssembly.Table.prototype.get' method");
     
    594594    const setDesc = Object.getOwnPropertyDescriptor(tableProto, 'set');
    595595    assert_equals(typeof setDesc.value, "function");
    596     assert_equals(setDesc.enumerable, false);
     596    assert_equals(setDesc.enumerable, true);
    597597    assert_equals(setDesc.configurable, true);
    598598}, "'WebAssembly.Table.prototype.set' data property");
     
    606606    assertThrows(() => set.call(tbl1, 0), TypeError);
    607607    assertThrows(() => set.call(tbl1, 2, null), RangeError);
    608     assertThrows(() => set.call(tbl1, -1, null), RangeError);
    609     assertThrows(() => set.call(tbl1, Math.pow(2,33), null), RangeError);
     608    assertThrows(() => set.call(tbl1, -1, null), TypeError);
     609    assertThrows(() => set.call(tbl1, Math.pow(2,33), null), TypeError);
    610610    assertThrows(() => set.call(tbl1, 0, undefined), TypeError);
    611611    assertThrows(() => set.call(tbl1, 0, {}), TypeError);
     
    620620    const tblGrowDesc = Object.getOwnPropertyDescriptor(tableProto, 'grow');
    621621    assert_equals(typeof tblGrowDesc.value, "function");
    622     assert_equals(tblGrowDesc.enumerable, false);
     622    assert_equals(tblGrowDesc.enumerable, true);
    623623    assert_equals(tblGrowDesc.configurable, true);
    624624}, "'WebAssembly.Table.prototype.grow' data property");
     
    630630    assertThrows(() => tblGrow.call(), TypeError);
    631631    assertThrows(() => tblGrow.call({}), TypeError);
    632     assertThrows(() => tblGrow.call(tbl1, -1), RangeError);
    633     assertThrows(() => tblGrow.call(tbl1, Math.pow(2,32)), RangeError);
     632    assertThrows(() => tblGrow.call(tbl1, -1), TypeError);
     633    assertThrows(() => tblGrow.call(tbl1, Math.pow(2,32)), TypeError);
    634634    var tbl = new Table({element:"funcref", initial:1, maximum:2});
    635635    assert_equals(tbl.length, 1);
  • trunk/LayoutTests/ChangeLog

    r247445 r247457  
     12019-07-15  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Improve wasm wpt test results by fixing miscellaneous issues
     4        https://bugs.webkit.org/show_bug.cgi?id=199783
     5
     6        Reviewed by Mark Lam.
     7
     8        * platform/ios-simulator/TestExpectations:
     9        * platform/win/TestExpectations:
     10
    1112019-07-15  Michael Catanzaro  <mcatanzaro@igalia.com>
    212
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r247445 r247457  
     12019-07-15  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Improve wasm wpt test results by fixing miscellaneous issues
     4        https://bugs.webkit.org/show_bug.cgi?id=199783
     5
     6        Reviewed by Mark Lam.
     7
     8        Import web-platform-tests/wasm/jsapi. Some of tests are failing just because imported wpt tests are old.
     9        They are fixed in the upstream. When upgrading wpt tests, we can mark them PASS.
     10
     11        * resources/import-expectations.json:
     12        * web-platform-tests/wasm/jsapi/assertions.js: Added.
     13        (assert_function_name):
     14        (assert_function_length):
     15        * web-platform-tests/wasm/jsapi/bad-imports.js: Added.
     16        (test_bad_imports):
     17        * web-platform-tests/wasm/jsapi/constructor/instantiate-bad-imports.any-expected.txt: Added.
     18        * web-platform-tests/wasm/jsapi/constructor/instantiate-bad-imports.any.html: Added.
     19        * web-platform-tests/wasm/jsapi/constructor/instantiate-bad-imports.any.js: Added.
     20        (test_bad_imports):
     21        * web-platform-tests/wasm/jsapi/constructor/instantiate-bad-imports.any.worker-expected.txt: Added.
     22        * web-platform-tests/wasm/jsapi/constructor/instantiate-bad-imports.any.worker.html: Added.
     23        * web-platform-tests/wasm/jsapi/constructor/w3c-import.log: Added.
     24        * web-platform-tests/wasm/jsapi/global/constructor.any-expected.txt: Added.
     25        * web-platform-tests/wasm/jsapi/global/constructor.any.html: Added.
     26        * web-platform-tests/wasm/jsapi/global/constructor.any.js: Added.
     27        (assert_Global):
     28        (test):
     29        (test.get assert_array_equals):
     30        (string_appeared_here.test):
     31        (string_appeared_here.toString):
     32        (string_appeared_here.valueOf):
     33        (string_appeared_here.name.format_value):
     34        * web-platform-tests/wasm/jsapi/global/constructor.any.worker-expected.txt: Added.
     35        * web-platform-tests/wasm/jsapi/global/constructor.any.worker.html: Added.
     36        * web-platform-tests/wasm/jsapi/global/toString.any-expected.txt: Added.
     37        * web-platform-tests/wasm/jsapi/global/toString.any.html: Added.
     38        * web-platform-tests/wasm/jsapi/global/toString.any.js: Added.
     39        (test):
     40        * web-platform-tests/wasm/jsapi/global/toString.any.worker-expected.txt: Added.
     41        * web-platform-tests/wasm/jsapi/global/toString.any.worker.html: Added.
     42        * web-platform-tests/wasm/jsapi/global/value-set.any-expected.txt: Added.
     43        * web-platform-tests/wasm/jsapi/global/value-set.any.html: Added.
     44        * web-platform-tests/wasm/jsapi/global/value-set.any.js: Added.
     45        (test):
     46        (string_appeared_here.name.of.immutableOptions.test):
     47        (string_appeared_here.name.of.mutableOptions.test):
     48        * web-platform-tests/wasm/jsapi/global/value-set.any.worker-expected.txt: Added.
     49        * web-platform-tests/wasm/jsapi/global/value-set.any.worker.html: Added.
     50        * web-platform-tests/wasm/jsapi/global/valueOf.any-expected.txt: Added.
     51        * web-platform-tests/wasm/jsapi/global/valueOf.any.html: Added.
     52        * web-platform-tests/wasm/jsapi/global/valueOf.any.js: Added.
     53        (test):
     54        * web-platform-tests/wasm/jsapi/global/valueOf.any.worker-expected.txt: Added.
     55        * web-platform-tests/wasm/jsapi/global/valueOf.any.worker.html: Added.
     56        * web-platform-tests/wasm/jsapi/global/w3c-import.log: Added.
     57        * web-platform-tests/wasm/jsapi/instance/constructor-bad-imports.any-expected.txt: Added.
     58        * web-platform-tests/wasm/jsapi/instance/constructor-bad-imports.any.html: Added.
     59        * web-platform-tests/wasm/jsapi/instance/constructor-bad-imports.any.js: Added.
     60        (test_bad_imports):
     61        * web-platform-tests/wasm/jsapi/instance/constructor-bad-imports.any.worker-expected.txt: Added.
     62        * web-platform-tests/wasm/jsapi/instance/constructor-bad-imports.any.worker.html: Added.
     63        * web-platform-tests/wasm/jsapi/instance/constructor.any-expected.txt: Added.
     64        * web-platform-tests/wasm/jsapi/instance/constructor.any.html: Added.
     65        * web-platform-tests/wasm/jsapi/instance/constructor.any.js: Added.
     66        (assert_exported_function):
     67        * web-platform-tests/wasm/jsapi/instance/constructor.any.worker-expected.txt: Added.
     68        * web-platform-tests/wasm/jsapi/instance/constructor.any.worker.html: Added.
     69        * web-platform-tests/wasm/jsapi/instance/exports.any-expected.txt: Added.
     70        * web-platform-tests/wasm/jsapi/instance/exports.any.html: Added.
     71        * web-platform-tests/wasm/jsapi/instance/exports.any.js: Added.
     72        (setup):
     73        (test):
     74        * web-platform-tests/wasm/jsapi/instance/exports.any.worker-expected.txt: Added.
     75        * web-platform-tests/wasm/jsapi/instance/exports.any.worker.html: Added.
     76        * web-platform-tests/wasm/jsapi/instance/toString.any-expected.txt: Added.
     77        * web-platform-tests/wasm/jsapi/instance/toString.any.html: Added.
     78        * web-platform-tests/wasm/jsapi/instance/toString.any.js: Added.
     79        (test):
     80        * web-platform-tests/wasm/jsapi/instance/toString.any.worker-expected.txt: Added.
     81        * web-platform-tests/wasm/jsapi/instance/toString.any.worker.html: Added.
     82        * web-platform-tests/wasm/jsapi/instance/w3c-import.log: Added.
     83        * web-platform-tests/wasm/jsapi/interface.any-expected.txt: Added.
     84        * web-platform-tests/wasm/jsapi/interface.any.html: Added.
     85        * web-platform-tests/wasm/jsapi/interface.any.js: Added.
     86        (test_operations):
     87        (test):
     88        (const.name.of.interfaces.test):
     89        * web-platform-tests/wasm/jsapi/interface.any.worker-expected.txt: Added.
     90        * web-platform-tests/wasm/jsapi/interface.any.worker.html: Added.
     91        * web-platform-tests/wasm/jsapi/memory/buffer.any-expected.txt: Added.
     92        * web-platform-tests/wasm/jsapi/memory/buffer.any.html: Added.
     93        * web-platform-tests/wasm/jsapi/memory/buffer.any.js: Added.
     94        (test):
     95        * web-platform-tests/wasm/jsapi/memory/buffer.any.worker-expected.txt: Added.
     96        * web-platform-tests/wasm/jsapi/memory/buffer.any.worker.html: Added.
     97        * web-platform-tests/wasm/jsapi/memory/constructor.any-expected.txt: Added.
     98        * web-platform-tests/wasm/jsapi/memory/constructor.any.html: Added.
     99        * web-platform-tests/wasm/jsapi/memory/constructor.any.js: Added.
     100        (assert_Memory):
     101        (test):
     102        (const.value.of.outOfRangeValues.test):
     103        (test.get new):
     104        (test.get assert_array_equals):
     105        * web-platform-tests/wasm/jsapi/memory/constructor.any.worker-expected.txt: Added.
     106        * web-platform-tests/wasm/jsapi/memory/constructor.any.worker.html: Added.
     107        * web-platform-tests/wasm/jsapi/memory/grow.any-expected.txt: Added.
     108        * web-platform-tests/wasm/jsapi/memory/grow.any.html: Added.
     109        * web-platform-tests/wasm/jsapi/memory/grow.any.js: Added.
     110        (assert_ArrayBuffer):
     111        (test):
     112        (valueOf):
     113        (const.value.of.outOfRangeValues.test):
     114        * web-platform-tests/wasm/jsapi/memory/grow.any.worker-expected.txt: Added.
     115        * web-platform-tests/wasm/jsapi/memory/grow.any.worker.html: Added.
     116        * web-platform-tests/wasm/jsapi/memory/toString.any-expected.txt: Added.
     117        * web-platform-tests/wasm/jsapi/memory/toString.any.html: Added.
     118        * web-platform-tests/wasm/jsapi/memory/toString.any.js: Added.
     119        (test):
     120        * web-platform-tests/wasm/jsapi/memory/toString.any.worker-expected.txt: Added.
     121        * web-platform-tests/wasm/jsapi/memory/toString.any.worker.html: Added.
     122        * web-platform-tests/wasm/jsapi/memory/w3c-import.log: Added.
     123        * web-platform-tests/wasm/jsapi/module/constructor.any-expected.txt: Added.
     124        * web-platform-tests/wasm/jsapi/module/constructor.any.html: Added.
     125        * web-platform-tests/wasm/jsapi/module/constructor.any.js: Added.
     126        (setup):
     127        (test):
     128        * web-platform-tests/wasm/jsapi/module/constructor.any.worker-expected.txt: Added.
     129        * web-platform-tests/wasm/jsapi/module/constructor.any.worker.html: Added.
     130        * web-platform-tests/wasm/jsapi/module/customSections.any-expected.txt: Added.
     131        * web-platform-tests/wasm/jsapi/module/customSections.any.html: Added.
     132        * web-platform-tests/wasm/jsapi/module/customSections.any.js: Added.
     133        (assert_ArrayBuffer):
     134        (assert_sections):
     135        (setup):
     136        (test):
     137        * web-platform-tests/wasm/jsapi/module/customSections.any.worker-expected.txt: Added.
     138        * web-platform-tests/wasm/jsapi/module/customSections.any.worker.html: Added.
     139        * web-platform-tests/wasm/jsapi/module/exports.any-expected.txt: Added.
     140        * web-platform-tests/wasm/jsapi/module/exports.any.html: Added.
     141        * web-platform-tests/wasm/jsapi/module/exports.any.js: Added.
     142        (setup):
     143        (assert_ModuleExportDescriptor):
     144        (assert_exports):
     145        (test):
     146        * web-platform-tests/wasm/jsapi/module/exports.any.worker-expected.txt: Added.
     147        * web-platform-tests/wasm/jsapi/module/exports.any.worker.html: Added.
     148        * web-platform-tests/wasm/jsapi/module/imports.any-expected.txt: Added.
     149        * web-platform-tests/wasm/jsapi/module/imports.any.html: Added.
     150        * web-platform-tests/wasm/jsapi/module/imports.any.js: Added.
     151        (assert_ModuleImportDescriptor):
     152        (assert_imports):
     153        (setup):
     154        (test):
     155        * web-platform-tests/wasm/jsapi/module/imports.any.worker-expected.txt: Added.
     156        * web-platform-tests/wasm/jsapi/module/imports.any.worker.html: Added.
     157        * web-platform-tests/wasm/jsapi/module/toString.any-expected.txt: Added.
     158        * web-platform-tests/wasm/jsapi/module/toString.any.html: Added.
     159        * web-platform-tests/wasm/jsapi/module/toString.any.js: Added.
     160        (test):
     161        * web-platform-tests/wasm/jsapi/module/toString.any.worker-expected.txt: Added.
     162        * web-platform-tests/wasm/jsapi/module/toString.any.worker.html: Added.
     163        * web-platform-tests/wasm/jsapi/module/w3c-import.log: Added.
     164        * web-platform-tests/wasm/jsapi/table/assertions.js: Added.
     165        (assert_equal_to_array):
     166        * web-platform-tests/wasm/jsapi/table/constructor.any-expected.txt: Added.
     167        * web-platform-tests/wasm/jsapi/table/constructor.any.html: Added.
     168        * web-platform-tests/wasm/jsapi/table/constructor.any.js: Added.
     169        (assert_Table):
     170        (test):
     171        (const.value.of.outOfRangeValues.test):
     172        (test.get const):
     173        * web-platform-tests/wasm/jsapi/table/constructor.any.worker-expected.txt: Added.
     174        * web-platform-tests/wasm/jsapi/table/constructor.any.worker.html: Added.
     175        * web-platform-tests/wasm/jsapi/table/get-set.any-expected.txt: Added.
     176        * web-platform-tests/wasm/jsapi/table/get-set.any.html: Added.
     177        * web-platform-tests/wasm/jsapi/table/get-set.any.js: Added.
     178        (setup):
     179        (test):
     180        (test.set assert_equal_to_array):
     181        (test.const.fn):
     182        (valueOf):
     183        (const.value.of.outOfRangeValues.test):
     184        * web-platform-tests/wasm/jsapi/table/get-set.any.worker-expected.txt: Added.
     185        * web-platform-tests/wasm/jsapi/table/get-set.any.worker.html: Added.
     186        * web-platform-tests/wasm/jsapi/table/grow.any-expected.txt: Added.
     187        * web-platform-tests/wasm/jsapi/table/grow.any.html: Added.
     188        * web-platform-tests/wasm/jsapi/table/grow.any.js: Added.
     189        (nulls):
     190        (test):
     191        (valueOf):
     192        (const.value.of.outOfRangeValues.test):
     193        * web-platform-tests/wasm/jsapi/table/grow.any.worker-expected.txt: Added.
     194        * web-platform-tests/wasm/jsapi/table/grow.any.worker.html: Added.
     195        * web-platform-tests/wasm/jsapi/table/length.any-expected.txt: Added.
     196        * web-platform-tests/wasm/jsapi/table/length.any.html: Added.
     197        * web-platform-tests/wasm/jsapi/table/length.any.js: Added.
     198        (test):
     199        * web-platform-tests/wasm/jsapi/table/length.any.worker-expected.txt: Added.
     200        * web-platform-tests/wasm/jsapi/table/length.any.worker.html: Added.
     201        * web-platform-tests/wasm/jsapi/table/toString.any-expected.txt: Added.
     202        * web-platform-tests/wasm/jsapi/table/toString.any.html: Added.
     203        * web-platform-tests/wasm/jsapi/table/toString.any.js: Added.
     204        (test):
     205        * web-platform-tests/wasm/jsapi/table/toString.any.worker-expected.txt: Added.
     206        * web-platform-tests/wasm/jsapi/table/toString.any.worker.html: Added.
     207        * web-platform-tests/wasm/jsapi/table/w3c-import.log: Added.
     208        * web-platform-tests/wasm/jsapi/w3c-import.log: Added.
     209        * web-platform-tests/wasm/jsapi/wasm-constants.js: Added.
     210        (bytes):
     211        (bytesWithHeader):
     212        (makeSig):
     213        (makeSig_v_x):
     214        (makeSig_v_xx):
     215        (makeSig_r_v):
     216        (makeSig_r_x):
     217        (makeSig_r_xx):
     218        (assertTraps):
     219        (assertWasmThrows):
     220        * web-platform-tests/wasm/jsapi/wasm-module-builder.js: Added.
     221        (Binary.prototype.emit_u8):
     222        (Binary.prototype.emit_u16):
     223        (Binary.prototype.emit_u32):
     224        (Binary.prototype.emit_u32v):
     225        (Binary.prototype.emit_bytes):
     226        (Binary.prototype.emit_string):
     227        (Binary.prototype.emit_header):
     228        (Binary.prototype.emit_section):
     229        (Binary):
     230        (WasmFunctionBuilder):
     231        (WasmFunctionBuilder.prototype.exportAs):
     232        (WasmFunctionBuilder.prototype.exportFunc):
     233        (WasmFunctionBuilder.prototype.addBody):
     234        (WasmFunctionBuilder.prototype.addLocals):
     235        (WasmFunctionBuilder.prototype.end):
     236        (WasmGlobalBuilder):
     237        (WasmGlobalBuilder.prototype.exportAs):
     238        (WasmModuleBuilder):
     239        (WasmModuleBuilder.prototype.addStart):
     240        (WasmModuleBuilder.prototype.addMemory):
     241        (WasmModuleBuilder.prototype.addExplicitSection):
     242        (WasmModuleBuilder.prototype.addType):
     243        (WasmModuleBuilder.prototype.addGlobal):
     244        (WasmModuleBuilder.prototype.addFunction):
     245        (WasmModuleBuilder.prototype.addImport):
     246        (WasmModuleBuilder.prototype.addImportedGlobal):
     247        (WasmModuleBuilder.prototype.addImportedMemory):
     248        (WasmModuleBuilder.prototype.addImportedTable):
     249        (WasmModuleBuilder.prototype.addExport):
     250        (WasmModuleBuilder.prototype.addExportOfKind):
     251        (WasmModuleBuilder.prototype.addDataSegment):
     252        (WasmModuleBuilder.prototype.exportMemoryAs):
     253        (WasmModuleBuilder.prototype.addFunctionTableInit):
     254        (WasmModuleBuilder.prototype.appendToTable):
     255        (WasmModuleBuilder.prototype.setFunctionTableLength):
     256        (WasmModuleBuilder.prototype.toArray):
     257        (WasmModuleBuilder.prototype.toBuffer):
     258        (WasmModuleBuilder.prototype.instantiate):
     259
    12602019-07-15  Michael Catanzaro  <mcatanzaro@igalia.com>
    2261
  • trunk/LayoutTests/imported/w3c/resources/import-expectations.json

    r247445 r247457  
    344344    "web-platform-tests/wai-aria": "skip",
    345345    "web-platform-tests/wasm": "skip",
     346    "web-platform-tests/wasm/jsapi": "import",
    346347    "web-platform-tests/web-animations": "skip",
    347348    "web-platform-tests/web-nfc": "skip",
  • trunk/LayoutTests/platform/ios-simulator/TestExpectations

    r247445 r247457  
    124124webkit.org/b/195466 imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/ready-states/autoplay.html [ Pass Failure ]
    125125webkit.org/b/195466 imported/w3c/web-platform-tests/html/semantics/embedded-content/media-elements/error-codes/error.html [ Pass Failure ]
     126
     127imported/w3c/web-platform-tests/wasm [ Skip ]
  • trunk/LayoutTests/platform/win/TestExpectations

    r247445 r247457  
    44244424
    44254425webkit.org/b/198679 fast/events/fire-mousedown-while-pressing-mouse-button.html [ Failure ]
     4426
     4427imported/w3c/web-platform-tests/wasm [ Skip ]
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r247445 r247457  
    109109    wasm/js/WebAssemblyModuleConstructor.cpp
    110110    wasm/js/WebAssemblyModulePrototype.cpp
    111     wasm/js/WebAssemblyPrototype.cpp
    112111    wasm/js/WebAssemblyRuntimeErrorConstructor.cpp
    113112    wasm/js/WebAssemblyRuntimeErrorPrototype.cpp
     
    10121011    wasm/WasmTierUpCount.h
    10131012
     1013    wasm/js/JSWebAssembly.h
    10141014    wasm/js/JSWebAssemblyModule.h
    1015     wasm/js/WebAssemblyPrototype.h
    10161015
    10171016
     
    12211220    ${JAVASCRIPTCORE_DIR}/builtins/TypedArrayConstructor.js
    12221221    ${JAVASCRIPTCORE_DIR}/builtins/TypedArrayPrototype.js
    1223     ${JAVASCRIPTCORE_DIR}/builtins/WebAssemblyPrototype.js
     1222    ${JAVASCRIPTCORE_DIR}/builtins/WebAssembly.js
    12241223)
    12251224
  • trunk/Source/JavaScriptCore/ChangeLog

    r247445 r247457  
     12019-07-15  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Improve wasm wpt test results by fixing miscellaneous issues
     4        https://bugs.webkit.org/show_bug.cgi?id=199783
     5
     6        Reviewed by Mark Lam.
     7
     8        This patch fixes miscellaneous issues in our Wasm JS API implementation to improve WPT score.
     9        I picked trivial ones in this patch to make this easily reviewable.
     10
     11        1. Remove WebAssemblyPrototype. It does not exist in the spec. Merging WebAssemblyPrototype into JSWebAssembly.
     12        2. Fix various attributes. It does not match to the usual JSC builtin's convention. But this change
     13           is correct because they are changed to be matched against WebIDL definition, and WebAssembly implementation
     14           follows WebIDL. In the future, we could move WebCore WebIDL things into WTF layer and even use (or leverage
     15           some of utility functions) in our WebAssembly JS API implementation.
     16        3. Fix how we interpret "present" in WebAssembly spec. This does not mean [[HasProperty]] result. It follows to
     17           WebIDL spec, and it means that [[Get]] result is not undefined.
     18        4. Add argument count check to Module.customSections, which is required because the method is defined in WebIDL.
     19        5. Fix toNonWrappingUint32 to match it to WebIDL's conversion rule.
     20
     21        * CMakeLists.txt:
     22        * DerivedSources-input.xcfilelist:
     23        * DerivedSources-output.xcfilelist:
     24        * DerivedSources.make:
     25        * JavaScriptCore.xcodeproj/project.pbxproj:
     26        * Sources.txt:
     27        * builtins/WebAssembly.js: Renamed from Source/JavaScriptCore/builtins/WebAssemblyPrototype.js.
     28        * jit/Repatch.cpp:
     29        * runtime/JSGlobalObject.cpp:
     30        (JSC::JSGlobalObject::init):
     31        * runtime/JSModuleLoader.cpp:
     32        (JSC::moduleLoaderParseModule):
     33        * wasm/js/JSWebAssembly.cpp:
     34        (JSC::JSWebAssembly::create):
     35        (JSC::JSWebAssembly::finishCreation):
     36        (JSC::reject):
     37        (JSC::webAssemblyModuleValidateAsyncInternal):
     38        (JSC::webAssemblyCompileFunc):
     39        (JSC::resolve):
     40        (JSC::JSWebAssembly::webAssemblyModuleValidateAsync):
     41        (JSC::instantiate):
     42        (JSC::compileAndInstantiate):
     43        (JSC::JSWebAssembly::instantiate):
     44        (JSC::webAssemblyModuleInstantinateAsyncInternal):
     45        (JSC::JSWebAssembly::webAssemblyModuleInstantinateAsync):
     46        (JSC::webAssemblyInstantiateFunc):
     47        (JSC::webAssemblyValidateFunc):
     48        (JSC::webAssemblyCompileStreamingInternal):
     49        (JSC::webAssemblyInstantiateStreamingInternal):
     50        * wasm/js/JSWebAssembly.h:
     51        * wasm/js/JSWebAssemblyHelpers.h:
     52        (JSC::toNonWrappingUint32):
     53        * wasm/js/WebAssemblyCompileErrorConstructor.cpp:
     54        (JSC::WebAssemblyCompileErrorConstructor::finishCreation):
     55        * wasm/js/WebAssemblyInstanceConstructor.cpp:
     56        (JSC::WebAssemblyInstanceConstructor::finishCreation):
     57        * wasm/js/WebAssemblyInstancePrototype.cpp:
     58        * wasm/js/WebAssemblyLinkErrorConstructor.cpp:
     59        (JSC::WebAssemblyLinkErrorConstructor::finishCreation):
     60        * wasm/js/WebAssemblyMemoryConstructor.cpp:
     61        (JSC::constructJSWebAssemblyMemory):
     62        (JSC::WebAssemblyMemoryConstructor::finishCreation):
     63        * wasm/js/WebAssemblyMemoryPrototype.cpp:
     64        * wasm/js/WebAssemblyModuleConstructor.cpp:
     65        (JSC::webAssemblyModuleCustomSections):
     66        (JSC::WebAssemblyModuleConstructor::finishCreation):
     67        * wasm/js/WebAssemblyPrototype.cpp: Removed.
     68        * wasm/js/WebAssemblyPrototype.h: Removed.
     69        * wasm/js/WebAssemblyRuntimeErrorConstructor.cpp:
     70        (JSC::WebAssemblyRuntimeErrorConstructor::finishCreation):
     71        * wasm/js/WebAssemblyTableConstructor.cpp:
     72        (JSC::constructJSWebAssemblyTable):
     73        (JSC::WebAssemblyTableConstructor::finishCreation):
     74        * wasm/js/WebAssemblyTablePrototype.cpp:
     75
    1762019-07-15  Michael Catanzaro  <mcatanzaro@igalia.com>
    277
  • trunk/Source/JavaScriptCore/DerivedSources-input.xcfilelist

    r247445 r247457  
    5858$(PROJECT_DIR)/builtins/TypedArrayConstructor.js
    5959$(PROJECT_DIR)/builtins/TypedArrayPrototype.js
    60 $(PROJECT_DIR)/builtins/WebAssemblyPrototype.js
     60$(PROJECT_DIR)/builtins/WebAssembly.js
    6161$(PROJECT_DIR)/bytecode/BytecodeList.rb
    6262$(PROJECT_DIR)/create_hash_table
     
    184184$(PROJECT_DIR)/wasm/js/WebAssemblyModuleConstructor.cpp
    185185$(PROJECT_DIR)/wasm/js/WebAssemblyModulePrototype.cpp
    186 $(PROJECT_DIR)/wasm/js/WebAssemblyPrototype.cpp
    187186$(PROJECT_DIR)/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp
    188187$(PROJECT_DIR)/wasm/js/WebAssemblyRuntimeErrorPrototype.cpp
  • trunk/Source/JavaScriptCore/DerivedSources-output.xcfilelist

    r247445 r247457  
    7070$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/WebAssemblyModuleConstructor.lut.h
    7171$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/WebAssemblyModulePrototype.lut.h
    72 $(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/WebAssemblyPrototype.lut.h
    7372$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/WebAssemblyRuntimeErrorConstructor.lut.h
    7473$(BUILT_PRODUCTS_DIR)/DerivedSources/JavaScriptCore/WebAssemblyRuntimeErrorPrototype.lut.h
  • trunk/Source/JavaScriptCore/DerivedSources.make

    r247445 r247457  
    120120    $(JavaScriptCore)/builtins/TypedArrayConstructor.js \
    121121    $(JavaScriptCore)/builtins/TypedArrayPrototype.js \
    122     $(JavaScriptCore)/builtins/WebAssemblyPrototype.js \
     122    $(JavaScriptCore)/builtins/WebAssembly.js \
    123123#
    124124
     
    184184    WebAssemblyModuleConstructor.lut.h \
    185185    WebAssemblyModulePrototype.lut.h \
    186     WebAssemblyPrototype.lut.h \
    187186    WebAssemblyRuntimeErrorConstructor.lut.h \
    188187    WebAssemblyRuntimeErrorPrototype.lut.h \
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r247445 r247457  
    15741574                AD2FCC201DB59CB200B3E736 /* WebAssemblyTableConstructor.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = AD2FCC141DB59C5900B3E736 /* WebAssemblyTableConstructor.lut.h */; };
    15751575                AD2FCC211DB59CB200B3E736 /* WebAssemblyTablePrototype.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = AD2FCC151DB59C5900B3E736 /* WebAssemblyTablePrototype.lut.h */; };
    1576                 AD2FCC2D1DB838FD00B3E736 /* WebAssemblyPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = AD2FCC271DB838C400B3E736 /* WebAssemblyPrototype.h */; settings = {ATTRIBUTES = (Private, ); }; };
    15771576                AD412B341E7B2E9E008AF157 /* WasmContext.h in Headers */ = {isa = PBXBuildFile; fileRef = AD412B321E7B2E8A008AF157 /* WasmContext.h */; settings = {ATTRIBUTES = (Private, ); }; };
    15781577                AD4252511E5D0E14009D2A97 /* FullCodeOrigin.h in Headers */ = {isa = PBXBuildFile; fileRef = AD4252501E5D0DEB009D2A97 /* FullCodeOrigin.h */; };
     
    45134512                AD2FCC141DB59C5900B3E736 /* WebAssemblyTableConstructor.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAssemblyTableConstructor.lut.h; sourceTree = "<group>"; };
    45144513                AD2FCC151DB59C5900B3E736 /* WebAssemblyTablePrototype.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAssemblyTablePrototype.lut.h; sourceTree = "<group>"; };
    4515                 AD2FCC261DB838C400B3E736 /* WebAssemblyPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebAssemblyPrototype.cpp; path = js/WebAssemblyPrototype.cpp; sourceTree = "<group>"; };
    4516                 AD2FCC271DB838C400B3E736 /* WebAssemblyPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebAssemblyPrototype.h; path = js/WebAssemblyPrototype.h; sourceTree = "<group>"; };
    45174514                AD2FCC321DC4045300B3E736 /* WasmFormat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmFormat.cpp; sourceTree = "<group>"; };
    45184515                AD412B321E7B2E8A008AF157 /* WasmContext.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmContext.h; sourceTree = "<group>"; };
     
    48174814                E39DA4A41B7E8B7C0084F33A /* JSModuleRecord.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSModuleRecord.cpp; sourceTree = "<group>"; };
    48184815                E39DA4A51B7E8B7C0084F33A /* JSModuleRecord.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSModuleRecord.h; sourceTree = "<group>"; };
     4816                E39E030D22D9EA3E00408C18 /* WebAssembly.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = WebAssembly.js; sourceTree = "<group>"; };
    48194817                E39EEAF12281244C008474F4 /* ObjectToStringAdaptiveStructureWatchpoint.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ObjectToStringAdaptiveStructureWatchpoint.cpp; sourceTree = "<group>"; };
    48204818                E39EEAF22281244C008474F4 /* ObjectToStringAdaptiveStructureWatchpoint.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ObjectToStringAdaptiveStructureWatchpoint.h; sourceTree = "<group>"; };
     
    83618359                                534C457A1BC703DC007476A7 /* TypedArrayConstructor.js */,
    83628360                                53917E831B791CB8000EBD33 /* TypedArrayPrototype.js */,
     8361                                E39E030D22D9EA3E00408C18 /* WebAssembly.js */,
    83638362                        );
    83648363                        path = builtins;
     
    84238422                                AD4937C51DDCDCF00077C807 /* WebAssemblyModuleRecord.cpp */,
    84248423                                AD4937C61DDCDCF00077C807 /* WebAssemblyModuleRecord.h */,
    8425                                 AD2FCC261DB838C400B3E736 /* WebAssemblyPrototype.cpp */,
    8426                                 AD2FCC271DB838C400B3E736 /* WebAssemblyPrototype.h */,
    84278424                                AD2FCBBC1DB58DA400B3E736 /* WebAssemblyRuntimeErrorConstructor.cpp */,
    84288425                                AD2FCBBD1DB58DA400B3E736 /* WebAssemblyRuntimeErrorConstructor.h */,
     
    1006510062                                AD2FCC1D1DB59CB200B3E736 /* WebAssemblyModulePrototype.lut.h in Headers */,
    1006610063                                AD4937C81DDD0AAE0077C807 /* WebAssemblyModuleRecord.h in Headers */,
    10067                                 AD2FCC2D1DB838FD00B3E736 /* WebAssemblyPrototype.h in Headers */,
    1006810064                                AD2FCBF91DB58DAD00B3E736 /* WebAssemblyRuntimeErrorConstructor.h in Headers */,
    1006910065                                AD2FCC1E1DB59CB200B3E736 /* WebAssemblyRuntimeErrorConstructor.lut.h in Headers */,
  • trunk/Source/JavaScriptCore/Sources.txt

    r247445 r247457  
    10541054wasm/js/WebAssemblyModulePrototype.cpp
    10551055wasm/js/WebAssemblyModuleRecord.cpp
    1056 wasm/js/WebAssemblyPrototype.cpp
    10571056wasm/js/WebAssemblyRuntimeErrorConstructor.cpp
    10581057wasm/js/WebAssemblyRuntimeErrorPrototype.cpp
  • trunk/Source/JavaScriptCore/jit/Repatch.cpp

    r247445 r247457  
    5252#include "JSModuleNamespaceObject.h"
    5353#include "JSWebAssembly.h"
     54#include "JSWebAssemblyModule.h"
    5455#include "LinkBuffer.h"
    5556#include "ModuleNamespaceAccessCase.h"
     
    6364#include "SuperSampler.h"
    6465#include "ThunkGenerators.h"
     66#include "WebAssemblyFunction.h"
     67#include "WebAssemblyToJSCallee.h"
    6568#include <wtf/CommaPrinter.h>
    6669#include <wtf/ListDump.h>
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r247445 r247457  
    126126#include "JSWeakSet.h"
    127127#include "JSWebAssembly.h"
     128#include "JSWebAssemblyCompileError.h"
     129#include "JSWebAssemblyInstance.h"
     130#include "JSWebAssemblyLinkError.h"
     131#include "JSWebAssemblyMemory.h"
     132#include "JSWebAssemblyModule.h"
     133#include "JSWebAssemblyRuntimeError.h"
     134#include "JSWebAssemblyTable.h"
    128135#include "JSWithScope.h"
    129136#include "LazyClassStructureInlines.h"
     
    179186#include "WeakSetConstructor.h"
    180187#include "WeakSetPrototype.h"
    181 #include "WebAssemblyPrototype.h"
     188#include "WebAssemblyCompileErrorConstructor.h"
     189#include "WebAssemblyCompileErrorPrototype.h"
     190#include "WebAssemblyFunction.h"
     191#include "WebAssemblyInstanceConstructor.h"
     192#include "WebAssemblyInstancePrototype.h"
     193#include "WebAssemblyLinkErrorConstructor.h"
     194#include "WebAssemblyLinkErrorPrototype.h"
     195#include "WebAssemblyMemoryConstructor.h"
     196#include "WebAssemblyMemoryPrototype.h"
     197#include "WebAssemblyModuleConstructor.h"
     198#include "WebAssemblyModulePrototype.h"
     199#include "WebAssemblyModuleRecord.h"
     200#include "WebAssemblyRuntimeErrorConstructor.h"
     201#include "WebAssemblyRuntimeErrorPrototype.h"
     202#include "WebAssemblyTableConstructor.h"
     203#include "WebAssemblyTablePrototype.h"
    182204#include "WebAssemblyToJSCallee.h"
    183205#include <wtf/RandomNumber.h>
     
    10611083#if ENABLE(WEBASSEMBLY)
    10621084    if (Wasm::isSupported()) {
    1063         auto* webAssemblyPrototype = WebAssemblyPrototype::create(vm, this, WebAssemblyPrototype::createStructure(vm, this, m_objectPrototype.get()));
    10641085        m_webAssemblyModuleRecordStructure.initLater(
    10651086            [] (const Initializer<Structure>& init) {
     
    10821103                init.set(WebAssemblyToJSCallee::createStructure(init.vm, init.owner, jsNull()));
    10831104            });
    1084         auto* webAssembly = JSWebAssembly::create(vm, this, JSWebAssembly::createStructure(vm, this, webAssemblyPrototype));
     1105        auto* webAssembly = JSWebAssembly::create(vm, this, JSWebAssembly::createStructure(vm, this, m_objectPrototype.get()));
    10851106        putDirectWithoutTransition(vm, Identifier::fromString(exec, "WebAssembly"), webAssembly, static_cast<unsigned>(PropertyAttribute::DontEnum));
    10861107
  • trunk/Source/JavaScriptCore/runtime/JSModuleLoader.cpp

    r247445 r247457  
    4242#include "JSModuleRecord.h"
    4343#include "JSSourceCode.h"
     44#include "JSWebAssembly.h"
    4445#include "ModuleAnalyzer.h"
    4546#include "Nodes.h"
     
    4748#include "Parser.h"
    4849#include "ParserError.h"
    49 #include "WebAssemblyPrototype.h"
    5050
    5151namespace JSC {
     
    414414#if ENABLE(WEBASSEMBLY)
    415415    if (sourceCode.provider()->sourceType() == SourceProviderSourceType::WebAssembly)
    416         return JSValue::encode(WebAssemblyPrototype::instantiate(exec, deferred, moduleKey, jsSourceCode));
     416        return JSValue::encode(JSWebAssembly::instantiate(exec, deferred, moduleKey, jsSourceCode));
    417417#endif
    418418
  • trunk/Source/JavaScriptCore/wasm/js/JSWebAssembly.cpp

    r247445 r247457  
    2929#if ENABLE(WEBASSEMBLY)
    3030
     31#include "CatchScope.h"
     32#include "Exception.h"
     33#include "FunctionPrototype.h"
     34#include "JSCBuiltins.h"
    3135#include "JSCInlines.h"
     36#include "JSModuleNamespaceObject.h"
     37#include "JSPromiseDeferred.h"
     38#include "JSToWasm.h"
     39#include "JSWebAssemblyHelpers.h"
     40#include "JSWebAssemblyInstance.h"
     41#include "JSWebAssemblyModule.h"
     42#include "ObjectConstructor.h"
     43#include "Options.h"
     44#include "PromiseDeferredTimer.h"
     45#include "StrongInlines.h"
     46#include "ThrowScope.h"
     47#include "WasmBBQPlan.h"
     48#include "WasmToJS.h"
     49#include "WasmWorklist.h"
     50#include "WebAssemblyInstanceConstructor.h"
     51#include "WebAssemblyModuleConstructor.h"
     52
     53using JSC::Wasm::Plan;
     54using JSC::Wasm::BBQPlan;
    3255
    3356namespace JSC {
     
    4770#undef DEFINE_CALLBACK_FOR_CONSTRUCTOR
    4871
     72static EncodedJSValue JSC_HOST_CALL webAssemblyCompileFunc(ExecState*);
     73static EncodedJSValue JSC_HOST_CALL webAssemblyInstantiateFunc(ExecState*);
     74static EncodedJSValue JSC_HOST_CALL webAssemblyValidateFunc(ExecState*);
     75
    4976}
    5077
     
    5380namespace JSC {
    5481
    55 const ClassInfo JSWebAssembly::s_info = { "WebAssembly", &Base::s_info, &jsWebAssemblyTable, nullptr, CREATE_METHOD_TABLE(JSWebAssembly) };
     82const ClassInfo JSWebAssembly::s_info = { "WebAssembly", &Base::s_info, &webAssemblyTable, nullptr, CREATE_METHOD_TABLE(JSWebAssembly) };
    5683
    5784/* Source for JSWebAssembly.lut.h
    58 @begin jsWebAssemblyTable
     85@begin webAssemblyTable
    5986  CompileError    createWebAssemblyCompileError  DontEnum|PropertyCallback
    6087  Instance        createWebAssemblyInstance      DontEnum|PropertyCallback
     
    6491  RuntimeError    createWebAssemblyRuntimeError  DontEnum|PropertyCallback
    6592  Table           createWebAssemblyTable         DontEnum|PropertyCallback
     93  compile         webAssemblyCompileFunc         Function 1
     94  instantiate     webAssemblyInstantiateFunc     Function 1
     95  validate        webAssemblyValidateFunc        Function 1
    6696@end
    6797*/
    6898
    69 JSWebAssembly* JSWebAssembly::create(VM& vm, JSGlobalObject*, Structure* structure)
     99JSWebAssembly* JSWebAssembly::create(VM& vm, JSGlobalObject* globalObject, Structure* structure)
    70100{
    71101    auto* object = new (NotNull, allocateCell<JSWebAssembly>(vm.heap)) JSWebAssembly(vm, structure);
    72     object->finishCreation(vm);
     102    object->finishCreation(vm, globalObject);
    73103    return object;
    74104}
     
    79109}
    80110
    81 void JSWebAssembly::finishCreation(VM& vm)
     111void JSWebAssembly::finishCreation(VM& vm, JSGlobalObject* globalObject)
    82112{
    83113    Base::finishCreation(vm);
    84114    ASSERT(inherits(vm, info()));
     115    if (Options::useWebAssemblyStreamingApi()) {
     116        JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("compileStreaming", webAssemblyCompileStreamingCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
     117        JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION("instantiateStreaming", webAssemblyInstantiateStreamingCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum));
     118    }
    85119}
    86120
     
    90124}
    91125
     126static void reject(ExecState* exec, CatchScope& catchScope, JSPromiseDeferred* promise)
     127{
     128    Exception* exception = catchScope.exception();
     129    ASSERT(exception);
     130    catchScope.clearException();
     131    promise->reject(exec, exception->value());
     132    CLEAR_AND_RETURN_IF_EXCEPTION(catchScope, void());
     133}
     134
     135static void webAssemblyModuleValidateAsyncInternal(ExecState* exec, JSPromiseDeferred* promise, Vector<uint8_t>&& source)
     136{
     137    VM& vm = exec->vm();
     138    auto* globalObject = exec->lexicalGlobalObject();
     139
     140    Vector<Strong<JSCell>> dependencies;
     141    dependencies.append(Strong<JSCell>(vm, globalObject));
     142
     143    vm.promiseDeferredTimer->addPendingPromise(vm, promise, WTFMove(dependencies));
     144
     145    Wasm::Module::validateAsync(&vm.wasmContext, WTFMove(source), createSharedTask<Wasm::Module::CallbackType>([promise, globalObject, &vm] (Wasm::Module::ValidationResult&& result) mutable {
     146        vm.promiseDeferredTimer->scheduleWorkSoon(promise, [promise, globalObject, result = WTFMove(result), &vm] () mutable {
     147            auto scope = DECLARE_CATCH_SCOPE(vm);
     148            ExecState* exec = globalObject->globalExec();
     149            JSValue module = JSWebAssemblyModule::createStub(vm, exec, globalObject->webAssemblyModuleStructure(), WTFMove(result));
     150            if (UNLIKELY(scope.exception())) {
     151                reject(exec, scope, promise);
     152                return;
     153            }
     154
     155            promise->resolve(exec, module);
     156            CLEAR_AND_RETURN_IF_EXCEPTION(scope, void());
     157        });
     158    }));
     159}
     160
     161static EncodedJSValue JSC_HOST_CALL webAssemblyCompileFunc(ExecState* exec)
     162{
     163    VM& vm = exec->vm();
     164    auto throwScope = DECLARE_THROW_SCOPE(vm);
     165    auto* globalObject = exec->lexicalGlobalObject();
     166
     167    JSPromiseDeferred* promise = JSPromiseDeferred::tryCreate(exec, globalObject);
     168    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     169
     170    {
     171        auto catchScope = DECLARE_CATCH_SCOPE(vm);
     172        Vector<uint8_t> source = createSourceBufferFromValue(vm, exec, exec->argument(0));
     173
     174        if (UNLIKELY(catchScope.exception()))
     175            reject(exec, catchScope, promise);
     176        else
     177            webAssemblyModuleValidateAsyncInternal(exec, promise, WTFMove(source));
     178
     179        return JSValue::encode(promise->promise());
     180    }
     181}
     182
     183enum class Resolve { WithInstance, WithModuleRecord, WithModuleAndInstance };
     184static void resolve(VM& vm, ExecState* exec, JSPromiseDeferred* promise, JSWebAssemblyInstance* instance, JSWebAssemblyModule* module, JSObject* importObject, Ref<Wasm::CodeBlock>&& codeBlock, Resolve resolveKind, Wasm::CreationMode creationMode)
     185{
     186    auto scope = DECLARE_CATCH_SCOPE(vm);
     187    instance->finalizeCreation(vm, exec, WTFMove(codeBlock), importObject, creationMode);
     188    RETURN_IF_EXCEPTION(scope, reject(exec, scope, promise));
     189
     190    if (resolveKind == Resolve::WithInstance)
     191        promise->resolve(exec, instance);
     192    else if (resolveKind == Resolve::WithModuleRecord) {
     193        auto* moduleRecord = instance->moduleNamespaceObject()->moduleRecord();
     194        if (Options::dumpModuleRecord())
     195            moduleRecord->dump();
     196        promise->resolve(exec, moduleRecord);
     197    } else {
     198        JSObject* result = constructEmptyObject(exec);
     199        result->putDirect(vm, Identifier::fromString(&vm, "module"_s), module);
     200        result->putDirect(vm, Identifier::fromString(&vm, "instance"_s), instance);
     201        promise->resolve(exec, result);
     202    }
     203    CLEAR_AND_RETURN_IF_EXCEPTION(scope, void());
     204}
     205
     206void JSWebAssembly::webAssemblyModuleValidateAsync(ExecState* exec, JSPromiseDeferred* promise, Vector<uint8_t>&& source)
     207{
     208    VM& vm = exec->vm();
     209    auto catchScope = DECLARE_CATCH_SCOPE(vm);
     210    webAssemblyModuleValidateAsyncInternal(exec, promise, WTFMove(source));
     211    CLEAR_AND_RETURN_IF_EXCEPTION(catchScope, void());
     212}
     213
     214static void instantiate(VM& vm, ExecState* exec, JSPromiseDeferred* promise, JSWebAssemblyModule* module, JSObject* importObject, const Identifier& moduleKey, Resolve resolveKind, Wasm::CreationMode creationMode)
     215{
     216    auto scope = DECLARE_CATCH_SCOPE(vm);
     217    // In order to avoid potentially recompiling a module. We first gather all the import/memory information prior to compiling code.
     218    JSWebAssemblyInstance* instance = JSWebAssemblyInstance::create(vm, exec, moduleKey, module, importObject, exec->lexicalGlobalObject()->webAssemblyInstanceStructure(), Ref<Wasm::Module>(module->module()), creationMode);
     219    RETURN_IF_EXCEPTION(scope, reject(exec, scope, promise));
     220
     221    Vector<Strong<JSCell>> dependencies;
     222    // The instance keeps the module alive.
     223    dependencies.append(Strong<JSCell>(vm, instance));
     224    dependencies.append(Strong<JSCell>(vm, importObject));
     225    vm.promiseDeferredTimer->addPendingPromise(vm, promise, WTFMove(dependencies));
     226    // Note: This completion task may or may not get called immediately.
     227    module->module().compileAsync(&vm.wasmContext, instance->memoryMode(), createSharedTask<Wasm::CodeBlock::CallbackType>([promise, instance, module, importObject, resolveKind, creationMode, &vm] (Ref<Wasm::CodeBlock>&& refCodeBlock) mutable {
     228        RefPtr<Wasm::CodeBlock> codeBlock = WTFMove(refCodeBlock);
     229        vm.promiseDeferredTimer->scheduleWorkSoon(promise, [promise, instance, module, importObject, resolveKind, creationMode, &vm, codeBlock = WTFMove(codeBlock)] () mutable {
     230            ExecState* exec = instance->globalObject(vm)->globalExec();
     231            resolve(vm, exec, promise, instance, module, importObject, codeBlock.releaseNonNull(), resolveKind, creationMode);
     232        });
     233    }), &Wasm::createJSToWasmWrapper, &Wasm::wasmToJSException);
     234}
     235
     236static void compileAndInstantiate(VM& vm, ExecState* exec, JSPromiseDeferred* promise, const Identifier& moduleKey, JSValue buffer, JSObject* importObject, Resolve resolveKind, Wasm::CreationMode creationMode)
     237{
     238    auto scope = DECLARE_CATCH_SCOPE(vm);
     239
     240    auto* globalObject = exec->lexicalGlobalObject();
     241
     242    JSCell* moduleKeyCell = identifierToJSValue(vm, moduleKey).asCell();
     243    Vector<Strong<JSCell>> dependencies;
     244    dependencies.append(Strong<JSCell>(vm, importObject));
     245    dependencies.append(Strong<JSCell>(vm, moduleKeyCell));
     246    vm.promiseDeferredTimer->addPendingPromise(vm, promise, WTFMove(dependencies));
     247
     248    Vector<uint8_t> source = createSourceBufferFromValue(vm, exec, buffer);
     249    RETURN_IF_EXCEPTION(scope, reject(exec, scope, promise));
     250
     251    Wasm::Module::validateAsync(&vm.wasmContext, WTFMove(source), createSharedTask<Wasm::Module::CallbackType>([promise, importObject, moduleKeyCell, globalObject, resolveKind, creationMode, &vm] (Wasm::Module::ValidationResult&& result) mutable {
     252        vm.promiseDeferredTimer->scheduleWorkSoon(promise, [promise, importObject, moduleKeyCell, globalObject, result = WTFMove(result), resolveKind, creationMode, &vm] () mutable {
     253            auto scope = DECLARE_CATCH_SCOPE(vm);
     254            ExecState* exec = globalObject->globalExec();
     255            JSWebAssemblyModule* module = JSWebAssemblyModule::createStub(vm, exec, globalObject->webAssemblyModuleStructure(), WTFMove(result));
     256            if (UNLIKELY(scope.exception()))
     257                return reject(exec, scope, promise);
     258
     259            const Identifier moduleKey = JSValue(moduleKeyCell).toPropertyKey(exec);
     260            if (UNLIKELY(scope.exception()))
     261                return reject(exec, scope, promise);
     262
     263            instantiate(vm, exec, promise, module, importObject, moduleKey, resolveKind, creationMode);
     264        });
     265    }));
     266}
     267
     268JSValue JSWebAssembly::instantiate(ExecState* exec, JSPromiseDeferred* promise, const Identifier& moduleKey, JSValue argument)
     269{
     270    VM& vm = exec->vm();
     271    compileAndInstantiate(vm, exec, promise, moduleKey, argument, nullptr, Resolve::WithModuleRecord, Wasm::CreationMode::FromModuleLoader);
     272    return promise->promise();
     273}
     274
     275static void webAssemblyModuleInstantinateAsyncInternal(ExecState* exec, JSPromiseDeferred* promise, Vector<uint8_t>&& source, JSObject* importObject)
     276{
     277    auto* globalObject = exec->lexicalGlobalObject();
     278    VM& vm = exec->vm();
     279
     280    Vector<Strong<JSCell>> dependencies;
     281    dependencies.append(Strong<JSCell>(vm, importObject));
     282    dependencies.append(Strong<JSCell>(vm, globalObject));
     283    vm.promiseDeferredTimer->addPendingPromise(vm, promise, WTFMove(dependencies));
     284
     285    Wasm::Module::validateAsync(&vm.wasmContext, WTFMove(source), createSharedTask<Wasm::Module::CallbackType>([promise, importObject, globalObject, &vm] (Wasm::Module::ValidationResult&& result) mutable {
     286        vm.promiseDeferredTimer->scheduleWorkSoon(promise, [promise, importObject, globalObject, result = WTFMove(result), &vm] () mutable {
     287            auto scope = DECLARE_CATCH_SCOPE(vm);
     288            ExecState* exec = globalObject->globalExec();
     289            JSWebAssemblyModule* module = JSWebAssemblyModule::createStub(vm, exec, globalObject->webAssemblyModuleStructure(), WTFMove(result));
     290            if (UNLIKELY(scope.exception()))
     291                return reject(exec, scope, promise);
     292
     293            instantiate(vm, exec, promise, module, importObject, JSWebAssemblyInstance::createPrivateModuleKey(),  Resolve::WithModuleAndInstance, Wasm::CreationMode::FromJS);
     294            CLEAR_AND_RETURN_IF_EXCEPTION(scope, reject(exec, scope, promise));
     295        });
     296    }));
     297}
     298
     299void JSWebAssembly::webAssemblyModuleInstantinateAsync(ExecState* exec, JSPromiseDeferred* promise, Vector<uint8_t>&& source, JSObject* importedObject)
     300{
     301    VM& vm = exec->vm();
     302    auto catchScope = DECLARE_CATCH_SCOPE(vm);
     303    webAssemblyModuleInstantinateAsyncInternal(exec, promise, WTFMove(source), importedObject);
     304    CLEAR_AND_RETURN_IF_EXCEPTION(catchScope, void());
     305}
     306
     307static EncodedJSValue JSC_HOST_CALL webAssemblyInstantiateFunc(ExecState* exec)
     308{
     309    VM& vm = exec->vm();
     310    auto throwScope = DECLARE_THROW_SCOPE(vm);
     311    auto* globalObject = exec->lexicalGlobalObject();
     312
     313    JSPromiseDeferred* promise = JSPromiseDeferred::tryCreate(exec, globalObject);
     314    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     315
     316    {
     317        auto catchScope = DECLARE_CATCH_SCOPE(vm);
     318
     319        JSValue importArgument = exec->argument(1);
     320        JSObject* importObject = importArgument.getObject();
     321        if (UNLIKELY(!importArgument.isUndefined() && !importObject)) {
     322            promise->reject(exec, createTypeError(exec,
     323                "second argument to WebAssembly.instantiate must be undefined or an Object"_s, defaultSourceAppender, runtimeTypeForValue(vm, importArgument)));
     324            CLEAR_AND_RETURN_IF_EXCEPTION(catchScope, JSValue::encode(promise->promise()));
     325        } else {
     326            JSValue firstArgument = exec->argument(0);
     327            if (auto* module = jsDynamicCast<JSWebAssemblyModule*>(vm, firstArgument))
     328                instantiate(vm, exec, promise, module, importObject, JSWebAssemblyInstance::createPrivateModuleKey(), Resolve::WithInstance, Wasm::CreationMode::FromJS);
     329            else
     330                compileAndInstantiate(vm, exec, promise, JSWebAssemblyInstance::createPrivateModuleKey(), firstArgument, importObject, Resolve::WithModuleAndInstance, Wasm::CreationMode::FromJS);
     331        }
     332
     333        return JSValue::encode(promise->promise());
     334    }
     335}
     336
     337static EncodedJSValue JSC_HOST_CALL webAssemblyValidateFunc(ExecState* exec)
     338{
     339    VM& vm = exec->vm();
     340    auto scope = DECLARE_THROW_SCOPE(vm);
     341
     342    auto [base, byteSize] = getWasmBufferFromValue(exec, exec->argument(0));
     343    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     344    BBQPlan plan(&vm.wasmContext, BBQPlan::Validation, Plan::dontFinalize());
     345    // FIXME: We might want to throw an OOM exception here if we detect that something will OOM.
     346    // https://bugs.webkit.org/show_bug.cgi?id=166015
     347    return JSValue::encode(jsBoolean(plan.parseAndValidateModule(base, byteSize)));
     348}
     349
     350EncodedJSValue JSC_HOST_CALL webAssemblyCompileStreamingInternal(ExecState* exec)
     351{
     352    VM& vm = exec->vm();
     353    auto* globalObject = exec->lexicalGlobalObject();
     354    auto catchScope = DECLARE_CATCH_SCOPE(vm);
     355
     356    JSPromiseDeferred* promise = JSPromiseDeferred::tryCreate(exec, globalObject);
     357
     358    Vector<Strong<JSCell>> dependencies;
     359    dependencies.append(Strong<JSCell>(vm, globalObject));
     360    vm.promiseDeferredTimer->addPendingPromise(vm, promise, WTFMove(dependencies));
     361
     362    if (globalObject->globalObjectMethodTable()->compileStreaming)
     363        globalObject->globalObjectMethodTable()->compileStreaming(globalObject, exec, promise, exec->argument(0));
     364    else {
     365        // CompileStreaming is not supported in jsc, only in browser environment
     366        ASSERT_NOT_REACHED();
     367    }
     368
     369    CLEAR_AND_RETURN_IF_EXCEPTION(catchScope, JSValue::encode(promise->promise()));
     370
     371    return JSValue::encode(promise->promise());
     372}
     373
     374EncodedJSValue JSC_HOST_CALL webAssemblyInstantiateStreamingInternal(ExecState* exec)
     375{
     376    VM& vm = exec->vm();
     377    auto throwScope = DECLARE_THROW_SCOPE(vm);
     378    auto* globalObject = exec->lexicalGlobalObject();
     379
     380    JSPromiseDeferred* promise = JSPromiseDeferred::tryCreate(exec, globalObject);
     381    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     382    {
     383        auto catchScope = DECLARE_CATCH_SCOPE(vm);
     384
     385        JSValue importArgument = exec->argument(1);
     386        JSObject* importObject = importArgument.getObject();
     387        if (UNLIKELY(!importArgument.isUndefined() && !importObject)) {
     388            promise->reject(exec, createTypeError(exec,
     389                "second argument to WebAssembly.instantiateStreaming must be undefined or an Object"_s, defaultSourceAppender, runtimeTypeForValue(vm, importArgument)));
     390            CLEAR_AND_RETURN_IF_EXCEPTION(catchScope, JSValue::encode(promise->promise()));
     391        } else {
     392            if (globalObject->globalObjectMethodTable()->instantiateStreaming) {
     393                Vector<Strong<JSCell>> dependencies;
     394                dependencies.append(Strong<JSCell>(vm, globalObject));
     395                dependencies.append(Strong<JSCell>(vm, importObject));
     396                vm.promiseDeferredTimer->addPendingPromise(vm, promise, WTFMove(dependencies));
     397
     398                // FIXME: <http://webkit.org/b/184888> if there's an importObject and it contains a Memory, then we can compile the module with the right memory type (fast or not) by looking at the memory's type.
     399                globalObject->globalObjectMethodTable()->instantiateStreaming(globalObject, exec, promise, exec->argument(0), importObject);
     400            } else {
     401                // InstantiateStreaming is not supported in jsc, only in browser environment.
     402                ASSERT_NOT_REACHED();
     403            }
     404        }
     405        CLEAR_AND_RETURN_IF_EXCEPTION(catchScope, JSValue::encode(promise->promise()));
     406
     407        return JSValue::encode(promise->promise());
     408    }
     409}
     410
    92411} // namespace JSC
    93412
  • trunk/Source/JavaScriptCore/wasm/js/JSWebAssembly.h

    r247445 r247457  
    2929
    3030#include "JSObject.h"
    31 #include "JSWebAssemblyCompileError.h"
    32 #include "JSWebAssemblyInstance.h"
    33 #include "JSWebAssemblyLinkError.h"
    34 #include "JSWebAssemblyMemory.h"
    35 #include "JSWebAssemblyModule.h"
    36 #include "JSWebAssemblyRuntimeError.h"
    37 #include "JSWebAssemblyTable.h"
    38 #include "WebAssemblyCompileErrorConstructor.h"
    39 #include "WebAssemblyCompileErrorPrototype.h"
    40 #include "WebAssemblyFunction.h"
    41 #include "WebAssemblyInstanceConstructor.h"
    42 #include "WebAssemblyInstancePrototype.h"
    43 #include "WebAssemblyLinkErrorConstructor.h"
    44 #include "WebAssemblyLinkErrorPrototype.h"
    45 #include "WebAssemblyMemoryConstructor.h"
    46 #include "WebAssemblyMemoryPrototype.h"
    47 #include "WebAssemblyModuleConstructor.h"
    48 #include "WebAssemblyModulePrototype.h"
    49 #include "WebAssemblyModuleRecord.h"
    50 #include "WebAssemblyPrototype.h"
    51 #include "WebAssemblyRuntimeErrorConstructor.h"
    52 #include "WebAssemblyRuntimeErrorPrototype.h"
    53 #include "WebAssemblyTableConstructor.h"
    54 #include "WebAssemblyTablePrototype.h"
    55 #include "WebAssemblyToJSCallee.h"
     31#include "JSPromiseDeferred.h"
    5632
    5733namespace JSC {
     
    6743    DECLARE_INFO;
    6844
     45    JS_EXPORT_PRIVATE static void webAssemblyModuleValidateAsync(ExecState*, JSPromiseDeferred*, Vector<uint8_t>&&);
     46    JS_EXPORT_PRIVATE static void webAssemblyModuleInstantinateAsync(ExecState*, JSPromiseDeferred*, Vector<uint8_t>&&, JSObject*);
     47    static JSValue instantiate(ExecState*, JSPromiseDeferred*, const Identifier&, JSValue);
     48
    6949protected:
    70     void finishCreation(VM&);
     50    void finishCreation(VM&, JSGlobalObject*);
    7151
    7252private:
     
    7454};
    7555
     56EncodedJSValue JSC_HOST_CALL webAssemblyCompileStreamingInternal(ExecState*);
     57EncodedJSValue JSC_HOST_CALL webAssemblyInstantiateStreamingInternal(ExecState*);
     58
    7659} // namespace JSC
    7760
  • trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyHelpers.h

    r247445 r247457  
    4040    VM& vm = exec->vm();
    4141    auto throwScope = DECLARE_THROW_SCOPE(vm);
    42     double doubleValue = value.toInteger(exec);
     42
     43    if (value.isUInt32())
     44        return value.asUInt32();
     45
     46    double doubleValue = value.toNumber(exec);
    4347    RETURN_IF_EXCEPTION(throwScope, { });
    44     if (doubleValue < 0 || doubleValue > UINT_MAX) {
    45         throwException(exec, throwScope,
    46             createRangeError(exec, "Expect an integer argument in the range: [0, 2^32 - 1]"_s));
    47         return { };
     48
     49    if (!std::isnan(doubleValue) && !std::isinf(doubleValue)) {
     50        double truncedValue = trunc(doubleValue);
     51        if (truncedValue >= 0 && truncedValue <= UINT_MAX)
     52            return static_cast<uint32_t>(truncedValue);
    4853    }
    4954
    50     return static_cast<uint32_t>(doubleValue);
     55    throwException(exec, throwScope, createTypeError(exec, "Expect an integer argument in the range: [0, 2^32 - 1]"_s));
     56    return { };
    5157}
    5258
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.cpp

    r247445 r247457  
    7878    Base::finishCreation(vm, "CompileError"_s, NameVisibility::Visible, NameAdditionMode::WithoutStructureTransition);
    7979    putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete);
    80     putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete);
     80    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum);
    8181}
    8282
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp

    r247445 r247457  
    109109    Base::finishCreation(vm, "Instance"_s, NameVisibility::Visible, NameAdditionMode::WithoutStructureTransition);
    110110    putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
    111     putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete);
     111    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum);
    112112}
    113113
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstancePrototype.cpp

    r247445 r247457  
    4646/* Source for WebAssemblyInstancePrototype.lut.h
    4747 @begin prototypeTableWebAssemblyInstance
    48  exports webAssemblyInstanceProtoFuncExports DontEnum|Accessor 0
     48 exports webAssemblyInstanceProtoFuncExports Accessor 0
    4949 @end
    5050 */
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyLinkErrorConstructor.cpp

    r247445 r247457  
    7878    Base::finishCreation(vm, "LinkError"_s, NameVisibility::Visible, NameAdditionMode::WithoutStructureTransition);
    7979    putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete);
    80     putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete);
     80    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum);
    8181}
    8282
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.cpp

    r247445 r247457  
    8080    Wasm::PageCount maximumPageCount;
    8181    {
     82        // In WebIDL, "present" means that [[Get]] result is undefined, not [[HasProperty]] result.
     83        // https://heycam.github.io/webidl/#idl-dictionaries
    8284        Identifier maximum = Identifier::fromString(&vm, "maximum");
    83         bool hasProperty = memoryDescriptor->hasProperty(exec, maximum);
     85        JSValue maxSizeValue = memoryDescriptor->get(exec, maximum);
    8486        RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    85         if (hasProperty) {
    86             JSValue maxSizeValue = memoryDescriptor->get(exec, maximum);
    87             RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     87        if (!maxSizeValue.isUndefined()) {
    8888            uint32_t size = toNonWrappingUint32(exec, maxSizeValue);
    8989            RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     
    137137    Base::finishCreation(vm, "Memory"_s, NameVisibility::Visible, NameAdditionMode::WithoutStructureTransition);
    138138    putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
    139     putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete);
     139    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum);
    140140}
    141141
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryPrototype.cpp

    r247445 r247457  
    4949/* Source for WebAssemblyMemoryPrototype.lut.h
    5050@begin prototypeTableWebAssemblyMemory
    51  grow   webAssemblyMemoryProtoFuncGrow   DontEnum|Function 1
    52  buffer webAssemblyMemoryProtoFuncBuffer DontEnum|Accessor 0
     51 grow   webAssemblyMemoryProtoFuncGrow   Function 1
     52 buffer webAssemblyMemoryProtoFuncBuffer Accessor 0
    5353@end
    5454*/
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp

    r247445 r247457  
    6060/* Source for WebAssemblyModuleConstructor.lut.h
    6161 @begin constructorTableWebAssemblyModule
    62  customSections webAssemblyModuleCustomSections DontEnum|Function 2
    63  imports        webAssemblyModuleImports        DontEnum|Function 1
    64  exports        webAssemblyModuleExports        DontEnum|Function 1
     62 customSections webAssemblyModuleCustomSections Function 2
     63 imports        webAssemblyModuleImports        Function 1
     64 exports        webAssemblyModuleExports        Function 1
    6565 @end
    6666 */
     
    7272    auto throwScope = DECLARE_THROW_SCOPE(vm);
    7373
    74     JSWebAssemblyModule* module = jsDynamicCast<JSWebAssemblyModule*>(vm, exec->argument(0));
     74    if (UNLIKELY(exec->argumentCount() < 2))
     75        return JSValue::encode(throwException(exec, throwScope, createNotEnoughArgumentsError(exec)));
     76
     77    JSWebAssemblyModule* module = jsDynamicCast<JSWebAssemblyModule*>(vm, exec->uncheckedArgument(0));
    7578    if (!module)
    7679        return JSValue::encode(throwException(exec, throwScope, createTypeError(exec, "WebAssembly.Module.customSections called with non WebAssembly.Module argument"_s)));
    7780
    78     const String sectionNameString = exec->argument(1).getString(exec);
     81    const String sectionNameString = exec->uncheckedArgument(1).getString(exec);
    7982    RETURN_IF_EXCEPTION(throwScope, { });
    8083
     
    204207    Base::finishCreation(vm, "Module"_s, NameVisibility::Visible, NameAdditionMode::WithoutStructureTransition);
    205208    putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
    206     putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete);
     209    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum);
    207210}
    208211
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp

    r247445 r247457  
    8080    Base::finishCreation(vm, "RuntimeError"_s, NameVisibility::Visible, NameAdditionMode::WithoutStructureTransition);
    8181    putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete);
    82     putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete);
     82    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum);
    8383}
    8484
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.cpp

    r247445 r247457  
    8080    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    8181
     82    // In WebIDL, "present" means that [[Get]] result is undefined, not [[HasProperty]] result.
     83    // https://heycam.github.io/webidl/#idl-dictionaries
    8284    Optional<uint32_t> maximum;
    8385    Identifier maximumIdent = Identifier::fromString(&vm, "maximum");
    84     bool hasProperty = memoryDescriptor->hasProperty(exec, maximumIdent);
     86    JSValue maxSizeValue = memoryDescriptor->get(exec, maximumIdent);
    8587    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    86     if (hasProperty) {
    87         JSValue maxSizeValue = memoryDescriptor->get(exec, maximumIdent);
    88         RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     88    if (!maxSizeValue.isUndefined()) {
    8989        maximum = toNonWrappingUint32(exec, maxSizeValue);
    9090        RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     
    128128    Base::finishCreation(vm, "Table"_s, NameVisibility::Visible, NameAdditionMode::WithoutStructureTransition);
    129129    putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, PropertyAttribute::DontEnum | PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly);
    130     putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum | PropertyAttribute::DontDelete);
     130    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), PropertyAttribute::ReadOnly | PropertyAttribute::DontEnum);
    131131}
    132132
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTablePrototype.cpp

    r247445 r247457  
    4949/* Source for WebAssemblyTablePrototype.lut.h
    5050 @begin prototypeTableWebAssemblyTable
    51  length webAssemblyTableProtoFuncLength DontEnum|Accessor 0
    52  grow   webAssemblyTableProtoFuncGrow   DontEnum|Function 1
    53  get    webAssemblyTableProtoFuncGet    DontEnum|Function 1
    54  set    webAssemblyTableProtoFuncSet    DontEnum|Function 2
     51 length webAssemblyTableProtoFuncLength Accessor 0
     52 grow   webAssemblyTableProtoFuncGrow   Function 1
     53 get    webAssemblyTableProtoFuncGet    Function 1
     54 set    webAssemblyTableProtoFuncSet    Function 2
    5555 @end
    5656 */
  • trunk/Source/WebCore/ChangeLog

    r247453 r247457  
     12019-07-15  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Improve wasm wpt test results by fixing miscellaneous issues
     4        https://bugs.webkit.org/show_bug.cgi?id=199783
     5
     6        Reviewed by Mark Lam.
     7
     8        Remove WebAssemblyPrototype.
     9
     10        Tests: imported/w3c/web-platform-tests/wasm/jsapi/constructor/instantiate-bad-imports.any.html
     11               imported/w3c/web-platform-tests/wasm/jsapi/constructor/instantiate-bad-imports.any.worker.html
     12               imported/w3c/web-platform-tests/wasm/jsapi/global/constructor.any.html
     13               imported/w3c/web-platform-tests/wasm/jsapi/global/constructor.any.worker.html
     14               imported/w3c/web-platform-tests/wasm/jsapi/global/toString.any.html
     15               imported/w3c/web-platform-tests/wasm/jsapi/global/toString.any.worker.html
     16               imported/w3c/web-platform-tests/wasm/jsapi/global/value-set.any.html
     17               imported/w3c/web-platform-tests/wasm/jsapi/global/value-set.any.worker.html
     18               imported/w3c/web-platform-tests/wasm/jsapi/global/valueOf.any.html
     19               imported/w3c/web-platform-tests/wasm/jsapi/global/valueOf.any.worker.html
     20               imported/w3c/web-platform-tests/wasm/jsapi/instance/constructor-bad-imports.any.html
     21               imported/w3c/web-platform-tests/wasm/jsapi/instance/constructor-bad-imports.any.worker.html
     22               imported/w3c/web-platform-tests/wasm/jsapi/instance/constructor.any.html
     23               imported/w3c/web-platform-tests/wasm/jsapi/instance/constructor.any.worker.html
     24               imported/w3c/web-platform-tests/wasm/jsapi/instance/exports.any.html
     25               imported/w3c/web-platform-tests/wasm/jsapi/instance/exports.any.worker.html
     26               imported/w3c/web-platform-tests/wasm/jsapi/instance/toString.any.html
     27               imported/w3c/web-platform-tests/wasm/jsapi/instance/toString.any.worker.html
     28               imported/w3c/web-platform-tests/wasm/jsapi/interface.any.html
     29               imported/w3c/web-platform-tests/wasm/jsapi/interface.any.worker.html
     30               imported/w3c/web-platform-tests/wasm/jsapi/memory/buffer.any.html
     31               imported/w3c/web-platform-tests/wasm/jsapi/memory/buffer.any.worker.html
     32               imported/w3c/web-platform-tests/wasm/jsapi/memory/constructor.any.html
     33               imported/w3c/web-platform-tests/wasm/jsapi/memory/constructor.any.worker.html
     34               imported/w3c/web-platform-tests/wasm/jsapi/memory/grow.any.html
     35               imported/w3c/web-platform-tests/wasm/jsapi/memory/grow.any.worker.html
     36               imported/w3c/web-platform-tests/wasm/jsapi/memory/toString.any.html
     37               imported/w3c/web-platform-tests/wasm/jsapi/memory/toString.any.worker.html
     38               imported/w3c/web-platform-tests/wasm/jsapi/module/constructor.any.html
     39               imported/w3c/web-platform-tests/wasm/jsapi/module/constructor.any.worker.html
     40               imported/w3c/web-platform-tests/wasm/jsapi/module/customSections.any.html
     41               imported/w3c/web-platform-tests/wasm/jsapi/module/customSections.any.worker.html
     42               imported/w3c/web-platform-tests/wasm/jsapi/module/exports.any.html
     43               imported/w3c/web-platform-tests/wasm/jsapi/module/exports.any.worker.html
     44               imported/w3c/web-platform-tests/wasm/jsapi/module/imports.any.html
     45               imported/w3c/web-platform-tests/wasm/jsapi/module/imports.any.worker.html
     46               imported/w3c/web-platform-tests/wasm/jsapi/module/toString.any.html
     47               imported/w3c/web-platform-tests/wasm/jsapi/module/toString.any.worker.html
     48               imported/w3c/web-platform-tests/wasm/jsapi/table/constructor.any.html
     49               imported/w3c/web-platform-tests/wasm/jsapi/table/constructor.any.worker.html
     50               imported/w3c/web-platform-tests/wasm/jsapi/table/get-set.any.html
     51               imported/w3c/web-platform-tests/wasm/jsapi/table/get-set.any.worker.html
     52               imported/w3c/web-platform-tests/wasm/jsapi/table/grow.any.html
     53               imported/w3c/web-platform-tests/wasm/jsapi/table/grow.any.worker.html
     54               imported/w3c/web-platform-tests/wasm/jsapi/table/length.any.html
     55               imported/w3c/web-platform-tests/wasm/jsapi/table/length.any.worker.html
     56               imported/w3c/web-platform-tests/wasm/jsapi/table/toString.any.html
     57               imported/w3c/web-platform-tests/wasm/jsapi/table/toString.any.worker.html
     58
     59        * bindings/js/JSDOMWindowBase.cpp:
     60        (WebCore::JSDOMWindowBase::compileStreaming):
     61        (WebCore::JSDOMWindowBase::instantiateStreaming):
     62
    1632019-07-15  Dean Jackson  <dino@apple.com>
    264
  • trunk/Source/WebCore/bindings/js/JSDOMWindowBase.cpp

    r247445 r247457  
    5151#include <JavaScriptCore/JSInternalPromise.h>
    5252#include <JavaScriptCore/JSInternalPromiseDeferred.h>
     53#include <JavaScriptCore/JSWebAssembly.h>
    5354#include <JavaScriptCore/Microtask.h>
    5455#include <JavaScriptCore/PromiseDeferredTimer.h>
    5556#include <JavaScriptCore/StrongInlines.h>
    56 #include <JavaScriptCore/WebAssemblyPrototype.h>
    5757#include <wtf/Language.h>
    5858#include <wtf/MainThread.h>
     
    447447        handleResponseOnStreamingAction(globalObject, exec, inputResponse, promise, [promise] (JSC::ExecState* exec, const char* data, size_t byteSize) mutable {
    448448            if (auto arrayBuffer = tryAllocate(exec, promise, data, byteSize))
    449                 JSC::WebAssemblyPrototype::webAssemblyModuleValidateAsync(exec, promise, WTFMove(*arrayBuffer));
     449                JSC::JSWebAssembly::webAssemblyModuleValidateAsync(exec, promise, WTFMove(*arrayBuffer));
    450450        });
    451451    } else
     
    466466        handleResponseOnStreamingAction(globalObject, exec, inputResponse, promise, [promise, importedObject] (JSC::ExecState* exec, const char* data, size_t byteSize) mutable {
    467467            if (auto arrayBuffer = tryAllocate(exec, promise, data, byteSize))
    468                 JSC::WebAssemblyPrototype::webAssemblyModuleInstantinateAsync(exec, promise, WTFMove(*arrayBuffer), importedObject);
     468                JSC::JSWebAssembly::webAssemblyModuleInstantinateAsync(exec, promise, WTFMove(*arrayBuffer), importedObject);
    469469        });
    470470    } else
Note: See TracChangeset for help on using the changeset viewer.