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

index dd37502..87fab15 100644 (file)
@@ -1,3 +1,29 @@
+2016-10-20  JF Bastien  <jfbastien@apple.com>
+
+        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.
+
+        * wasm/js-api/test_basic_api.js:
+        (const.c.in.constructorProperties): more tests
+
 2016-10-20  Caitlin Potter  <caitp@igalia.com>
 
         [JSC] disallow references to `await` in AsyncFunction formal parameters
index bbd50b5..c4e1927 100644 (file)
@@ -27,6 +27,9 @@ assert.notUndef(WebAssembly);
 checkOwnPropertyDescriptor(utilities.global, "WebAssembly", { typeofvalue: "object", writable: true, configurable: true, enumerable: false });
 assert.eq(String(WebAssembly), "[object WebAssembly]");
 assert.isUndef(WebAssembly.length);
+assert.eq(WebAssembly instanceof Object, true);
+assert.throws(() => WebAssembly(), TypeError, `WebAssembly is not a function. (In 'WebAssembly()', 'WebAssembly' is an instance of WebAssembly)`);
+assert.throws(() => new WebAssembly(), TypeError, `WebAssembly is not a constructor (evaluating 'new WebAssembly()')`);
 
 for (const f in functionProperties) {
     assert.notUndef(WebAssembly[f]);
@@ -39,10 +42,19 @@ for (const c in constructorProperties) {
     assert.eq(WebAssembly[c].name, c);
     assert.eq(WebAssembly[c].length, constructorProperties[c].length);
     checkOwnPropertyDescriptor(WebAssembly, c, constructorProperties[c]);
-    // Check the constructor's prototype.
     checkOwnPropertyDescriptor(WebAssembly[c], "prototype", { typeofvalue: "object", writable: false, configurable: false, enumerable: false });
-    assert.eq(String(WebAssembly[c].prototype), `[object WebAssembly.${c}.prototype]`);
     assert.throws(() => WebAssembly[c](), TypeError, `calling WebAssembly.${c} constructor without new is invalid`);
+    if (constructorProperties[c].isError) {
+        const e = new WebAssembly[c];
+        assert.eq(e instanceof WebAssembly[c], true);
+        assert.eq(e instanceof Error, true);
+        assert.eq(e instanceof TypeError, false);
+        assert.eq(e.message, "");
+        assert.eq(typeof e.stack, "string");
+        const sillyString = "uh-oh!";
+        const e2 = new WebAssembly[c](sillyString);
+        assert.eq(e2.message, sillyString);
+    }
 }
 
 // FIXME Implement and test these APIs further. For now they just throw. https://bugs.webkit.org/show_bug.cgi?id=159775
@@ -51,5 +63,7 @@ for (const f in functionProperties) {
     assert.throws(() => WebAssembly[f](), Error, `WebAssembly doesn't yet implement the ${f} function property`);
 }
 
-for (const c in constructorProperties)
-    assert.throws(() => new WebAssembly[c](), Error, `WebAssembly doesn't yet implement the ${c} constructor property`);
+for (const c in constructorProperties) {
+    if (!constructorProperties[c].isError)
+        assert.throws(() => new WebAssembly[c](), Error, `WebAssembly doesn't yet implement the ${c} constructor property`);
+}
index 968d075..97741fe 100644 (file)
@@ -861,12 +861,12 @@ set(JavaScriptCore_SOURCES
     tools/JSDollarVMPrototype.cpp
 
     wasm/JSWASMModule.cpp
+    wasm/JSWebAssembly.cpp
     wasm/WASMB3IRGenerator.cpp
     wasm/WASMCallingConvention.cpp
     wasm/WASMMemory.cpp
     wasm/WASMModuleParser.cpp
     wasm/WASMPlan.cpp
-    wasm/WebAssemblyObject.cpp
 
     wasm/js/JSWebAssemblyCompileError.cpp
     wasm/js/JSWebAssemblyInstance.cpp
@@ -882,6 +882,7 @@ set(JavaScriptCore_SOURCES
     wasm/js/WebAssemblyMemoryPrototype.cpp
     wasm/js/WebAssemblyModuleConstructor.cpp
     wasm/js/WebAssemblyModulePrototype.cpp
+    wasm/js/WebAssemblyPrototype.cpp
     wasm/js/WebAssemblyRuntimeErrorConstructor.cpp
     wasm/js/WebAssemblyRuntimeErrorPrototype.cpp
     wasm/js/WebAssemblyTableConstructor.cpp
@@ -946,6 +947,7 @@ set(JavaScriptCore_OBJECT_LUT_SOURCES
     wasm/js/WebAssemblyMemoryPrototype.cpp
     wasm/js/WebAssemblyModuleConstructor.cpp
     wasm/js/WebAssemblyModulePrototype.cpp
+    wasm/js/WebAssemblyPrototype.cpp
     wasm/js/WebAssemblyRuntimeErrorConstructor.cpp
     wasm/js/WebAssemblyRuntimeErrorPrototype.cpp
     wasm/js/WebAssemblyTableConstructor.cpp
index a541adc..4c41695 100644 (file)
@@ -1,3 +1,91 @@
+2016-10-20  JF Bastien  <jfbastien@apple.com>
+
+        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.
+
+        * 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:
+
 2016-10-19  Myles C. Maxfield  <mmaxfield@apple.com>
 
         [macOS] [iOS] Disable variation fonts on macOS El Capitan and iOS 9
index eecb53c..6630537 100644 (file)
@@ -168,6 +168,7 @@ OBJECT_LUT_HEADERS = \
     WebAssemblyMemoryPrototype.lut.h \
     WebAssemblyModuleConstructor.lut.h \
     WebAssemblyModulePrototype.lut.h \
+    WebAssemblyPrototype.lut.h \
     WebAssemblyRuntimeErrorConstructor.lut.h \
     WebAssemblyRuntimeErrorPrototype.lut.h \
     WebAssemblyTableConstructor.lut.h \
index aecd1b2..0966e47 100644 (file)
                A7FB61001040C38B0017A286 /* PropertyDescriptor.h in Headers */ = {isa = PBXBuildFile; fileRef = A7FB604B103F5EAB0017A286 /* PropertyDescriptor.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A7FCC26D17A0B6AA00786D1A /* FTLSwitchCase.h in Headers */ = {isa = PBXBuildFile; fileRef = A7FCC26C17A0B6AA00786D1A /* FTLSwitchCase.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A8A4748E151A8306004123FF /* libWTF.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A8A4748D151A8306004123FF /* libWTF.a */; };
-               AD2FCB881DAEBF3C00B3E736 /* WebAssemblyObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD2FCB861DAEBF3700B3E736 /* WebAssemblyObject.cpp */; };
-               AD2FCB891DAEBF3F00B3E736 /* WebAssemblyObject.h in Headers */ = {isa = PBXBuildFile; fileRef = AD2FCB871DAEBF3700B3E736 /* WebAssemblyObject.h */; };
                AD2FCBE21DB58DAD00B3E736 /* JSWebAssemblyCompileError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD2FCBA61DB58DA400B3E736 /* JSWebAssemblyCompileError.cpp */; };
                AD2FCBE31DB58DAD00B3E736 /* JSWebAssemblyCompileError.h in Headers */ = {isa = PBXBuildFile; fileRef = AD2FCBA71DB58DA400B3E736 /* JSWebAssemblyCompileError.h */; };
                AD2FCBE41DB58DAD00B3E736 /* JSWebAssemblyInstance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD2FCBA81DB58DA400B3E736 /* JSWebAssemblyInstance.cpp */; };
                AD2FCC1F1DB59CB200B3E736 /* WebAssemblyRuntimeErrorPrototype.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = AD2FCC131DB59C5900B3E736 /* WebAssemblyRuntimeErrorPrototype.lut.h */; };
                AD2FCC201DB59CB200B3E736 /* WebAssemblyTableConstructor.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = AD2FCC141DB59C5900B3E736 /* WebAssemblyTableConstructor.lut.h */; };
                AD2FCC211DB59CB200B3E736 /* WebAssemblyTablePrototype.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = AD2FCC151DB59C5900B3E736 /* WebAssemblyTablePrototype.lut.h */; };
+               AD2FCC2C1DB838FD00B3E736 /* WebAssemblyPrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD2FCC261DB838C400B3E736 /* WebAssemblyPrototype.cpp */; };
+               AD2FCC2D1DB838FD00B3E736 /* WebAssemblyPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = AD2FCC271DB838C400B3E736 /* WebAssemblyPrototype.h */; };
+               AD2FCC301DB83D4900B3E736 /* JSWebAssembly.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD2FCC2E1DB839F700B3E736 /* JSWebAssembly.cpp */; };
+               AD2FCC311DB83D4900B3E736 /* JSWebAssembly.h in Headers */ = {isa = PBXBuildFile; fileRef = AD2FCC2F1DB839F700B3E736 /* JSWebAssembly.h */; };
                AD86A93E1AA4D88D002FE77F /* WeakGCMapInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = AD86A93D1AA4D87C002FE77F /* WeakGCMapInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
                ADDB1F6318D77DBE009B58A8 /* OpaqueRootSet.h in Headers */ = {isa = PBXBuildFile; fileRef = ADDB1F6218D77DB7009B58A8 /* OpaqueRootSet.h */; settings = {ATTRIBUTES = (Private, ); }; };
                ADE39FFF16DD144B0003CD4A /* PropertyTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD1CF06816DCAB2D00B97123 /* PropertyTable.cpp */; };
                A8E894310CD0602400367179 /* JSCallbackObjectFunctions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCallbackObjectFunctions.h; sourceTree = "<group>"; };
                A8E894330CD0603F00367179 /* JSGlobalObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalObject.h; sourceTree = "<group>"; };
                AD1CF06816DCAB2D00B97123 /* PropertyTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PropertyTable.cpp; sourceTree = "<group>"; };
-               AD2FCB861DAEBF3700B3E736 /* WebAssemblyObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebAssemblyObject.cpp; sourceTree = "<group>"; };
-               AD2FCB871DAEBF3700B3E736 /* WebAssemblyObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAssemblyObject.h; sourceTree = "<group>"; };
                AD2FCB8C1DB5844000B3E736 /* JSWebAssemblyModule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSWebAssemblyModule.cpp; path = js/JSWebAssemblyModule.cpp; sourceTree = "<group>"; };
                AD2FCB8D1DB5844000B3E736 /* JSWebAssemblyModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSWebAssemblyModule.h; path = js/JSWebAssemblyModule.h; sourceTree = "<group>"; };
                AD2FCB981DB585A600B3E736 /* WebAssemblyModuleConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebAssemblyModuleConstructor.cpp; path = js/WebAssemblyModuleConstructor.cpp; sourceTree = "<group>"; };
                AD2FCC131DB59C5900B3E736 /* WebAssemblyRuntimeErrorPrototype.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAssemblyRuntimeErrorPrototype.lut.h; sourceTree = "<group>"; };
                AD2FCC141DB59C5900B3E736 /* WebAssemblyTableConstructor.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAssemblyTableConstructor.lut.h; sourceTree = "<group>"; };
                AD2FCC151DB59C5900B3E736 /* WebAssemblyTablePrototype.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAssemblyTablePrototype.lut.h; sourceTree = "<group>"; };
+               AD2FCC261DB838C400B3E736 /* WebAssemblyPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebAssemblyPrototype.cpp; path = js/WebAssemblyPrototype.cpp; sourceTree = "<group>"; };
+               AD2FCC271DB838C400B3E736 /* WebAssemblyPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebAssemblyPrototype.h; path = js/WebAssemblyPrototype.h; sourceTree = "<group>"; };
+               AD2FCC2E1DB839F700B3E736 /* JSWebAssembly.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebAssembly.cpp; sourceTree = "<group>"; };
+               AD2FCC2F1DB839F700B3E736 /* JSWebAssembly.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebAssembly.h; sourceTree = "<group>"; };
                AD86A93D1AA4D87C002FE77F /* WeakGCMapInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakGCMapInlines.h; sourceTree = "<group>"; };
                ADDB1F6218D77DB7009B58A8 /* OpaqueRootSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpaqueRootSet.h; sourceTree = "<group>"; };
                B59F89371891AD3300D5CCDC /* UnlinkedInstructionStream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnlinkedInstructionStream.h; sourceTree = "<group>"; };
                7B98D1331B60CD1E0023B1A4 /* wasm */ = {
                        isa = PBXGroup;
                        children = (
+                               AD2FCC2E1DB839F700B3E736 /* JSWebAssembly.cpp */,
+                               AD2FCC2F1DB839F700B3E736 /* JSWebAssembly.h */,
                                AD2FCB8A1DB5840000B3E736 /* js */,
-                               AD2FCB861DAEBF3700B3E736 /* WebAssemblyObject.cpp */,
-                               AD2FCB871DAEBF3700B3E736 /* WebAssemblyObject.h */,
                                7B98D1341B60CD5A0023B1A4 /* JSWASMModule.cpp */,
                                7B98D1351B60CD5A0023B1A4 /* JSWASMModule.h */,
                                53F40E8E1D5902820099A1B6 /* WASMB3IRGenerator.cpp */,
                AD2FCB8A1DB5840000B3E736 /* js */ = {
                        isa = PBXGroup;
                        children = (
+                               AD2FCC261DB838C400B3E736 /* WebAssemblyPrototype.cpp */,
+                               AD2FCC271DB838C400B3E736 /* WebAssemblyPrototype.h */,
                                AD2FCBA61DB58DA400B3E736 /* JSWebAssemblyCompileError.cpp */,
                                AD2FCBA71DB58DA400B3E736 /* JSWebAssemblyCompileError.h */,
                                AD2FCBA81DB58DA400B3E736 /* JSWebAssemblyInstance.cpp */,
                                0FC97F34182020D7002C9B26 /* CodeBlockJettisoningWatchpoint.h in Headers */,
                                0FD8A31417D4326C00CA2C40 /* CodeBlockSet.h in Headers */,
                                0F96EBB316676EF6008BADE3 /* CodeBlockWithJITType.h in Headers */,
-                               AD2FCB891DAEBF3F00B3E736 /* WebAssemblyObject.h in Headers */,
                                A77F1822164088B200640A47 /* CodeCache.h in Headers */,
                                99CC0B6318BE9950006CEBCC /* CodeGeneratorReplayInputs.py in Headers */,
                                99CC0B6218BE9946006CEBCC /* CodeGeneratorReplayInputsTemplates.py in Headers */,
                                A7D89CF617A0B8CC00773AD8 /* DFGCriticalEdgeBreakingPhase.h in Headers */,
                                0FFFC95A14EF90A900C72532 /* DFGCSEPhase.h in Headers */,
                                0F2FC77316E12F740038D976 /* DFGDCEPhase.h in Headers */,
+                               AD2FCC311DB83D4900B3E736 /* JSWebAssembly.h in Headers */,
                                0F8F2B9A172F0501007DBDA5 /* DFGDesiredIdentifiers.h in Headers */,
                                8B9F6D561D5912FA001C739F /* IterationKind.h in Headers */,
                                0FFC92141B94E83E0071DD66 /* DFGDesiredInferredType.h in Headers */,
                                A5BA15EA182340B400A82E69 /* RemoteInspectorConstants.h in Headers */,
                                A5BA15F0182345AF00A82E69 /* RemoteInspectionTarget.h in Headers */,
                                A5BA15EB182340B400A82E69 /* RemoteConnectionToTarget.h in Headers */,
+                               AD2FCC2D1DB838FD00B3E736 /* WebAssemblyPrototype.h in Headers */,
                                A5BA15ED182340B400A82E69 /* RemoteInspectorXPCConnection.h in Headers */,
                                0F24E55117EE274900ABB217 /* Repatch.h in Headers */,
                                DC2143071CA32E55000A8869 /* ICStats.h in Headers */,
                                0F8F14351ADF090100ED792C /* DFGMovHintRemovalPhase.cpp in Sources */,
                                0FF2CD5B1B61A4F8004955A8 /* DFGMultiGetByOffsetData.cpp in Sources */,
                                A737810D1799EA2E00817533 /* DFGNaturalLoops.cpp in Sources */,
+                               AD2FCC301DB83D4900B3E736 /* JSWebAssembly.cpp in Sources */,
                                79B00CBE1C6AB07E0088C65D /* ProxyObject.cpp in Sources */,
                                792CB3491C4EED5C00D13AF3 /* PCToCodeOriginMap.cpp in Sources */,
                                0FF0F19C16B72A03005DF95B /* DFGNode.cpp in Sources */,
                                147F39D6107EC37600427A48 /* JSCJSValue.cpp in Sources */,
                                1440FCE40A51E46B0005F061 /* JSClassRef.cpp in Sources */,
                                86E3C616167BABEE006D760A /* JSContext.mm in Sources */,
+                               AD2FCC2C1DB838FD00B3E736 /* WebAssemblyPrototype.cpp in Sources */,
                                14BD5A300A3E91F600BAF59C /* JSContextRef.cpp in Sources */,
                                A72028B61797601E0098028C /* JSCTestRunnerUtils.cpp in Sources */,
                                0F2B66EB17B6B5AB00A7AE3F /* JSDataView.cpp in Sources */,
                                7905BB681D12050E0019FE57 /* InlineAccess.cpp in Sources */,
                                0FE050271AA9095600D33B33 /* ScopedArguments.cpp in Sources */,
                                0FE0502F1AAA806900D33B33 /* ScopedArgumentsTable.cpp in Sources */,
-                               AD2FCB881DAEBF3C00B3E736 /* WebAssemblyObject.cpp in Sources */,
                                992ABCF91BEA9BD2006403A0 /* RemoteAutomationTarget.cpp in Sources */,
                                0FE0502A1AA9095600D33B33 /* ScopeOffset.cpp in Sources */,
                                0FA7A8EE18CE4FD80052371D /* ScratchRegisterAllocator.cpp in Sources */,
index 15a9410..f48cbcf 100644 (file)
 #include "JSTypedArrays.h"
 #include "JSWeakMap.h"
 #include "JSWeakSet.h"
+#include "JSWebAssembly.h"
 #include "JSWithScope.h"
 #include "LazyClassStructureInlines.h"
 #include "LazyPropertyInlines.h"
 #include "WeakMapPrototype.h"
 #include "WeakSetConstructor.h"
 #include "WeakSetPrototype.h"
-#include "WebAssemblyObject.h"
 #include <wtf/RandomNumber.h>
 
 #if ENABLE(INTL)
@@ -541,18 +541,18 @@ void JSGlobalObject::init(VM& vm)
     m_parseIntFunction.set(vm, this, JSFunction::create(vm, this, 2, vm.propertyNames->parseInt.string(), globalFuncParseInt, NoIntrinsic));
     putDirectWithoutTransition(vm, vm.propertyNames->parseInt, m_parseIntFunction.get(), DontEnum);
 
-#define CREATE_PROTOTYPE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
-m_ ## lowerName ## Prototype.set(vm, this, capitalName##Prototype::create(vm, this, capitalName##Prototype::createStructure(vm, this, m_objectPrototype.get()))); \
+#define CREATE_PROTOTYPE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
+m_ ## lowerName ## Prototype.set(vm, this, capitalName##Prototype::create(vm, this, capitalName##Prototype::createStructure(vm, this, m_ ## prototypeBase ## Prototype.get()))); \
 m_ ## properName ## Structure.set(vm, this, instanceType::createStructure(vm, this, m_ ## lowerName ## Prototype.get()));
     
     FOR_EACH_SIMPLE_BUILTIN_TYPE(CREATE_PROTOTYPE_FOR_SIMPLE_TYPE)
     
 #undef CREATE_PROTOTYPE_FOR_SIMPLE_TYPE
 
-#define CREATE_PROTOTYPE_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
+#define CREATE_PROTOTYPE_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
     m_ ## properName ## Structure.initLater(\
         [] (LazyClassStructure::Initializer& init) { \
-            init.setPrototype(capitalName##Prototype::create(init.vm, init.global, capitalName##Prototype::createStructure(init.vm, init.global, init.global->m_objectPrototype.get()))); \
+            init.setPrototype(capitalName##Prototype::create(init.vm, init.global, capitalName##Prototype::createStructure(init.vm, init.global, init.global->m_ ## prototypeBase ## Prototype.get()))); \
             init.setStructure(instanceType::createStructure(init.vm, init.global, init.prototype)); \
             init.setConstructor(capitalName ## Constructor::create(init.vm, capitalName ## Constructor::createStructure(init.vm, init.global, init.global->m_functionPrototype.get()), jsCast<capitalName ## Prototype*>(init.prototype), init.global->m_speciesGetterSetter.get())); \
         });
@@ -563,7 +563,7 @@ m_ ## properName ## Structure.set(vm, this, instanceType::createStructure(vm, th
     
     m_iteratorPrototype.set(vm, this, IteratorPrototype::create(vm, this, IteratorPrototype::createStructure(vm, this, m_objectPrototype.get())));
 
-#define CREATE_PROTOTYPE_FOR_DERIVED_ITERATOR_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
+#define CREATE_PROTOTYPE_FOR_DERIVED_ITERATOR_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
     m_ ## lowerName ## Structure.initLater( \
         [] (const Initializer<Structure>& init) { \
             JSObject* prototype = capitalName ## Prototype::create(init.vm, init.owner, capitalName ## Prototype::createStructure(init.vm, init.owner, init.owner->m_iteratorPrototype.get())); \
@@ -590,7 +590,7 @@ m_ ## properName ## Structure.set(vm, this, instanceType::createStructure(vm, th
     
     m_regExpConstructor.set(vm, this, RegExpConstructor::create(vm, RegExpConstructor::createStructure(vm, this, m_functionPrototype.get()), m_regExpPrototype.get(), m_speciesGetterSetter.get()));
     
-#define CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
+#define CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
 capitalName ## Constructor* lowerName ## Constructor = capitalName ## Constructor::create(vm, capitalName ## Constructor::createStructure(vm, this, m_functionPrototype.get()), m_ ## lowerName ## Prototype.get(), m_speciesGetterSetter.get()); \
 m_ ## lowerName ## Prototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, lowerName ## Constructor, DontEnum); \
 
@@ -646,7 +646,7 @@ m_ ## lowerName ## Prototype->putDirectWithoutTransition(vm, vm.propertyNames->c
     putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().ObjectPrivateName(), objectConstructor, DontEnum | DontDelete | ReadOnly);
     putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().ArrayPrivateName(), arrayConstructor, DontEnum | DontDelete | ReadOnly);
 
-#define PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
+#define PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
 putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Constructor, DontEnum); \
 
     FOR_EACH_SIMPLE_BUILTIN_TYPE_WITH_CONSTRUCTOR(PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE)
@@ -820,14 +820,28 @@ putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Construct
 
 #if ENABLE(WEBASSEMBLY)
     if (Options::useWebAssembly()) {
-        auto* wasm = WebAssemblyObject::create(vm, this, WebAssemblyObject::createStructure(vm, this, m_objectPrototype.get()));
-        putDirectWithoutTransition(vm, Identifier::fromString(exec, "WebAssembly"), wasm, DontEnum);
-        GlobalPropertyInfo extraStaticGlobals[] = {
-#define REGISTER_WASM_CONSTRUCTOR_AS_GLOBAL_PROPERTY(NAME, ...) \
-            GlobalPropertyInfo(vm.propertyNames->builtinNames().NAME ## PrivateName(), wasm->getDirect(vm, Identifier::fromString(exec, #NAME)), DontEnum | DontDelete | ReadOnly),
-            FOR_EACH_WASM_CONSTRUCTOR_PROPERTY(REGISTER_WASM_CONSTRUCTOR_AS_GLOBAL_PROPERTY)
-        };
-        addStaticGlobals(extraStaticGlobals, WTF_ARRAY_LENGTH(extraStaticGlobals));
+        auto* webAssemblyPrototype = WebAssemblyPrototype::create(vm, this, WebAssemblyPrototype::createStructure(vm, this, m_objectPrototype.get()));
+        m_webAssemblyStructure.set(vm, this, JSWebAssembly::createStructure(vm, this, webAssemblyPrototype));
+        auto* webAssembly = JSWebAssembly::create(vm, this, m_webAssemblyStructure.get());
+        putDirectWithoutTransition(vm, Identifier::fromString(exec, "WebAssembly"), webAssembly, DontEnum);
+
+#define CREATE_WEBASSEMBLY_CONSTRUCTOR(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) do { \
+        typedef capitalName ## Prototype Prototype; \
+        typedef capitalName ## Constructor Constructor; \
+        typedef JS ## capitalName JSObj; \
+        auto* base = m_ ## prototypeBase ## Prototype.get(); \
+        auto* prototype = Prototype::create(vm, this, Prototype::createStructure(vm, this, base)); \
+        auto* structure = JSObj::createStructure(vm, this, prototype); \
+        auto* constructor = Constructor::create(vm, Constructor::createStructure(vm, this, this->functionPrototype()), prototype, structure); \
+        prototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, constructor, DontEnum); \
+        m_ ## lowerName ## Prototype.set(vm, this, prototype); \
+        m_ ## properName ## Structure.set(vm, this, structure); \
+        webAssembly->putDirectWithoutTransition(vm, Identifier::fromString(this->globalExec(), #jsName), constructor, DontEnum); \
+    } while (0);
+
+        FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(CREATE_WEBASSEMBLY_CONSTRUCTOR)
+
+#undef CREATE_WEBASSEMBLY_CONSTRUCTOR
     }
 #endif // ENABLE(WEBASSEMBLY)
 
@@ -1142,15 +1156,20 @@ void JSGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor)
     visitor.append(&thisObject->m_proxyRevokeStructure);
     visitor.append(&thisObject->m_moduleLoaderStructure);
 
-#define VISIT_SIMPLE_TYPE(CapitalName, lowerName, properName, instanceType, jsName) \
+#define VISIT_SIMPLE_TYPE(CapitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
     visitor.append(&thisObject->m_ ## lowerName ## Prototype); \
     visitor.append(&thisObject->m_ ## properName ## Structure); \
 
     FOR_EACH_SIMPLE_BUILTIN_TYPE(VISIT_SIMPLE_TYPE)
+    
+#if ENABLE(WEBASSEMBLY)
+    visitor.append(&thisObject->m_webAssemblyStructure);
+    FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(VISIT_SIMPLE_TYPE)
+#endif // ENABLE(WEBASSEMBLY)
 
 #undef VISIT_SIMPLE_TYPE
 
-#define VISIT_LAZY_TYPE(CapitalName, lowerName, properName, instanceType, jsName) \
+#define VISIT_LAZY_TYPE(CapitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
     thisObject->m_ ## properName ## Structure.visit(visitor);
     
     FOR_EACH_LAZY_BUILTIN_TYPE(VISIT_LAZY_TYPE)
index 25bde2b..40846ce 100644 (file)
@@ -95,16 +95,16 @@ class VariableEnvironment;
 struct ActivationStackNode;
 struct HashTable;
 
-#define DEFINE_STANDARD_BUILTIN(macro, upperName, lowerName) macro(upperName, lowerName, lowerName, JS ## upperName, upperName)
+#define DEFINE_STANDARD_BUILTIN(macro, upperName, lowerName) macro(upperName, lowerName, lowerName, JS ## upperName, upperName, object)
 
 #define FOR_EACH_SIMPLE_BUILTIN_TYPE_WITH_CONSTRUCTOR(macro) \
-    macro(String, string, stringObject, StringObject, String) \
-    macro(Symbol, symbol, symbolObject, SymbolObject, Symbol) \
-    macro(Number, number, numberObject, NumberObject, Number) \
-    macro(Error, error, error, ErrorInstance, Error) \
-    macro(Map, map, map, JSMap, Map) \
-    macro(JSPromise, promise, promise, JSPromise, Promise) \
-    macro(JSArrayBuffer, arrayBuffer, arrayBuffer, JSArrayBuffer, ArrayBuffer) \
+    macro(String, string, stringObject, StringObject, String, object) \
+    macro(Symbol, symbol, symbolObject, SymbolObject, Symbol, object) \
+    macro(Number, number, numberObject, NumberObject, Number, object) \
+    macro(Error, error, error, ErrorInstance, Error, object) \
+    macro(Map, map, map, JSMap, Map, object) \
+    macro(JSPromise, promise, promise, JSPromise, Promise, object) \
+    macro(JSArrayBuffer, arrayBuffer, arrayBuffer, JSArrayBuffer, ArrayBuffer, object) \
 
 #define FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(macro) \
     DEFINE_STANDARD_BUILTIN(macro, MapIterator, mapIterator) \
@@ -117,16 +117,28 @@ struct HashTable;
 
 #define FOR_EACH_SIMPLE_BUILTIN_TYPE(macro) \
     FOR_EACH_SIMPLE_BUILTIN_TYPE_WITH_CONSTRUCTOR(macro) \
-    macro(JSInternalPromise, internalPromise, internalPromise, JSInternalPromise, InternalPromise) \
+    macro(JSInternalPromise, internalPromise, internalPromise, JSInternalPromise, InternalPromise, object) \
 
 #define FOR_EACH_LAZY_BUILTIN_TYPE(macro) \
-    macro(Set, set, set, JSSet, Set) \
-    macro(Date, date, date, DateInstance, Date) \
-    macro(Boolean, boolean, booleanObject, BooleanObject, Boolean) \
+    macro(Set, set, set, JSSet, Set, object) \
+    macro(Date, date, date, DateInstance, Date, object) \
+    macro(Boolean, boolean, booleanObject, BooleanObject, Boolean, object) \
     DEFINE_STANDARD_BUILTIN(macro, WeakMap, weakMap) \
     DEFINE_STANDARD_BUILTIN(macro, WeakSet, weakSet) \
 
-#define DECLARE_SIMPLE_BUILTIN_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
+#if ENABLE(WEBASSEMBLY)
+#define FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(macro) \
+    macro(WebAssemblyCompileError, webAssemblyCompileError, WebAssemblyCompileError, WebAssemblyCompileError, CompileError, error) \
+    macro(WebAssemblyInstance,     webAssemblyInstance,     WebAssemblyInstance,     WebAssemblyInstance,     Instance,     object) \
+    macro(WebAssemblyMemory,       webAssemblyMemory,       WebAssemblyMemory,       WebAssemblyMemory,       Memory,       object) \
+    macro(WebAssemblyModule,       webAssemblyModule,       WebAssemblyModule,       WebAssemblyModule,       Module,       object) \
+    macro(WebAssemblyRuntimeError, webAssemblyRuntimeError, WebAssemblyRuntimeError, WebAssemblyRuntimeError, RuntimeError, error) \
+    macro(WebAssemblyTable,        webAssemblyTable,        WebAssemblyTable,        WebAssemblyTable,        Table,        object)
+#else
+#define FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(macro)
+#endif // ENABLE(WEBASSEMBLY)
+
+#define DECLARE_SIMPLE_BUILTIN_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
     class JS ## capitalName; \
     class capitalName ## Prototype; \
     class capitalName ## Constructor;
@@ -135,6 +147,7 @@ class IteratorPrototype;
 FOR_EACH_SIMPLE_BUILTIN_TYPE(DECLARE_SIMPLE_BUILTIN_TYPE)
 FOR_EACH_LAZY_BUILTIN_TYPE(DECLARE_SIMPLE_BUILTIN_TYPE)
 FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(DECLARE_SIMPLE_BUILTIN_TYPE)
+FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(DECLARE_SIMPLE_BUILTIN_TYPE)
 
 #undef DECLARE_SIMPLE_BUILTIN_TYPE
 
@@ -305,20 +318,25 @@ public:
     WriteBarrier<Structure> m_proxyRevokeStructure;
     WriteBarrier<Structure> m_moduleLoaderStructure;
 
-#define DEFINE_STORAGE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
+#define DEFINE_STORAGE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
     WriteBarrier<capitalName ## Prototype> m_ ## lowerName ## Prototype; \
     WriteBarrier<Structure> m_ ## properName ## Structure;
 
     FOR_EACH_SIMPLE_BUILTIN_TYPE(DEFINE_STORAGE_FOR_SIMPLE_TYPE)
+    
+#if ENABLE(WEBASSEMBLY)
+    WriteBarrier<Structure> m_webAssemblyStructure;
+    FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(DEFINE_STORAGE_FOR_SIMPLE_TYPE)
+#endif // ENABLE(WEBASSEMBLY)
 
 #undef DEFINE_STORAGE_FOR_SIMPLE_TYPE
 
-#define DEFINE_STORAGE_FOR_ITERATOR_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
+#define DEFINE_STORAGE_FOR_ITERATOR_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
     LazyProperty<JSGlobalObject, Structure> m_ ## properName ## Structure;
     FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(DEFINE_STORAGE_FOR_ITERATOR_TYPE)
 #undef DEFINE_STORAGE_FOR_ITERATOR_TYPE
     
-#define DEFINE_STORAGE_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
+#define DEFINE_STORAGE_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
     LazyClassStructure m_ ## properName ## Structure;
     FOR_EACH_LAZY_BUILTIN_TYPE(DEFINE_STORAGE_FOR_LAZY_TYPE)
 #undef DEFINE_STORAGE_FOR_LAZY_TYPE
@@ -606,21 +624,22 @@ public:
 
     JSArrayBufferPrototype* arrayBufferPrototype() const { return m_arrayBufferPrototype.get(); }
 
-#define DEFINE_ACCESSORS_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
+#define DEFINE_ACCESSORS_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
     Structure* properName ## Structure() { return m_ ## properName ## Structure.get(); }
 
     FOR_EACH_SIMPLE_BUILTIN_TYPE(DEFINE_ACCESSORS_FOR_SIMPLE_TYPE)
+    FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(DEFINE_ACCESSORS_FOR_SIMPLE_TYPE)
 
 #undef DEFINE_ACCESSORS_FOR_SIMPLE_TYPE
 
-#define DEFINE_ACCESSORS_FOR_ITERATOR_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
+#define DEFINE_ACCESSORS_FOR_ITERATOR_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
     Structure* properName ## Structure() { return m_ ## properName ## Structure.get(this); }
 
     FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(DEFINE_ACCESSORS_FOR_ITERATOR_TYPE)
 
 #undef DEFINE_ACCESSORS_FOR_ITERATOR_TYPE
 
-#define DEFINE_ACCESSORS_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
+#define DEFINE_ACCESSORS_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
     Structure* properName ## Structure() { return m_ ## properName ## Structure.get(this); }
 
     FOR_EACH_LAZY_BUILTIN_TYPE(DEFINE_ACCESSORS_FOR_LAZY_TYPE)
diff --git a/Source/JavaScriptCore/wasm/JSWebAssembly.cpp b/Source/JavaScriptCore/wasm/JSWebAssembly.cpp
new file mode 100644 (file)
index 0000000..7a3d7ac
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSWebAssembly.h"
+
+#if ENABLE(WEBASSEMBLY)
+
+#include "FunctionPrototype.h"
+#include "JSCInlines.h"
+
+namespace JSC {
+
+STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(JSWebAssembly);
+
+const ClassInfo JSWebAssembly::s_info = { "WebAssembly", &Base::s_info, 0, CREATE_METHOD_TABLE(JSWebAssembly) };
+
+JSWebAssembly* JSWebAssembly::create(VM& vm, JSGlobalObject* globalObject, Structure* structure)
+{
+    auto* object = new (NotNull, allocateCell<JSWebAssembly>(vm.heap)) JSWebAssembly(vm, structure);
+    object->finishCreation(vm, globalObject);
+    return object;
+}
+
+Structure* JSWebAssembly::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
+{
+    return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
+}
+
+void JSWebAssembly::finishCreation(VM& vm, JSGlobalObject*)
+{
+    Base::finishCreation(vm);
+    ASSERT(inherits(info()));
+}
+
+JSWebAssembly::JSWebAssembly(VM& vm, Structure* structure)
+    : JSNonFinalObject(vm, structure)
+{
+}
+
+} // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
diff --git a/Source/JavaScriptCore/wasm/JSWebAssembly.h b/Source/JavaScriptCore/wasm/JSWebAssembly.h
new file mode 100644 (file)
index 0000000..e71a15a
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(WEBASSEMBLY)
+
+#include "JSObject.h"
+#include "js/JSWebAssemblyCompileError.h"
+#include "js/JSWebAssemblyInstance.h"
+#include "js/JSWebAssemblyMemory.h"
+#include "js/JSWebAssemblyModule.h"
+#include "js/JSWebAssemblyRuntimeError.h"
+#include "js/JSWebAssemblyTable.h"
+#include "js/WebAssemblyCompileErrorConstructor.h"
+#include "js/WebAssemblyCompileErrorPrototype.h"
+#include "js/WebAssemblyInstanceConstructor.h"
+#include "js/WebAssemblyInstancePrototype.h"
+#include "js/WebAssemblyMemoryConstructor.h"
+#include "js/WebAssemblyMemoryPrototype.h"
+#include "js/WebAssemblyModuleConstructor.h"
+#include "js/WebAssemblyModulePrototype.h"
+#include "js/WebAssemblyPrototype.h"
+#include "js/WebAssemblyRuntimeErrorConstructor.h"
+#include "js/WebAssemblyRuntimeErrorPrototype.h"
+#include "js/WebAssemblyTableConstructor.h"
+#include "js/WebAssemblyTablePrototype.h"
+
+namespace JSC {
+
+class JSWebAssembly : public JSNonFinalObject {
+public:
+    typedef JSNonFinalObject Base;
+
+    static JSWebAssembly* create(VM&, JSGlobalObject*, Structure*);
+    static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
+
+    DECLARE_INFO;
+
+protected:
+    void finishCreation(VM&, JSGlobalObject*);
+
+private:
+    JSWebAssembly(VM&, Structure*);
+};
+
+} // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
diff --git a/Source/JavaScriptCore/wasm/WebAssemblyObject.cpp b/Source/JavaScriptCore/wasm/WebAssemblyObject.cpp
deleted file mode 100644 (file)
index 9372fb4..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "WebAssemblyObject.h"
-
-#include "FunctionPrototype.h"
-#include "JSCInlines.h"
-#include "js/JSWebAssemblyCompileError.h"
-#include "js/JSWebAssemblyInstance.h"
-#include "js/JSWebAssemblyMemory.h"
-#include "js/JSWebAssemblyModule.h"
-#include "js/JSWebAssemblyRuntimeError.h"
-#include "js/JSWebAssemblyTable.h"
-#include "js/WebAssemblyCompileErrorConstructor.h"
-#include "js/WebAssemblyCompileErrorPrototype.h"
-#include "js/WebAssemblyInstanceConstructor.h"
-#include "js/WebAssemblyInstancePrototype.h"
-#include "js/WebAssemblyMemoryConstructor.h"
-#include "js/WebAssemblyMemoryPrototype.h"
-#include "js/WebAssemblyModuleConstructor.h"
-#include "js/WebAssemblyModulePrototype.h"
-#include "js/WebAssemblyRuntimeErrorConstructor.h"
-#include "js/WebAssemblyRuntimeErrorPrototype.h"
-#include "js/WebAssemblyTableConstructor.h"
-#include "js/WebAssemblyTablePrototype.h"
-
-namespace JSC {
-
-STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(WebAssemblyObject);
-
-#define DECLARE_WASM_OBJECT_FUNCTION(NAME, ...) EncodedJSValue JSC_HOST_CALL wasmObjectFunc ## NAME(ExecState*);
-FOR_EACH_WASM_FUNCTION_PROPERTY(DECLARE_WASM_OBJECT_FUNCTION)
-
-const ClassInfo WebAssemblyObject::s_info = { "WebAssembly", &Base::s_info, 0, CREATE_METHOD_TABLE(WebAssemblyObject) };
-
-WebAssemblyObject* WebAssemblyObject::create(VM& vm, JSGlobalObject* globalObject, Structure* structure)
-{
-    auto* object = new (NotNull, allocateCell<WebAssemblyObject>(vm.heap)) WebAssemblyObject(vm, structure);
-    object->finishCreation(vm, globalObject);
-    return object;
-}
-
-Structure* WebAssemblyObject::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
-{
-    return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
-}
-
-void WebAssemblyObject::finishCreation(VM& vm, JSGlobalObject* globalObject)
-{
-    Base::finishCreation(vm);
-    ASSERT(inherits(info()));
-
-#define SET_UP_WASM_CONSTRUCTOR_PROPERTY(NAME, ...) \
-    auto* prototype ## NAME = WebAssembly ## NAME ## Prototype::create(vm, globalObject, WebAssembly ## NAME ## Prototype::createStructure(vm, globalObject, globalObject->objectPrototype())); \
-    auto* structure ## NAME = JSWebAssembly ## NAME::createStructure(vm, globalObject, prototype ## NAME); \
-    auto* constructor ## NAME = WebAssembly ## NAME ## Constructor::create(vm, WebAssembly ## NAME ## Constructor::createStructure(vm, globalObject, globalObject->functionPrototype()), prototype ## NAME, structure ## NAME); \
-    prototype ## NAME->putDirectWithoutTransition(vm, vm.propertyNames->constructor, constructor ## NAME, DontEnum);
-    FOR_EACH_WASM_CONSTRUCTOR_PROPERTY(SET_UP_WASM_CONSTRUCTOR_PROPERTY)
-
-#define REGISTER_WASM_CONSTRUCTOR_PROPERTY(NAME, ...) \
-    putDirectWithoutTransition(vm, Identifier::fromString(globalObject->globalExec(), #NAME), constructor ## NAME, DontEnum);
-    FOR_EACH_WASM_CONSTRUCTOR_PROPERTY(REGISTER_WASM_CONSTRUCTOR_PROPERTY)
-
-#define REGISTER_WASM_FUNCTION_PROPERTY(NAME, LENGTH) \
-    putDirectNativeFunction(vm, globalObject, Identifier::fromString(&vm, #NAME), LENGTH, wasmObjectFunc ## NAME, NoIntrinsic, DontEnum);
-    FOR_EACH_WASM_FUNCTION_PROPERTY(REGISTER_WASM_FUNCTION_PROPERTY)
-}
-
-WebAssemblyObject::WebAssemblyObject(VM& vm, Structure* structure)
-    : JSNonFinalObject(vm, structure)
-{
-}
-
-// ------------------------------ Functions --------------------------------
-
-EncodedJSValue JSC_HOST_CALL wasmObjectFuncvalidate(ExecState* state)
-{
-    VM& vm = state->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-    return JSValue::encode(throwException(state, scope, createError(state, ASCIILiteral("WebAssembly doesn't yet implement the validate function property"))));
-}
-
-EncodedJSValue JSC_HOST_CALL wasmObjectFunccompile(ExecState* state)
-{
-    VM& vm = state->vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-    return JSValue::encode(throwException(state, scope, createError(state, ASCIILiteral("WebAssembly doesn't yet implement the compile function property"))));
-}
-
-} // namespace JSC
index 32e136a..02ff885 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "JSWebAssemblyCompileError.h"
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "JSCInlines.h"
 
 namespace JSC {
@@ -46,3 +48,5 @@ JSWebAssemblyCompileError::JSWebAssemblyCompileError(VM& vm, Structure* structur
 const ClassInfo JSWebAssemblyCompileError::s_info = { "WebAssembly.CompileError", &Base::s_info, 0, CREATE_METHOD_TABLE(JSWebAssemblyCompileError) };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index 1a77efb..656b8d0 100644 (file)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "ErrorInstance.h"
 
 namespace JSC {
@@ -34,6 +36,10 @@ public:
     typedef ErrorInstance Base;
 
     static JSWebAssemblyCompileError* create(ExecState*, Structure*, const String&, bool);
+    static JSWebAssemblyCompileError* create(ExecState* exec, Structure* structure, JSValue message, bool useCurrentFrame)
+    {
+        return create(exec, structure, message.isUndefined() ? String() : message.toString(exec)->value(exec), useCurrentFrame);
+    }
 
     DECLARE_INFO;
 
@@ -42,3 +48,5 @@ protected:
 };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index bd159bb..b1da4e2 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "JSWebAssemblyInstance.h"
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "JSCInlines.h"
 
 namespace JSC {
@@ -69,3 +71,5 @@ void JSWebAssemblyInstance::visitChildren(JSCell* cell, SlotVisitor& visitor)
 const ClassInfo JSWebAssemblyInstance::s_info = { "WebAssembly.Instance", &Base::s_info, 0, CREATE_METHOD_TABLE(JSWebAssemblyInstance) };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index da4bf80..b21e45f 100644 (file)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "JSDestructibleObject.h"
 #include "JSObject.h"
 
@@ -47,3 +49,5 @@ protected:
 };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index 6a465de..d56a2c7 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "JSWebAssemblyMemory.h"
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "JSCInlines.h"
 
 namespace JSC {
@@ -69,3 +71,5 @@ void JSWebAssemblyMemory::visitChildren(JSCell* cell, SlotVisitor& visitor)
 const ClassInfo JSWebAssemblyMemory::s_info = { "WebAssembly.Memory", &Base::s_info, 0, CREATE_METHOD_TABLE(JSWebAssemblyMemory) };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index a965a99..b36187b 100644 (file)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "JSDestructibleObject.h"
 #include "JSObject.h"
 
@@ -47,3 +49,5 @@ protected:
 };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index edc54cc..f28a4fc 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "JSWebAssemblyModule.h"
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "JSCInlines.h"
 
 namespace JSC {
@@ -69,3 +71,5 @@ void JSWebAssemblyModule::visitChildren(JSCell* cell, SlotVisitor& visitor)
 const ClassInfo JSWebAssemblyModule::s_info = { "WebAssembly.Module", &Base::s_info, 0, CREATE_METHOD_TABLE(JSWebAssemblyModule) };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index 7723211..be7f692 100644 (file)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "JSDestructibleObject.h"
 #include "JSObject.h"
 
@@ -47,3 +49,5 @@ protected:
 };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index 8ce2e79..3121efb 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "JSWebAssemblyRuntimeError.h"
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "JSCInlines.h"
 
 namespace JSC {
@@ -46,3 +48,5 @@ JSWebAssemblyRuntimeError::JSWebAssemblyRuntimeError(VM& vm, Structure* structur
 const ClassInfo JSWebAssemblyRuntimeError::s_info = { "WebAssembly.RuntimeError", &Base::s_info, 0, CREATE_METHOD_TABLE(JSWebAssemblyRuntimeError) };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index c12a1fa..7ebe7c4 100644 (file)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "ErrorInstance.h"
 
 namespace JSC {
@@ -34,6 +36,10 @@ public:
     typedef ErrorInstance Base;
 
     static JSWebAssemblyRuntimeError* create(ExecState*, Structure*, const String&, bool);
+    static JSWebAssemblyRuntimeError* create(ExecState* exec, Structure* structure, JSValue message, bool useCurrentFrame)
+    {
+        return create(exec, structure, message.isUndefined() ? String() : message.toString(exec)->value(exec), useCurrentFrame);
+    }
 
     DECLARE_INFO;
 
@@ -42,3 +48,5 @@ protected:
 };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index 23d5258..cb5e918 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "JSWebAssemblyTable.h"
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "JSCInlines.h"
 
 namespace JSC {
@@ -69,3 +71,5 @@ void JSWebAssemblyTable::visitChildren(JSCell* cell, SlotVisitor& visitor)
 const ClassInfo JSWebAssemblyTable::s_info = { "WebAssembly.Table", &Base::s_info, 0, CREATE_METHOD_TABLE(JSWebAssemblyTable) };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index d399f9e..01e68dd 100644 (file)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "JSDestructibleObject.h"
 #include "JSObject.h"
 
@@ -47,3 +49,5 @@ protected:
 };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index d17864c..67e6d95 100644 (file)
 #include "config.h"
 #include "WebAssemblyCompileErrorConstructor.h"
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "FunctionPrototype.h"
 #include "JSCInlines.h"
+#include "JSWebAssemblyCompileError.h"
 #include "WebAssemblyCompileErrorPrototype.h"
 
 #include "WebAssemblyCompileErrorConstructor.lut.h"
@@ -43,9 +46,12 @@ const ClassInfo WebAssemblyCompileErrorConstructor::s_info = { "Function", &Base
 
 static EncodedJSValue JSC_HOST_CALL constructJSWebAssemblyCompileError(ExecState* state)
 {
-    VM& vm = state->vm();
+    auto& vm = state->vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
-    return JSValue::encode(throwException(state, scope, createError(state, ASCIILiteral("WebAssembly doesn't yet implement the CompileError constructor property"))));
+    JSValue message = state->argumentCount() ? state->argument(0) : jsUndefined();
+    auto* structure = InternalFunction::createSubclassStructure(state, state->newTarget(), asInternalFunction(state->callee())->globalObject()->WebAssemblyCompileErrorStructure());
+    RETURN_IF_EXCEPTION(scope, encodedJSValue());
+    return JSValue::encode(JSWebAssemblyCompileError::create(state, structure, message, false));
 }
 
 static EncodedJSValue JSC_HOST_CALL callJSWebAssemblyCompileError(ExecState* state)
@@ -67,12 +73,11 @@ Structure* WebAssemblyCompileErrorConstructor::createStructure(VM& vm, JSGlobalO
     return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
 }
 
-void WebAssemblyCompileErrorConstructor::finishCreation(VM& vm, WebAssemblyCompileErrorPrototype* prototype, Structure* structure)
+void WebAssemblyCompileErrorConstructor::finishCreation(VM& vm, WebAssemblyCompileErrorPrototype* prototype, Structure*)
 {
     Base::finishCreation(vm, ASCIILiteral("CompileError"));
-    putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
+    putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, ReadOnly | DontEnum | DontDelete);
     putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
-    m_CompileErrorStructure.set(vm, this, structure);
 }
 
 WebAssemblyCompileErrorConstructor::WebAssemblyCompileErrorConstructor(VM& vm, Structure* structure)
@@ -92,12 +97,6 @@ CallType WebAssemblyCompileErrorConstructor::getCallData(JSCell*, CallData& call
     return CallType::Host;
 }
 
-void WebAssemblyCompileErrorConstructor::visitChildren(JSCell* cell, SlotVisitor& visitor)
-{
-    auto* thisObject = jsCast<WebAssemblyCompileErrorConstructor*>(cell);
-    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-    Base::visitChildren(thisObject, visitor);
-    visitor.append(&thisObject->m_CompileErrorStructure);
-}
-
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index 7a524b9..d4856c9 100644 (file)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "InternalFunction.h"
 #include "JSObject.h"
 
@@ -42,8 +44,6 @@ public:
 
     DECLARE_INFO;
 
-    Structure* CompileErrorStructure() const { return m_CompileErrorStructure.get(); }
-
 protected:
     void finishCreation(VM&, WebAssemblyCompileErrorPrototype*, Structure*);
 
@@ -51,9 +51,8 @@ private:
     WebAssemblyCompileErrorConstructor(VM&, Structure*);
     static ConstructType getConstructData(JSCell*, ConstructData&);
     static CallType getCallData(JSCell*, CallData&);
-    static void visitChildren(JSCell*, SlotVisitor&);
-
-    WriteBarrier<Structure> m_CompileErrorStructure;
 };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index 993c496..0522e1f 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "WebAssemblyCompileErrorPrototype.h"
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "FunctionPrototype.h"
 #include "JSCInlines.h"
 
@@ -63,3 +65,5 @@ WebAssemblyCompileErrorPrototype::WebAssemblyCompileErrorPrototype(VM& vm, Struc
 }
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index 1a39c36..d329651 100644 (file)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "JSDestructibleObject.h"
 #include "JSObject.h"
 
@@ -48,3 +50,5 @@ private:
 };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index a56855a..85ce9aa 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "WebAssemblyInstanceConstructor.h"
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "FunctionPrototype.h"
 #include "JSCInlines.h"
 #include "WebAssemblyInstancePrototype.h"
@@ -101,3 +103,6 @@ void WebAssemblyInstanceConstructor::visitChildren(JSCell* cell, SlotVisitor& vi
 }
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
+
index 736bd8c..ddddf71 100644 (file)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "InternalFunction.h"
 #include "JSObject.h"
 
@@ -57,3 +59,5 @@ private:
 };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index ede3c79..4777a61 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "WebAssemblyInstancePrototype.h"
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "FunctionPrototype.h"
 #include "JSCInlines.h"
 
@@ -63,3 +65,5 @@ WebAssemblyInstancePrototype::WebAssemblyInstancePrototype(VM& vm, Structure* st
 }
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index 93b4ac7..ebdbe98 100644 (file)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "JSDestructibleObject.h"
 #include "JSObject.h"
 
@@ -48,3 +50,5 @@ private:
 };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index 1f6370d..ad525cf 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "WebAssemblyMemoryConstructor.h"
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "FunctionPrototype.h"
 #include "JSCInlines.h"
 #include "WebAssemblyMemoryPrototype.h"
@@ -101,3 +103,6 @@ void WebAssemblyMemoryConstructor::visitChildren(JSCell* cell, SlotVisitor& visi
 }
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
+
index 9525364..34cd120 100644 (file)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "InternalFunction.h"
 #include "JSObject.h"
 
@@ -57,3 +59,5 @@ private:
 };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index 60e4888..2418ff3 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "WebAssemblyMemoryPrototype.h"
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "FunctionPrototype.h"
 #include "JSCInlines.h"
 
@@ -63,3 +65,5 @@ WebAssemblyMemoryPrototype::WebAssemblyMemoryPrototype(VM& vm, Structure* struct
 }
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index 9d3f850..4219902 100644 (file)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "JSDestructibleObject.h"
 #include "JSObject.h"
 
@@ -48,3 +50,5 @@ private:
 };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index c838b3d..e97b011 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "WebAssemblyModuleConstructor.h"
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "FunctionPrototype.h"
 #include "JSCInlines.h"
 #include "WebAssemblyModulePrototype.h"
@@ -101,3 +103,6 @@ void WebAssemblyModuleConstructor::visitChildren(JSCell* cell, SlotVisitor& visi
 }
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
+
index 3aa4afa..56057a6 100644 (file)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "InternalFunction.h"
 #include "JSObject.h"
 
@@ -57,3 +59,5 @@ private:
 };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index 9db0ce9..2bb2b5e 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "WebAssemblyModulePrototype.h"
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "FunctionPrototype.h"
 #include "JSCInlines.h"
 
@@ -63,3 +65,5 @@ WebAssemblyModulePrototype::WebAssemblyModulePrototype(VM& vm, Structure* struct
 }
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index 8a713d5..d5b6279 100644 (file)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "JSDestructibleObject.h"
 #include "JSObject.h"
 
@@ -48,3 +50,5 @@ private:
 };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
diff --git a/Source/JavaScriptCore/wasm/js/WebAssemblyPrototype.cpp b/Source/JavaScriptCore/wasm/js/WebAssemblyPrototype.cpp
new file mode 100644 (file)
index 0000000..2d4e004
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebAssemblyPrototype.h"
+
+#if ENABLE(WEBASSEMBLY)
+
+#include "FunctionPrototype.h"
+#include "JSCInlines.h"
+
+namespace JSC {
+
+static EncodedJSValue JSC_HOST_CALL webAssemblyFunctionValidate(ExecState* state)
+{
+    VM& vm = state->vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+    return JSValue::encode(throwException(state, scope, createError(state, ASCIILiteral("WebAssembly doesn't yet implement the validate function property"))));
+}
+
+static EncodedJSValue JSC_HOST_CALL webAssemblyFunctionCompile(ExecState* state)
+{
+    VM& vm = state->vm();
+    auto scope = DECLARE_THROW_SCOPE(vm);
+    return JSValue::encode(throwException(state, scope, createError(state, ASCIILiteral("WebAssembly doesn't yet implement the compile function property"))));
+}
+
+}
+
+#include "WebAssemblyPrototype.lut.h"
+
+namespace JSC {
+
+const ClassInfo WebAssemblyPrototype::s_info = { "WebAssembly.prototype", &Base::s_info, &prototypeTableWebAssembly, CREATE_METHOD_TABLE(WebAssemblyPrototype) };
+
+/* Source for WebAssemblyPrototype.lut.h
+ @begin prototypeTableWebAssembly
+ validate webAssemblyFunctionValidate  DontEnum|Function 1
+ compile  webAssemblyFunctionCompile   DontEnum|Function 1
+ @end
+ */
+
+WebAssemblyPrototype* WebAssemblyPrototype::create(VM& vm, JSGlobalObject*, Structure* structure)
+{
+    auto* object = new (NotNull, allocateCell<WebAssemblyPrototype>(vm.heap)) WebAssemblyPrototype(vm, structure);
+    object->finishCreation(vm);
+    return object;
+}
+
+Structure* WebAssemblyPrototype::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
+{
+    return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
+}
+
+void WebAssemblyPrototype::finishCreation(VM& vm)
+{
+    Base::finishCreation(vm);
+}
+
+WebAssemblyPrototype::WebAssemblyPrototype(VM& vm, Structure* structure)
+    : Base(vm, structure)
+{
+}
+
+} // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
 
 #pragma once
 
+#if ENABLE(WEBASSEMBLY)
+
+#include "JSDestructibleObject.h"
 #include "JSObject.h"
 
 namespace JSC {
 
-class WebAssemblyObject : public JSNonFinalObject {
+class WebAssemblyPrototype : public JSNonFinalObject {
 public:
     typedef JSNonFinalObject Base;
+    static const unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
 
-    static WebAssemblyObject* create(VM&, JSGlobalObject*, Structure*);
+    static WebAssemblyPrototype* create(VM&, JSGlobalObject*, Structure*);
     static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
 
     DECLARE_INFO;
 
 protected:
-    void finishCreation(VM&, JSGlobalObject*);
+    void finishCreation(VM&);
 
 private:
-    WebAssemblyObject(VM&, Structure*);
+    WebAssemblyPrototype(VM&, Structure*);
 };
 
-// Name, functionLength
-#define FOR_EACH_WASM_CONSTRUCTOR_PROPERTY(DO) \
-    DO(Module, 1) \
-    DO(Instance, 2) \
-    DO(Memory, 1) \
-    DO(Table, 1) \
-    DO(CompileError, 1) \
-    DO(RuntimeError, 1)
-
-// Name, functionLength
-#define FOR_EACH_WASM_FUNCTION_PROPERTY(DO) \
-    DO(validate, 1) \
-    DO(compile, 1)
-
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index b3067e5..5528022 100644 (file)
 #include "config.h"
 #include "WebAssemblyRuntimeErrorConstructor.h"
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "FunctionPrototype.h"
 #include "JSCInlines.h"
+#include "JSWebAssemblyRuntimeError.h"
 #include "WebAssemblyRuntimeErrorPrototype.h"
 
 #include "WebAssemblyRuntimeErrorConstructor.lut.h"
@@ -43,9 +46,12 @@ const ClassInfo WebAssemblyRuntimeErrorConstructor::s_info = { "Function", &Base
 
 static EncodedJSValue JSC_HOST_CALL constructJSWebAssemblyRuntimeError(ExecState* state)
 {
-    VM& vm = state->vm();
+    auto& vm = state->vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
-    return JSValue::encode(throwException(state, scope, createError(state, ASCIILiteral("WebAssembly doesn't yet implement the RuntimeError constructor property"))));
+    JSValue message = state->argumentCount() ? state->argument(0) : jsUndefined();
+    auto* structure = InternalFunction::createSubclassStructure(state, state->newTarget(), asInternalFunction(state->callee())->globalObject()->WebAssemblyRuntimeErrorStructure());
+    RETURN_IF_EXCEPTION(scope, encodedJSValue());
+    return JSValue::encode(JSWebAssemblyRuntimeError::create(state, structure, message, false));
 }
 
 static EncodedJSValue JSC_HOST_CALL callJSWebAssemblyRuntimeError(ExecState* state)
@@ -67,12 +73,11 @@ Structure* WebAssemblyRuntimeErrorConstructor::createStructure(VM& vm, JSGlobalO
     return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
 }
 
-void WebAssemblyRuntimeErrorConstructor::finishCreation(VM& vm, WebAssemblyRuntimeErrorPrototype* prototype, Structure* structure)
+void WebAssemblyRuntimeErrorConstructor::finishCreation(VM& vm, WebAssemblyRuntimeErrorPrototype* prototype, Structure*)
 {
     Base::finishCreation(vm, ASCIILiteral("RuntimeError"));
-    putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
+    putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, ReadOnly | DontEnum | DontDelete);
     putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
-    m_RuntimeErrorStructure.set(vm, this, structure);
 }
 
 WebAssemblyRuntimeErrorConstructor::WebAssemblyRuntimeErrorConstructor(VM& vm, Structure* structure)
@@ -92,12 +97,6 @@ CallType WebAssemblyRuntimeErrorConstructor::getCallData(JSCell*, CallData& call
     return CallType::Host;
 }
 
-void WebAssemblyRuntimeErrorConstructor::visitChildren(JSCell* cell, SlotVisitor& visitor)
-{
-    auto* thisObject = jsCast<WebAssemblyRuntimeErrorConstructor*>(cell);
-    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-    Base::visitChildren(thisObject, visitor);
-    visitor.append(&thisObject->m_RuntimeErrorStructure);
-}
-
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index 9fc91c7..be419d7 100644 (file)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "InternalFunction.h"
 #include "JSObject.h"
 
@@ -42,8 +44,6 @@ public:
 
     DECLARE_INFO;
 
-    Structure* RuntimeErrorStructure() const { return m_RuntimeErrorStructure.get(); }
-
 protected:
     void finishCreation(VM&, WebAssemblyRuntimeErrorPrototype*, Structure*);
 
@@ -51,9 +51,8 @@ private:
     WebAssemblyRuntimeErrorConstructor(VM&, Structure*);
     static ConstructType getConstructData(JSCell*, ConstructData&);
     static CallType getCallData(JSCell*, CallData&);
-    static void visitChildren(JSCell*, SlotVisitor&);
-
-    WriteBarrier<Structure> m_RuntimeErrorStructure;
 };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index dbc6677..b374dbd 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "WebAssemblyRuntimeErrorPrototype.h"
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "FunctionPrototype.h"
 #include "JSCInlines.h"
 
@@ -63,3 +65,5 @@ WebAssemblyRuntimeErrorPrototype::WebAssemblyRuntimeErrorPrototype(VM& vm, Struc
 }
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index a729fb0..2077fa9 100644 (file)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "JSDestructibleObject.h"
 #include "JSObject.h"
 
@@ -48,3 +50,5 @@ private:
 };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index 053d8bf..4b6608c 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "WebAssemblyTableConstructor.h"
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "FunctionPrototype.h"
 #include "JSCInlines.h"
 #include "WebAssemblyTablePrototype.h"
@@ -101,3 +103,6 @@ void WebAssemblyTableConstructor::visitChildren(JSCell* cell, SlotVisitor& visit
 }
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
+
index 894b514..e08e735 100644 (file)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "InternalFunction.h"
 #include "JSObject.h"
 
@@ -57,3 +59,5 @@ private:
 };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index 5c32097..7aa394b 100644 (file)
@@ -26,6 +26,8 @@
 #include "config.h"
 #include "WebAssemblyTablePrototype.h"
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "FunctionPrototype.h"
 #include "JSCInlines.h"
 
@@ -63,3 +65,5 @@ WebAssemblyTablePrototype::WebAssemblyTablePrototype(VM& vm, Structure* structur
 }
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)
index c63e001..c5b1ef8 100644 (file)
@@ -25,6 +25,8 @@
 
 #pragma once
 
+#if ENABLE(WEBASSEMBLY)
+
 #include "JSDestructibleObject.h"
 #include "JSObject.h"
 
@@ -48,3 +50,5 @@ private:
 };
 
 } // namespace JSC
+
+#endif // ENABLE(WEBASSEMBLY)