WebAssembly API: implement exception constructors properly
authorjfbastien@apple.com <jfbastien@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Oct 2016 01:19:24 +0000 (01:19 +0000)
committerjfbastien@apple.com <jfbastien@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 21 Oct 2016 01:19:24 +0000 (01:19 +0000)
commit50ce04c8d745194324b26f4143f27dde018b1c5a
treeb83712e6b0836c44b00b775f426494186eeaa63f
parent0617ec58d77116cd0f37b4029c61b0aedef548cf
WebAssembly API: implement exception constructors properly

 - Rename WebAssemblyObject to JSWebAssembly for consistency.
 - WebAssembly object now has its own prototype: add WebAssemblyPrototype, and
   use it to register JSWebAssembly's function properties through auto-generated
   .lut.h, instead of manually.
 - The error constructors used to throw (e.g. `new WebAssembly.CompileError()`).
 - Register WebAssembly's constructors from the global object, and hold a
   reference to their structure and prototype so that invoking the constructor
   can use the structure directly from the global object.
 - Add a prototype base field to global object creation. Previous ones all had
   Object's prototype as their base, but WebAssembly's error constructors have
   Error as their base.
 - Test for the error object's correctness.
 - Add missing #if ENABLE(WEBASSEMBLY)

WebAssembly API: implement exception constructors properly
https://bugs.webkit.org/show_bug.cgi?id=163699

Reviewed by Keith Miller.

JSTests:

* wasm/js-api/test_basic_api.js:
(const.c.in.constructorProperties): more tests

Source/JavaScriptCore:

* CMakeLists.txt: rename WebAssemblyObject -> JSWebAssembly; add a .lut.h file
* DerivedSources.make: new .lut.h file
* JavaScriptCore.xcodeproj/project.pbxproj: ditto
* runtime/JSGlobalObject.cpp: new prototypeBase macro
(JSC::JSGlobalObject::init): register WebAssembly constructors here
(JSC::JSGlobalObject::visitChildren): use the macro to visit
* runtime/JSGlobalObject.h: declare the WebAssembly constructor macro
* wasm/JSWebAssembly.cpp: Copied from Source/JavaScriptCore/wasm/WebAssemblyObject.h.
(JSC::JSWebAssembly::create):
(JSC::JSWebAssembly::createStructure):
(JSC::JSWebAssembly::finishCreation):
(JSC::JSWebAssembly::JSWebAssembly):
* wasm/JSWebAssembly.h: Renamed from Source/JavaScriptCore/wasm/WebAssemblyObject.h.
* wasm/WebAssemblyObject.cpp: Removed.
* wasm/js/JSWebAssemblyCompileError.cpp:
* wasm/js/JSWebAssemblyCompileError.h:
(JSC::JSWebAssemblyCompileError::create): string convenience
* wasm/js/JSWebAssemblyInstance.cpp:
* wasm/js/JSWebAssemblyInstance.h:
* wasm/js/JSWebAssemblyMemory.cpp:
* wasm/js/JSWebAssemblyMemory.h:
* wasm/js/JSWebAssemblyModule.cpp:
* wasm/js/JSWebAssemblyModule.h:
* wasm/js/JSWebAssemblyRuntimeError.cpp:
* wasm/js/JSWebAssemblyRuntimeError.h:
(JSC::JSWebAssemblyRuntimeError::create): string convenience
* wasm/js/JSWebAssemblyTable.cpp:
* wasm/js/JSWebAssemblyTable.h:
* wasm/js/WebAssemblyCompileErrorConstructor.cpp:
(JSC::constructJSWebAssemblyCompileError):don't throw, create the object
(JSC::WebAssemblyCompileErrorConstructor::finishCreation):no need for the structure, it's on the global object
* wasm/js/WebAssemblyCompileErrorConstructor.h:
* wasm/js/WebAssemblyCompileErrorPrototype.cpp:
* wasm/js/WebAssemblyCompileErrorPrototype.h:
* wasm/js/WebAssemblyInstanceConstructor.cpp:
* wasm/js/WebAssemblyInstanceConstructor.h:
* wasm/js/WebAssemblyInstancePrototype.cpp:
* wasm/js/WebAssemblyInstancePrototype.h:
* wasm/js/WebAssemblyMemoryConstructor.cpp:
* wasm/js/WebAssemblyMemoryConstructor.h:
* wasm/js/WebAssemblyMemoryPrototype.cpp:
* wasm/js/WebAssemblyMemoryPrototype.h:
* wasm/js/WebAssemblyModuleConstructor.cpp:
* wasm/js/WebAssemblyModuleConstructor.h:
* wasm/js/WebAssemblyModulePrototype.cpp:
* wasm/js/WebAssemblyModulePrototype.h:
* wasm/js/WebAssemblyPrototype.cpp: Copied from Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorPrototype.cpp.
(JSC::webAssemblyFunctionValidate):
(JSC::webAssemblyFunctionCompile):
(JSC::WebAssemblyPrototype::create):
(JSC::WebAssemblyPrototype::createStructure):
(JSC::WebAssemblyPrototype::finishCreation):
(JSC::WebAssemblyPrototype::WebAssemblyPrototype):
* wasm/js/WebAssemblyPrototype.h: Copied from Source/JavaScriptCore/wasm/js/WebAssemblyMemoryPrototype.h.
* wasm/js/WebAssemblyRuntimeErrorConstructor.cpp:
(JSC::constructJSWebAssemblyRuntimeError):don't throw, create the object
(JSC::WebAssemblyRuntimeErrorConstructor::finishCreation):no need for the structure, it's on the global object
* wasm/js/WebAssemblyRuntimeErrorConstructor.h:
* wasm/js/WebAssemblyRuntimeErrorPrototype.cpp:
* wasm/js/WebAssemblyRuntimeErrorPrototype.h:
* wasm/js/WebAssemblyTableConstructor.cpp:
* wasm/js/WebAssemblyTableConstructor.h:
* wasm/js/WebAssemblyTablePrototype.cpp:
* wasm/js/WebAssemblyTablePrototype.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@207650 268f45cc-cd09-0410-ab3c-d52691b4dbfc
49 files changed:
JSTests/ChangeLog
JSTests/wasm/js-api/test_basic_api.js
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/DerivedSources.make
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/runtime/JSGlobalObject.cpp
Source/JavaScriptCore/runtime/JSGlobalObject.h
Source/JavaScriptCore/wasm/JSWebAssembly.cpp [new file with mode: 0644]
Source/JavaScriptCore/wasm/JSWebAssembly.h [new file with mode: 0644]
Source/JavaScriptCore/wasm/WebAssemblyObject.cpp [deleted file]
Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp
Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.h
Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.cpp
Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h
Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.cpp
Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.h
Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.cpp
Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.h
Source/JavaScriptCore/wasm/js/JSWebAssemblyRuntimeError.cpp
Source/JavaScriptCore/wasm/js/JSWebAssemblyRuntimeError.h
Source/JavaScriptCore/wasm/js/JSWebAssemblyTable.cpp
Source/JavaScriptCore/wasm/js/JSWebAssemblyTable.h
Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.cpp
Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.h
Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorPrototype.cpp
Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorPrototype.h
Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp
Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.h
Source/JavaScriptCore/wasm/js/WebAssemblyInstancePrototype.cpp
Source/JavaScriptCore/wasm/js/WebAssemblyInstancePrototype.h
Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.cpp
Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.h
Source/JavaScriptCore/wasm/js/WebAssemblyMemoryPrototype.cpp
Source/JavaScriptCore/wasm/js/WebAssemblyMemoryPrototype.h
Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp
Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.h
Source/JavaScriptCore/wasm/js/WebAssemblyModulePrototype.cpp
Source/JavaScriptCore/wasm/js/WebAssemblyModulePrototype.h
Source/JavaScriptCore/wasm/js/WebAssemblyPrototype.cpp [new file with mode: 0644]
Source/JavaScriptCore/wasm/js/WebAssemblyPrototype.h [moved from Source/JavaScriptCore/wasm/WebAssemblyObject.h with 74% similarity]
Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp
Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.h
Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorPrototype.cpp
Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorPrototype.h
Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.cpp
Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.h
Source/JavaScriptCore/wasm/js/WebAssemblyTablePrototype.cpp
Source/JavaScriptCore/wasm/js/WebAssemblyTablePrototype.h