Changeset 207650 in webkit


Ignore:
Timestamp:
Oct 20, 2016 6:19:24 PM (8 years ago)
Author:
jfbastien@apple.com
Message:

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:
Location:
trunk
Files:
1 deleted
44 edited
3 copied
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r207628 r207650  
     12016-10-20  JF Bastien  <jfbastien@apple.com>
     2
     3        WebAssembly API: implement exception constructors properly
     4
     5         - Rename WebAssemblyObject to JSWebAssembly for consistency.
     6         - WebAssembly object now has its own prototype: add WebAssemblyPrototype, and
     7           use it to register JSWebAssembly's function properties through auto-generated
     8           .lut.h, instead of manually.
     9         - The error constructors used to throw (e.g. `new WebAssembly.CompileError()`).
     10         - Register WebAssembly's constructors from the global object, and hold a
     11           reference to their structure and prototype so that invoking the constructor
     12           can use the structure directly from the global object.
     13         - Add a prototype base field to global object creation. Previous ones all had
     14           Object's prototype as their base, but WebAssembly's error constructors have
     15           Error as their base.
     16         - Test for the error object's correctness.
     17         - Add missing #if ENABLE(WEBASSEMBLY)
     18
     19        WebAssembly API: implement exception constructors properly
     20        https://bugs.webkit.org/show_bug.cgi?id=163699
     21
     22        Reviewed by Keith Miller.
     23
     24        * wasm/js-api/test_basic_api.js:
     25        (const.c.in.constructorProperties): more tests
     26
    1272016-10-20  Caitlin Potter  <caitp@igalia.com>
    228
  • trunk/JSTests/wasm/js-api/test_basic_api.js

    r207572 r207650  
    2828assert.eq(String(WebAssembly), "[object WebAssembly]");
    2929assert.isUndef(WebAssembly.length);
     30assert.eq(WebAssembly instanceof Object, true);
     31assert.throws(() => WebAssembly(), TypeError, `WebAssembly is not a function. (In 'WebAssembly()', 'WebAssembly' is an instance of WebAssembly)`);
     32assert.throws(() => new WebAssembly(), TypeError, `WebAssembly is not a constructor (evaluating 'new WebAssembly()')`);
    3033
    3134for (const f in functionProperties) {
     
    4043    assert.eq(WebAssembly[c].length, constructorProperties[c].length);
    4144    checkOwnPropertyDescriptor(WebAssembly, c, constructorProperties[c]);
    42     // Check the constructor's prototype.
    4345    checkOwnPropertyDescriptor(WebAssembly[c], "prototype", { typeofvalue: "object", writable: false, configurable: false, enumerable: false });
    44     assert.eq(String(WebAssembly[c].prototype), `[object WebAssembly.${c}.prototype]`);
    4546    assert.throws(() => WebAssembly[c](), TypeError, `calling WebAssembly.${c} constructor without new is invalid`);
     47    if (constructorProperties[c].isError) {
     48        const e = new WebAssembly[c];
     49        assert.eq(e instanceof WebAssembly[c], true);
     50        assert.eq(e instanceof Error, true);
     51        assert.eq(e instanceof TypeError, false);
     52        assert.eq(e.message, "");
     53        assert.eq(typeof e.stack, "string");
     54        const sillyString = "uh-oh!";
     55        const e2 = new WebAssembly[c](sillyString);
     56        assert.eq(e2.message, sillyString);
     57    }
    4658}
    4759
     
    5264}
    5365
    54 for (const c in constructorProperties)
    55     assert.throws(() => new WebAssembly[c](), Error, `WebAssembly doesn't yet implement the ${c} constructor property`);
     66for (const c in constructorProperties) {
     67    if (!constructorProperties[c].isError)
     68        assert.throws(() => new WebAssembly[c](), Error, `WebAssembly doesn't yet implement the ${c} constructor property`);
     69}
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r207572 r207650  
    862862
    863863    wasm/JSWASMModule.cpp
     864    wasm/JSWebAssembly.cpp
    864865    wasm/WASMB3IRGenerator.cpp
    865866    wasm/WASMCallingConvention.cpp
     
    867868    wasm/WASMModuleParser.cpp
    868869    wasm/WASMPlan.cpp
    869     wasm/WebAssemblyObject.cpp
    870870
    871871    wasm/js/JSWebAssemblyCompileError.cpp
     
    883883    wasm/js/WebAssemblyModuleConstructor.cpp
    884884    wasm/js/WebAssemblyModulePrototype.cpp
     885    wasm/js/WebAssemblyPrototype.cpp
    885886    wasm/js/WebAssemblyRuntimeErrorConstructor.cpp
    886887    wasm/js/WebAssemblyRuntimeErrorPrototype.cpp
     
    947948    wasm/js/WebAssemblyModuleConstructor.cpp
    948949    wasm/js/WebAssemblyModulePrototype.cpp
     950    wasm/js/WebAssemblyPrototype.cpp
    949951    wasm/js/WebAssemblyRuntimeErrorConstructor.cpp
    950952    wasm/js/WebAssemblyRuntimeErrorPrototype.cpp
  • trunk/Source/JavaScriptCore/ChangeLog

    r207642 r207650  
     12016-10-20  JF Bastien  <jfbastien@apple.com>
     2
     3        WebAssembly API: implement exception constructors properly
     4
     5         - Rename WebAssemblyObject to JSWebAssembly for consistency.
     6         - WebAssembly object now has its own prototype: add WebAssemblyPrototype, and
     7           use it to register JSWebAssembly's function properties through auto-generated
     8           .lut.h, instead of manually.
     9         - The error constructors used to throw (e.g. `new WebAssembly.CompileError()`).
     10         - Register WebAssembly's constructors from the global object, and hold a
     11           reference to their structure and prototype so that invoking the constructor
     12           can use the structure directly from the global object.
     13         - Add a prototype base field to global object creation. Previous ones all had
     14           Object's prototype as their base, but WebAssembly's error constructors have
     15           Error as their base.
     16         - Test for the error object's correctness.
     17         - Add missing #if ENABLE(WEBASSEMBLY)
     18
     19        WebAssembly API: implement exception constructors properly
     20        https://bugs.webkit.org/show_bug.cgi?id=163699
     21
     22        Reviewed by Keith Miller.
     23
     24        * CMakeLists.txt: rename WebAssemblyObject -> JSWebAssembly; add a .lut.h file
     25        * DerivedSources.make: new .lut.h file
     26        * JavaScriptCore.xcodeproj/project.pbxproj: ditto
     27        * runtime/JSGlobalObject.cpp: new prototypeBase macro
     28        (JSC::JSGlobalObject::init): register WebAssembly constructors here
     29        (JSC::JSGlobalObject::visitChildren): use the macro to visit
     30        * runtime/JSGlobalObject.h: declare the WebAssembly constructor macro
     31        * wasm/JSWebAssembly.cpp: Copied from Source/JavaScriptCore/wasm/WebAssemblyObject.h.
     32        (JSC::JSWebAssembly::create):
     33        (JSC::JSWebAssembly::createStructure):
     34        (JSC::JSWebAssembly::finishCreation):
     35        (JSC::JSWebAssembly::JSWebAssembly):
     36        * wasm/JSWebAssembly.h: Renamed from Source/JavaScriptCore/wasm/WebAssemblyObject.h.
     37        * wasm/WebAssemblyObject.cpp: Removed.
     38        * wasm/js/JSWebAssemblyCompileError.cpp:
     39        * wasm/js/JSWebAssemblyCompileError.h:
     40        (JSC::JSWebAssemblyCompileError::create): string convenience
     41        * wasm/js/JSWebAssemblyInstance.cpp:
     42        * wasm/js/JSWebAssemblyInstance.h:
     43        * wasm/js/JSWebAssemblyMemory.cpp:
     44        * wasm/js/JSWebAssemblyMemory.h:
     45        * wasm/js/JSWebAssemblyModule.cpp:
     46        * wasm/js/JSWebAssemblyModule.h:
     47        * wasm/js/JSWebAssemblyRuntimeError.cpp:
     48        * wasm/js/JSWebAssemblyRuntimeError.h:
     49        (JSC::JSWebAssemblyRuntimeError::create): string convenience
     50        * wasm/js/JSWebAssemblyTable.cpp:
     51        * wasm/js/JSWebAssemblyTable.h:
     52        * wasm/js/WebAssemblyCompileErrorConstructor.cpp:
     53        (JSC::constructJSWebAssemblyCompileError):don't throw, create the object
     54        (JSC::WebAssemblyCompileErrorConstructor::finishCreation):no need for the structure, it's on the global object
     55        * wasm/js/WebAssemblyCompileErrorConstructor.h:
     56        * wasm/js/WebAssemblyCompileErrorPrototype.cpp:
     57        * wasm/js/WebAssemblyCompileErrorPrototype.h:
     58        * wasm/js/WebAssemblyInstanceConstructor.cpp:
     59        * wasm/js/WebAssemblyInstanceConstructor.h:
     60        * wasm/js/WebAssemblyInstancePrototype.cpp:
     61        * wasm/js/WebAssemblyInstancePrototype.h:
     62        * wasm/js/WebAssemblyMemoryConstructor.cpp:
     63        * wasm/js/WebAssemblyMemoryConstructor.h:
     64        * wasm/js/WebAssemblyMemoryPrototype.cpp:
     65        * wasm/js/WebAssemblyMemoryPrototype.h:
     66        * wasm/js/WebAssemblyModuleConstructor.cpp:
     67        * wasm/js/WebAssemblyModuleConstructor.h:
     68        * wasm/js/WebAssemblyModulePrototype.cpp:
     69        * wasm/js/WebAssemblyModulePrototype.h:
     70        * wasm/js/WebAssemblyPrototype.cpp: Copied from Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorPrototype.cpp.
     71        (JSC::webAssemblyFunctionValidate):
     72        (JSC::webAssemblyFunctionCompile):
     73        (JSC::WebAssemblyPrototype::create):
     74        (JSC::WebAssemblyPrototype::createStructure):
     75        (JSC::WebAssemblyPrototype::finishCreation):
     76        (JSC::WebAssemblyPrototype::WebAssemblyPrototype):
     77        * wasm/js/WebAssemblyPrototype.h: Copied from Source/JavaScriptCore/wasm/js/WebAssemblyMemoryPrototype.h.
     78        * wasm/js/WebAssemblyRuntimeErrorConstructor.cpp:
     79        (JSC::constructJSWebAssemblyRuntimeError):don't throw, create the object
     80        (JSC::WebAssemblyRuntimeErrorConstructor::finishCreation):no need for the structure, it's on the global object
     81        * wasm/js/WebAssemblyRuntimeErrorConstructor.h:
     82        * wasm/js/WebAssemblyRuntimeErrorPrototype.cpp:
     83        * wasm/js/WebAssemblyRuntimeErrorPrototype.h:
     84        * wasm/js/WebAssemblyTableConstructor.cpp:
     85        * wasm/js/WebAssemblyTableConstructor.h:
     86        * wasm/js/WebAssemblyTablePrototype.cpp:
     87        * wasm/js/WebAssemblyTablePrototype.h:
     88
    1892016-10-19  Myles C. Maxfield  <mmaxfield@apple.com>
    290
  • trunk/Source/JavaScriptCore/DerivedSources.make

    r207572 r207650  
    169169    WebAssemblyModuleConstructor.lut.h \
    170170    WebAssemblyModulePrototype.lut.h \
     171    WebAssemblyPrototype.lut.h \
    171172    WebAssemblyRuntimeErrorConstructor.lut.h \
    172173    WebAssemblyRuntimeErrorPrototype.lut.h \
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r207572 r207650  
    18801880                A7FCC26D17A0B6AA00786D1A /* FTLSwitchCase.h in Headers */ = {isa = PBXBuildFile; fileRef = A7FCC26C17A0B6AA00786D1A /* FTLSwitchCase.h */; settings = {ATTRIBUTES = (Private, ); }; };
    18811881                A8A4748E151A8306004123FF /* libWTF.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A8A4748D151A8306004123FF /* libWTF.a */; };
    1882                 AD2FCB881DAEBF3C00B3E736 /* WebAssemblyObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD2FCB861DAEBF3700B3E736 /* WebAssemblyObject.cpp */; };
    1883                 AD2FCB891DAEBF3F00B3E736 /* WebAssemblyObject.h in Headers */ = {isa = PBXBuildFile; fileRef = AD2FCB871DAEBF3700B3E736 /* WebAssemblyObject.h */; };
    18841882                AD2FCBE21DB58DAD00B3E736 /* JSWebAssemblyCompileError.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD2FCBA61DB58DA400B3E736 /* JSWebAssemblyCompileError.cpp */; };
    18851883                AD2FCBE31DB58DAD00B3E736 /* JSWebAssemblyCompileError.h in Headers */ = {isa = PBXBuildFile; fileRef = AD2FCBA71DB58DA400B3E736 /* JSWebAssemblyCompileError.h */; };
     
    19301928                AD2FCC201DB59CB200B3E736 /* WebAssemblyTableConstructor.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = AD2FCC141DB59C5900B3E736 /* WebAssemblyTableConstructor.lut.h */; };
    19311929                AD2FCC211DB59CB200B3E736 /* WebAssemblyTablePrototype.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = AD2FCC151DB59C5900B3E736 /* WebAssemblyTablePrototype.lut.h */; };
     1930                AD2FCC2C1DB838FD00B3E736 /* WebAssemblyPrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD2FCC261DB838C400B3E736 /* WebAssemblyPrototype.cpp */; };
     1931                AD2FCC2D1DB838FD00B3E736 /* WebAssemblyPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = AD2FCC271DB838C400B3E736 /* WebAssemblyPrototype.h */; };
     1932                AD2FCC301DB83D4900B3E736 /* JSWebAssembly.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD2FCC2E1DB839F700B3E736 /* JSWebAssembly.cpp */; };
     1933                AD2FCC311DB83D4900B3E736 /* JSWebAssembly.h in Headers */ = {isa = PBXBuildFile; fileRef = AD2FCC2F1DB839F700B3E736 /* JSWebAssembly.h */; };
    19321934                AD86A93E1AA4D88D002FE77F /* WeakGCMapInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = AD86A93D1AA4D87C002FE77F /* WeakGCMapInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
    19331935                ADDB1F6318D77DBE009B58A8 /* OpaqueRootSet.h in Headers */ = {isa = PBXBuildFile; fileRef = ADDB1F6218D77DB7009B58A8 /* OpaqueRootSet.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    42604262                A8E894330CD0603F00367179 /* JSGlobalObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalObject.h; sourceTree = "<group>"; };
    42614263                AD1CF06816DCAB2D00B97123 /* PropertyTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PropertyTable.cpp; sourceTree = "<group>"; };
    4262                 AD2FCB861DAEBF3700B3E736 /* WebAssemblyObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebAssemblyObject.cpp; sourceTree = "<group>"; };
    4263                 AD2FCB871DAEBF3700B3E736 /* WebAssemblyObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAssemblyObject.h; sourceTree = "<group>"; };
    42644264                AD2FCB8C1DB5844000B3E736 /* JSWebAssemblyModule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSWebAssemblyModule.cpp; path = js/JSWebAssemblyModule.cpp; sourceTree = "<group>"; };
    42654265                AD2FCB8D1DB5844000B3E736 /* JSWebAssemblyModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSWebAssemblyModule.h; path = js/JSWebAssemblyModule.h; sourceTree = "<group>"; };
     
    43104310                AD2FCC141DB59C5900B3E736 /* WebAssemblyTableConstructor.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAssemblyTableConstructor.lut.h; sourceTree = "<group>"; };
    43114311                AD2FCC151DB59C5900B3E736 /* WebAssemblyTablePrototype.lut.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAssemblyTablePrototype.lut.h; sourceTree = "<group>"; };
     4312                AD2FCC261DB838C400B3E736 /* WebAssemblyPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = WebAssemblyPrototype.cpp; path = js/WebAssemblyPrototype.cpp; sourceTree = "<group>"; };
     4313                AD2FCC271DB838C400B3E736 /* WebAssemblyPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebAssemblyPrototype.h; path = js/WebAssemblyPrototype.h; sourceTree = "<group>"; };
     4314                AD2FCC2E1DB839F700B3E736 /* JSWebAssembly.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWebAssembly.cpp; sourceTree = "<group>"; };
     4315                AD2FCC2F1DB839F700B3E736 /* JSWebAssembly.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWebAssembly.h; sourceTree = "<group>"; };
    43124316                AD86A93D1AA4D87C002FE77F /* WeakGCMapInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakGCMapInlines.h; sourceTree = "<group>"; };
    43134317                ADDB1F6218D77DB7009B58A8 /* OpaqueRootSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpaqueRootSet.h; sourceTree = "<group>"; };
     
    58045808                        isa = PBXGroup;
    58055809                        children = (
     5810                                AD2FCC2E1DB839F700B3E736 /* JSWebAssembly.cpp */,
     5811                                AD2FCC2F1DB839F700B3E736 /* JSWebAssembly.h */,
    58065812                                AD2FCB8A1DB5840000B3E736 /* js */,
    5807                                 AD2FCB861DAEBF3700B3E736 /* WebAssemblyObject.cpp */,
    5808                                 AD2FCB871DAEBF3700B3E736 /* WebAssemblyObject.h */,
    58095813                                7B98D1341B60CD5A0023B1A4 /* JSWASMModule.cpp */,
    58105814                                7B98D1351B60CD5A0023B1A4 /* JSWASMModule.h */,
     
    73137317                        isa = PBXGroup;
    73147318                        children = (
     7319                                AD2FCC261DB838C400B3E736 /* WebAssemblyPrototype.cpp */,
     7320                                AD2FCC271DB838C400B3E736 /* WebAssemblyPrototype.h */,
    73157321                                AD2FCBA61DB58DA400B3E736 /* JSWebAssemblyCompileError.cpp */,
    73167322                                AD2FCBA71DB58DA400B3E736 /* JSWebAssemblyCompileError.h */,
     
    76167622                                0FD8A31417D4326C00CA2C40 /* CodeBlockSet.h in Headers */,
    76177623                                0F96EBB316676EF6008BADE3 /* CodeBlockWithJITType.h in Headers */,
    7618                                 AD2FCB891DAEBF3F00B3E736 /* WebAssemblyObject.h in Headers */,
    76197624                                A77F1822164088B200640A47 /* CodeCache.h in Headers */,
    76207625                                99CC0B6318BE9950006CEBCC /* CodeGeneratorReplayInputs.py in Headers */,
     
    77407745                                0FFFC95A14EF90A900C72532 /* DFGCSEPhase.h in Headers */,
    77417746                                0F2FC77316E12F740038D976 /* DFGDCEPhase.h in Headers */,
     7747                                AD2FCC311DB83D4900B3E736 /* JSWebAssembly.h in Headers */,
    77427748                                0F8F2B9A172F0501007DBDA5 /* DFGDesiredIdentifiers.h in Headers */,
    77437749                                8B9F6D561D5912FA001C739F /* IterationKind.h in Headers */,
     
    85118517                                A5BA15F0182345AF00A82E69 /* RemoteInspectionTarget.h in Headers */,
    85128518                                A5BA15EB182340B400A82E69 /* RemoteConnectionToTarget.h in Headers */,
     8519                                AD2FCC2D1DB838FD00B3E736 /* WebAssemblyPrototype.h in Headers */,
    85138520                                A5BA15ED182340B400A82E69 /* RemoteInspectorXPCConnection.h in Headers */,
    85148521                                0F24E55117EE274900ABB217 /* Repatch.h in Headers */,
     
    94519458                                0FF2CD5B1B61A4F8004955A8 /* DFGMultiGetByOffsetData.cpp in Sources */,
    94529459                                A737810D1799EA2E00817533 /* DFGNaturalLoops.cpp in Sources */,
     9460                                AD2FCC301DB83D4900B3E736 /* JSWebAssembly.cpp in Sources */,
    94539461                                79B00CBE1C6AB07E0088C65D /* ProxyObject.cpp in Sources */,
    94549462                                792CB3491C4EED5C00D13AF3 /* PCToCodeOriginMap.cpp in Sources */,
     
    97189726                                1440FCE40A51E46B0005F061 /* JSClassRef.cpp in Sources */,
    97199727                                86E3C616167BABEE006D760A /* JSContext.mm in Sources */,
     9728                                AD2FCC2C1DB838FD00B3E736 /* WebAssemblyPrototype.cpp in Sources */,
    97209729                                14BD5A300A3E91F600BAF59C /* JSContextRef.cpp in Sources */,
    97219730                                A72028B61797601E0098028C /* JSCTestRunnerUtils.cpp in Sources */,
     
    99399948                                0FE050271AA9095600D33B33 /* ScopedArguments.cpp in Sources */,
    99409949                                0FE0502F1AAA806900D33B33 /* ScopedArgumentsTable.cpp in Sources */,
    9941                                 AD2FCB881DAEBF3C00B3E736 /* WebAssemblyObject.cpp in Sources */,
    99429950                                992ABCF91BEA9BD2006403A0 /* RemoteAutomationTarget.cpp in Sources */,
    99439951                                0FE0502A1AA9095600D33B33 /* ScopeOffset.cpp in Sources */,
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r207572 r207650  
    109109#include "JSWeakMap.h"
    110110#include "JSWeakSet.h"
     111#include "JSWebAssembly.h"
    111112#include "JSWithScope.h"
    112113#include "LazyClassStructureInlines.h"
     
    155156#include "WeakSetConstructor.h"
    156157#include "WeakSetPrototype.h"
    157 #include "WebAssemblyObject.h"
    158158#include <wtf/RandomNumber.h>
    159159
     
    542542    putDirectWithoutTransition(vm, vm.propertyNames->parseInt, m_parseIntFunction.get(), DontEnum);
    543543
    544 #define CREATE_PROTOTYPE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
    545 m_ ## lowerName ## Prototype.set(vm, this, capitalName##Prototype::create(vm, this, capitalName##Prototype::createStructure(vm, this, m_objectPrototype.get()))); \
     544#define CREATE_PROTOTYPE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
     545m_ ## lowerName ## Prototype.set(vm, this, capitalName##Prototype::create(vm, this, capitalName##Prototype::createStructure(vm, this, m_ ## prototypeBase ## Prototype.get()))); \
    546546m_ ## properName ## Structure.set(vm, this, instanceType::createStructure(vm, this, m_ ## lowerName ## Prototype.get()));
    547547   
     
    550550#undef CREATE_PROTOTYPE_FOR_SIMPLE_TYPE
    551551
    552 #define CREATE_PROTOTYPE_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
     552#define CREATE_PROTOTYPE_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
    553553    m_ ## properName ## Structure.initLater(\
    554554        [] (LazyClassStructure::Initializer& init) { \
    555             init.setPrototype(capitalName##Prototype::create(init.vm, init.global, capitalName##Prototype::createStructure(init.vm, init.global, init.global->m_objectPrototype.get()))); \
     555            init.setPrototype(capitalName##Prototype::create(init.vm, init.global, capitalName##Prototype::createStructure(init.vm, init.global, init.global->m_ ## prototypeBase ## Prototype.get()))); \
    556556            init.setStructure(instanceType::createStructure(init.vm, init.global, init.prototype)); \
    557557            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())); \
     
    564564    m_iteratorPrototype.set(vm, this, IteratorPrototype::create(vm, this, IteratorPrototype::createStructure(vm, this, m_objectPrototype.get())));
    565565
    566 #define CREATE_PROTOTYPE_FOR_DERIVED_ITERATOR_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
     566#define CREATE_PROTOTYPE_FOR_DERIVED_ITERATOR_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
    567567    m_ ## lowerName ## Structure.initLater( \
    568568        [] (const Initializer<Structure>& init) { \
     
    591591    m_regExpConstructor.set(vm, this, RegExpConstructor::create(vm, RegExpConstructor::createStructure(vm, this, m_functionPrototype.get()), m_regExpPrototype.get(), m_speciesGetterSetter.get()));
    592592   
    593 #define CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
     593#define CREATE_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
    594594capitalName ## Constructor* lowerName ## Constructor = capitalName ## Constructor::create(vm, capitalName ## Constructor::createStructure(vm, this, m_functionPrototype.get()), m_ ## lowerName ## Prototype.get(), m_speciesGetterSetter.get()); \
    595595m_ ## lowerName ## Prototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, lowerName ## Constructor, DontEnum); \
     
    647647    putDirectWithoutTransition(vm, vm.propertyNames->builtinNames().ArrayPrivateName(), arrayConstructor, DontEnum | DontDelete | ReadOnly);
    648648
    649 #define PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
     649#define PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
    650650putDirectWithoutTransition(vm, vm.propertyNames-> jsName, lowerName ## Constructor, DontEnum); \
    651651
     
    821821#if ENABLE(WEBASSEMBLY)
    822822    if (Options::useWebAssembly()) {
    823         auto* wasm = WebAssemblyObject::create(vm, this, WebAssemblyObject::createStructure(vm, this, m_objectPrototype.get()));
    824         putDirectWithoutTransition(vm, Identifier::fromString(exec, "WebAssembly"), wasm, DontEnum);
    825         GlobalPropertyInfo extraStaticGlobals[] = {
    826 #define REGISTER_WASM_CONSTRUCTOR_AS_GLOBAL_PROPERTY(NAME, ...) \
    827             GlobalPropertyInfo(vm.propertyNames->builtinNames().NAME ## PrivateName(), wasm->getDirect(vm, Identifier::fromString(exec, #NAME)), DontEnum | DontDelete | ReadOnly),
    828             FOR_EACH_WASM_CONSTRUCTOR_PROPERTY(REGISTER_WASM_CONSTRUCTOR_AS_GLOBAL_PROPERTY)
    829         };
    830         addStaticGlobals(extraStaticGlobals, WTF_ARRAY_LENGTH(extraStaticGlobals));
     823        auto* webAssemblyPrototype = WebAssemblyPrototype::create(vm, this, WebAssemblyPrototype::createStructure(vm, this, m_objectPrototype.get()));
     824        m_webAssemblyStructure.set(vm, this, JSWebAssembly::createStructure(vm, this, webAssemblyPrototype));
     825        auto* webAssembly = JSWebAssembly::create(vm, this, m_webAssemblyStructure.get());
     826        putDirectWithoutTransition(vm, Identifier::fromString(exec, "WebAssembly"), webAssembly, DontEnum);
     827
     828#define CREATE_WEBASSEMBLY_CONSTRUCTOR(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) do { \
     829        typedef capitalName ## Prototype Prototype; \
     830        typedef capitalName ## Constructor Constructor; \
     831        typedef JS ## capitalName JSObj; \
     832        auto* base = m_ ## prototypeBase ## Prototype.get(); \
     833        auto* prototype = Prototype::create(vm, this, Prototype::createStructure(vm, this, base)); \
     834        auto* structure = JSObj::createStructure(vm, this, prototype); \
     835        auto* constructor = Constructor::create(vm, Constructor::createStructure(vm, this, this->functionPrototype()), prototype, structure); \
     836        prototype->putDirectWithoutTransition(vm, vm.propertyNames->constructor, constructor, DontEnum); \
     837        m_ ## lowerName ## Prototype.set(vm, this, prototype); \
     838        m_ ## properName ## Structure.set(vm, this, structure); \
     839        webAssembly->putDirectWithoutTransition(vm, Identifier::fromString(this->globalExec(), #jsName), constructor, DontEnum); \
     840    } while (0);
     841
     842        FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(CREATE_WEBASSEMBLY_CONSTRUCTOR)
     843
     844#undef CREATE_WEBASSEMBLY_CONSTRUCTOR
    831845    }
    832846#endif // ENABLE(WEBASSEMBLY)
     
    11431157    visitor.append(&thisObject->m_moduleLoaderStructure);
    11441158
    1145 #define VISIT_SIMPLE_TYPE(CapitalName, lowerName, properName, instanceType, jsName) \
     1159#define VISIT_SIMPLE_TYPE(CapitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
    11461160    visitor.append(&thisObject->m_ ## lowerName ## Prototype); \
    11471161    visitor.append(&thisObject->m_ ## properName ## Structure); \
    11481162
    11491163    FOR_EACH_SIMPLE_BUILTIN_TYPE(VISIT_SIMPLE_TYPE)
     1164   
     1165#if ENABLE(WEBASSEMBLY)
     1166    visitor.append(&thisObject->m_webAssemblyStructure);
     1167    FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(VISIT_SIMPLE_TYPE)
     1168#endif // ENABLE(WEBASSEMBLY)
    11501169
    11511170#undef VISIT_SIMPLE_TYPE
    11521171
    1153 #define VISIT_LAZY_TYPE(CapitalName, lowerName, properName, instanceType, jsName) \
     1172#define VISIT_LAZY_TYPE(CapitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
    11541173    thisObject->m_ ## properName ## Structure.visit(visitor);
    11551174   
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.h

    r206778 r207650  
    9696struct HashTable;
    9797
    98 #define DEFINE_STANDARD_BUILTIN(macro, upperName, lowerName) macro(upperName, lowerName, lowerName, JS ## upperName, upperName)
     98#define DEFINE_STANDARD_BUILTIN(macro, upperName, lowerName) macro(upperName, lowerName, lowerName, JS ## upperName, upperName, object)
    9999
    100100#define FOR_EACH_SIMPLE_BUILTIN_TYPE_WITH_CONSTRUCTOR(macro) \
    101     macro(String, string, stringObject, StringObject, String) \
    102     macro(Symbol, symbol, symbolObject, SymbolObject, Symbol) \
    103     macro(Number, number, numberObject, NumberObject, Number) \
    104     macro(Error, error, error, ErrorInstance, Error) \
    105     macro(Map, map, map, JSMap, Map) \
    106     macro(JSPromise, promise, promise, JSPromise, Promise) \
    107     macro(JSArrayBuffer, arrayBuffer, arrayBuffer, JSArrayBuffer, ArrayBuffer) \
     101    macro(String, string, stringObject, StringObject, String, object) \
     102    macro(Symbol, symbol, symbolObject, SymbolObject, Symbol, object) \
     103    macro(Number, number, numberObject, NumberObject, Number, object) \
     104    macro(Error, error, error, ErrorInstance, Error, object) \
     105    macro(Map, map, map, JSMap, Map, object) \
     106    macro(JSPromise, promise, promise, JSPromise, Promise, object) \
     107    macro(JSArrayBuffer, arrayBuffer, arrayBuffer, JSArrayBuffer, ArrayBuffer, object) \
    108108
    109109#define FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(macro) \
     
    118118#define FOR_EACH_SIMPLE_BUILTIN_TYPE(macro) \
    119119    FOR_EACH_SIMPLE_BUILTIN_TYPE_WITH_CONSTRUCTOR(macro) \
    120     macro(JSInternalPromise, internalPromise, internalPromise, JSInternalPromise, InternalPromise) \
     120    macro(JSInternalPromise, internalPromise, internalPromise, JSInternalPromise, InternalPromise, object) \
    121121
    122122#define FOR_EACH_LAZY_BUILTIN_TYPE(macro) \
    123     macro(Set, set, set, JSSet, Set) \
    124     macro(Date, date, date, DateInstance, Date) \
    125     macro(Boolean, boolean, booleanObject, BooleanObject, Boolean) \
     123    macro(Set, set, set, JSSet, Set, object) \
     124    macro(Date, date, date, DateInstance, Date, object) \
     125    macro(Boolean, boolean, booleanObject, BooleanObject, Boolean, object) \
    126126    DEFINE_STANDARD_BUILTIN(macro, WeakMap, weakMap) \
    127127    DEFINE_STANDARD_BUILTIN(macro, WeakSet, weakSet) \
    128128
    129 #define DECLARE_SIMPLE_BUILTIN_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
     129#if ENABLE(WEBASSEMBLY)
     130#define FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(macro) \
     131    macro(WebAssemblyCompileError, webAssemblyCompileError, WebAssemblyCompileError, WebAssemblyCompileError, CompileError, error) \
     132    macro(WebAssemblyInstance,     webAssemblyInstance,     WebAssemblyInstance,     WebAssemblyInstance,     Instance,     object) \
     133    macro(WebAssemblyMemory,       webAssemblyMemory,       WebAssemblyMemory,       WebAssemblyMemory,       Memory,       object) \
     134    macro(WebAssemblyModule,       webAssemblyModule,       WebAssemblyModule,       WebAssemblyModule,       Module,       object) \
     135    macro(WebAssemblyRuntimeError, webAssemblyRuntimeError, WebAssemblyRuntimeError, WebAssemblyRuntimeError, RuntimeError, error) \
     136    macro(WebAssemblyTable,        webAssemblyTable,        WebAssemblyTable,        WebAssemblyTable,        Table,        object)
     137#else
     138#define FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(macro)
     139#endif // ENABLE(WEBASSEMBLY)
     140
     141#define DECLARE_SIMPLE_BUILTIN_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
    130142    class JS ## capitalName; \
    131143    class capitalName ## Prototype; \
     
    136148FOR_EACH_LAZY_BUILTIN_TYPE(DECLARE_SIMPLE_BUILTIN_TYPE)
    137149FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(DECLARE_SIMPLE_BUILTIN_TYPE)
     150FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(DECLARE_SIMPLE_BUILTIN_TYPE)
    138151
    139152#undef DECLARE_SIMPLE_BUILTIN_TYPE
     
    306319    WriteBarrier<Structure> m_moduleLoaderStructure;
    307320
    308 #define DEFINE_STORAGE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
     321#define DEFINE_STORAGE_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
    309322    WriteBarrier<capitalName ## Prototype> m_ ## lowerName ## Prototype; \
    310323    WriteBarrier<Structure> m_ ## properName ## Structure;
    311324
    312325    FOR_EACH_SIMPLE_BUILTIN_TYPE(DEFINE_STORAGE_FOR_SIMPLE_TYPE)
     326   
     327#if ENABLE(WEBASSEMBLY)
     328    WriteBarrier<Structure> m_webAssemblyStructure;
     329    FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(DEFINE_STORAGE_FOR_SIMPLE_TYPE)
     330#endif // ENABLE(WEBASSEMBLY)
    313331
    314332#undef DEFINE_STORAGE_FOR_SIMPLE_TYPE
    315333
    316 #define DEFINE_STORAGE_FOR_ITERATOR_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
     334#define DEFINE_STORAGE_FOR_ITERATOR_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
    317335    LazyProperty<JSGlobalObject, Structure> m_ ## properName ## Structure;
    318336    FOR_EACH_BUILTIN_DERIVED_ITERATOR_TYPE(DEFINE_STORAGE_FOR_ITERATOR_TYPE)
    319337#undef DEFINE_STORAGE_FOR_ITERATOR_TYPE
    320338   
    321 #define DEFINE_STORAGE_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
     339#define DEFINE_STORAGE_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
    322340    LazyClassStructure m_ ## properName ## Structure;
    323341    FOR_EACH_LAZY_BUILTIN_TYPE(DEFINE_STORAGE_FOR_LAZY_TYPE)
     
    607625    JSArrayBufferPrototype* arrayBufferPrototype() const { return m_arrayBufferPrototype.get(); }
    608626
    609 #define DEFINE_ACCESSORS_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
     627#define DEFINE_ACCESSORS_FOR_SIMPLE_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
    610628    Structure* properName ## Structure() { return m_ ## properName ## Structure.get(); }
    611629
    612630    FOR_EACH_SIMPLE_BUILTIN_TYPE(DEFINE_ACCESSORS_FOR_SIMPLE_TYPE)
     631    FOR_EACH_WEBASSEMBLY_CONSTRUCTOR_TYPE(DEFINE_ACCESSORS_FOR_SIMPLE_TYPE)
    613632
    614633#undef DEFINE_ACCESSORS_FOR_SIMPLE_TYPE
    615634
    616 #define DEFINE_ACCESSORS_FOR_ITERATOR_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
     635#define DEFINE_ACCESSORS_FOR_ITERATOR_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
    617636    Structure* properName ## Structure() { return m_ ## properName ## Structure.get(this); }
    618637
     
    621640#undef DEFINE_ACCESSORS_FOR_ITERATOR_TYPE
    622641
    623 #define DEFINE_ACCESSORS_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
     642#define DEFINE_ACCESSORS_FOR_LAZY_TYPE(capitalName, lowerName, properName, instanceType, jsName, prototypeBase) \
    624643    Structure* properName ## Structure() { return m_ ## properName ## Structure.get(this); }
    625644
  • trunk/Source/JavaScriptCore/wasm/JSWebAssembly.cpp

    r207649 r207650  
    2525
    2626#include "config.h"
    27 #include "WebAssemblyTablePrototype.h"
     27#include "JSWebAssembly.h"
     28
     29#if ENABLE(WEBASSEMBLY)
    2830
    2931#include "FunctionPrototype.h"
    3032#include "JSCInlines.h"
    3133
    32 #include "WebAssemblyTablePrototype.lut.h"
    33 
    3434namespace JSC {
    3535
    36 const ClassInfo WebAssemblyTablePrototype::s_info = { "WebAssembly.Table.prototype", &Base::s_info, &prototypeTableWebAssemblyTable, CREATE_METHOD_TABLE(WebAssemblyTablePrototype) };
     36STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(JSWebAssembly);
    3737
    38 /* Source for WebAssemblyTablePrototype.lut.h
    39  @begin prototypeTableWebAssemblyTable
    40  @end
    41  */
     38const ClassInfo JSWebAssembly::s_info = { "WebAssembly", &Base::s_info, 0, CREATE_METHOD_TABLE(JSWebAssembly) };
    4239
    43 WebAssemblyTablePrototype* WebAssemblyTablePrototype::create(VM& vm, JSGlobalObject*, Structure* structure)
     40JSWebAssembly* JSWebAssembly::create(VM& vm, JSGlobalObject* globalObject, Structure* structure)
    4441{
    45     auto* object = new (NotNull, allocateCell<WebAssemblyTablePrototype>(vm.heap)) WebAssemblyTablePrototype(vm, structure);
    46     object->finishCreation(vm);
     42    auto* object = new (NotNull, allocateCell<JSWebAssembly>(vm.heap)) JSWebAssembly(vm, structure);
     43    object->finishCreation(vm, globalObject);
    4744    return object;
    4845}
    4946
    50 Structure* WebAssemblyTablePrototype::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
     47Structure* JSWebAssembly::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
    5148{
    5249    return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
    5350}
    5451
    55 void WebAssemblyTablePrototype::finishCreation(VM& vm)
     52void JSWebAssembly::finishCreation(VM& vm, JSGlobalObject*)
    5653{
    5754    Base::finishCreation(vm);
     55    ASSERT(inherits(info()));
    5856}
    5957
    60 WebAssemblyTablePrototype::WebAssemblyTablePrototype(VM& vm, Structure* structure)
    61     : Base(vm, structure)
     58JSWebAssembly::JSWebAssembly(VM& vm, Structure* structure)
     59    : JSNonFinalObject(vm, structure)
    6260{
    6361}
    6462
    6563} // namespace JSC
     64
     65#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/JSWebAssembly.h

    r207649 r207650  
    2626#pragma once
    2727
     28#if ENABLE(WEBASSEMBLY)
     29
    2830#include "JSObject.h"
     31#include "js/JSWebAssemblyCompileError.h"
     32#include "js/JSWebAssemblyInstance.h"
     33#include "js/JSWebAssemblyMemory.h"
     34#include "js/JSWebAssemblyModule.h"
     35#include "js/JSWebAssemblyRuntimeError.h"
     36#include "js/JSWebAssemblyTable.h"
     37#include "js/WebAssemblyCompileErrorConstructor.h"
     38#include "js/WebAssemblyCompileErrorPrototype.h"
     39#include "js/WebAssemblyInstanceConstructor.h"
     40#include "js/WebAssemblyInstancePrototype.h"
     41#include "js/WebAssemblyMemoryConstructor.h"
     42#include "js/WebAssemblyMemoryPrototype.h"
     43#include "js/WebAssemblyModuleConstructor.h"
     44#include "js/WebAssemblyModulePrototype.h"
     45#include "js/WebAssemblyPrototype.h"
     46#include "js/WebAssemblyRuntimeErrorConstructor.h"
     47#include "js/WebAssemblyRuntimeErrorPrototype.h"
     48#include "js/WebAssemblyTableConstructor.h"
     49#include "js/WebAssemblyTablePrototype.h"
    2950
    3051namespace JSC {
    3152
    32 class WebAssemblyObject : public JSNonFinalObject {
     53class JSWebAssembly : public JSNonFinalObject {
    3354public:
    3455    typedef JSNonFinalObject Base;
    3556
    36     static WebAssemblyObject* create(VM&, JSGlobalObject*, Structure*);
     57    static JSWebAssembly* create(VM&, JSGlobalObject*, Structure*);
    3758    static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
    3859
     
    4364
    4465private:
    45     WebAssemblyObject(VM&, Structure*);
     66    JSWebAssembly(VM&, Structure*);
    4667};
    4768
    48 // Name, functionLength
    49 #define FOR_EACH_WASM_CONSTRUCTOR_PROPERTY(DO) \
    50     DO(Module, 1) \
    51     DO(Instance, 2) \
    52     DO(Memory, 1) \
    53     DO(Table, 1) \
    54     DO(CompileError, 1) \
    55     DO(RuntimeError, 1)
     69} // namespace JSC
    5670
    57 // Name, functionLength
    58 #define FOR_EACH_WASM_FUNCTION_PROPERTY(DO) \
    59     DO(validate, 1) \
    60     DO(compile, 1)
    61 
    62 } // namespace JSC
     71#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.cpp

    r207572 r207650  
    2727#include "JSWebAssemblyCompileError.h"
    2828
     29#if ENABLE(WEBASSEMBLY)
     30
    2931#include "JSCInlines.h"
    3032
     
    4749
    4850} // namespace JSC
     51
     52#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyCompileError.h

    r207572 r207650  
    2626#pragma once
    2727
     28#if ENABLE(WEBASSEMBLY)
     29
    2830#include "ErrorInstance.h"
    2931
     
    3537
    3638    static JSWebAssemblyCompileError* create(ExecState*, Structure*, const String&, bool);
     39    static JSWebAssemblyCompileError* create(ExecState* exec, Structure* structure, JSValue message, bool useCurrentFrame)
     40    {
     41        return create(exec, structure, message.isUndefined() ? String() : message.toString(exec)->value(exec), useCurrentFrame);
     42    }
    3743
    3844    DECLARE_INFO;
     
    4349
    4450} // namespace JSC
     51
     52#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.cpp

    r207572 r207650  
    2626#include "config.h"
    2727#include "JSWebAssemblyInstance.h"
     28
     29#if ENABLE(WEBASSEMBLY)
    2830
    2931#include "JSCInlines.h"
     
    7072
    7173} // namespace JSC
     74
     75#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyInstance.h

    r207572 r207650  
    2626#pragma once
    2727
     28#if ENABLE(WEBASSEMBLY)
     29
    2830#include "JSDestructibleObject.h"
    2931#include "JSObject.h"
     
    4850
    4951} // namespace JSC
     52
     53#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.cpp

    r207572 r207650  
    2626#include "config.h"
    2727#include "JSWebAssemblyMemory.h"
     28
     29#if ENABLE(WEBASSEMBLY)
    2830
    2931#include "JSCInlines.h"
     
    7072
    7173} // namespace JSC
     74
     75#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyMemory.h

    r207572 r207650  
    2626#pragma once
    2727
     28#if ENABLE(WEBASSEMBLY)
     29
    2830#include "JSDestructibleObject.h"
    2931#include "JSObject.h"
     
    4850
    4951} // namespace JSC
     52
     53#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.cpp

    r207572 r207650  
    2626#include "config.h"
    2727#include "JSWebAssemblyModule.h"
     28
     29#if ENABLE(WEBASSEMBLY)
    2830
    2931#include "JSCInlines.h"
     
    7072
    7173} // namespace JSC
     74
     75#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyModule.h

    r207572 r207650  
    2626#pragma once
    2727
     28#if ENABLE(WEBASSEMBLY)
     29
    2830#include "JSDestructibleObject.h"
    2931#include "JSObject.h"
     
    4850
    4951} // namespace JSC
     52
     53#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyRuntimeError.cpp

    r207572 r207650  
    2727#include "JSWebAssemblyRuntimeError.h"
    2828
     29#if ENABLE(WEBASSEMBLY)
     30
    2931#include "JSCInlines.h"
    3032
     
    4749
    4850} // namespace JSC
     51
     52#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyRuntimeError.h

    r207572 r207650  
    2626#pragma once
    2727
     28#if ENABLE(WEBASSEMBLY)
     29
    2830#include "ErrorInstance.h"
    2931
     
    3537
    3638    static JSWebAssemblyRuntimeError* create(ExecState*, Structure*, const String&, bool);
     39    static JSWebAssemblyRuntimeError* create(ExecState* exec, Structure* structure, JSValue message, bool useCurrentFrame)
     40    {
     41        return create(exec, structure, message.isUndefined() ? String() : message.toString(exec)->value(exec), useCurrentFrame);
     42    }
    3743
    3844    DECLARE_INFO;
     
    4349
    4450} // namespace JSC
     51
     52#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyTable.cpp

    r207572 r207650  
    2626#include "config.h"
    2727#include "JSWebAssemblyTable.h"
     28
     29#if ENABLE(WEBASSEMBLY)
    2830
    2931#include "JSCInlines.h"
     
    7072
    7173} // namespace JSC
     74
     75#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/JSWebAssemblyTable.h

    r207572 r207650  
    2626#pragma once
    2727
     28#if ENABLE(WEBASSEMBLY)
     29
    2830#include "JSDestructibleObject.h"
    2931#include "JSObject.h"
     
    4850
    4951} // namespace JSC
     52
     53#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.cpp

    r207572 r207650  
    2727#include "WebAssemblyCompileErrorConstructor.h"
    2828
     29#if ENABLE(WEBASSEMBLY)
     30
    2931#include "FunctionPrototype.h"
    3032#include "JSCInlines.h"
     33#include "JSWebAssemblyCompileError.h"
    3134#include "WebAssemblyCompileErrorPrototype.h"
    3235
     
    4447static EncodedJSValue JSC_HOST_CALL constructJSWebAssemblyCompileError(ExecState* state)
    4548{
    46     VM& vm = state->vm();
     49    auto& vm = state->vm();
    4750    auto scope = DECLARE_THROW_SCOPE(vm);
    48     return JSValue::encode(throwException(state, scope, createError(state, ASCIILiteral("WebAssembly doesn't yet implement the CompileError constructor property"))));
     51    JSValue message = state->argumentCount() ? state->argument(0) : jsUndefined();
     52    auto* structure = InternalFunction::createSubclassStructure(state, state->newTarget(), asInternalFunction(state->callee())->globalObject()->WebAssemblyCompileErrorStructure());
     53    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     54    return JSValue::encode(JSWebAssemblyCompileError::create(state, structure, message, false));
    4955}
    5056
     
    6874}
    6975
    70 void WebAssemblyCompileErrorConstructor::finishCreation(VM& vm, WebAssemblyCompileErrorPrototype* prototype, Structure* structure)
     76void WebAssemblyCompileErrorConstructor::finishCreation(VM& vm, WebAssemblyCompileErrorPrototype* prototype, Structure*)
    7177{
    7278    Base::finishCreation(vm, ASCIILiteral("CompileError"));
    73     putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
     79    putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, ReadOnly | DontEnum | DontDelete);
    7480    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
    75     m_CompileErrorStructure.set(vm, this, structure);
    7681}
    7782
     
    9398}
    9499
    95 void WebAssemblyCompileErrorConstructor::visitChildren(JSCell* cell, SlotVisitor& visitor)
    96 {
    97     auto* thisObject = jsCast<WebAssemblyCompileErrorConstructor*>(cell);
    98     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
    99     Base::visitChildren(thisObject, visitor);
    100     visitor.append(&thisObject->m_CompileErrorStructure);
    101 }
     100} // namespace JSC
    102101
    103 } // namespace JSC
     102#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorConstructor.h

    r207572 r207650  
    2626#pragma once
    2727
     28#if ENABLE(WEBASSEMBLY)
     29
    2830#include "InternalFunction.h"
    2931#include "JSObject.h"
     
    4345    DECLARE_INFO;
    4446
    45     Structure* CompileErrorStructure() const { return m_CompileErrorStructure.get(); }
    46 
    4747protected:
    4848    void finishCreation(VM&, WebAssemblyCompileErrorPrototype*, Structure*);
     
    5252    static ConstructType getConstructData(JSCell*, ConstructData&);
    5353    static CallType getCallData(JSCell*, CallData&);
    54     static void visitChildren(JSCell*, SlotVisitor&);
    55 
    56     WriteBarrier<Structure> m_CompileErrorStructure;
    5754};
    5855
    5956} // namespace JSC
     57
     58#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorPrototype.cpp

    r207572 r207650  
    2626#include "config.h"
    2727#include "WebAssemblyCompileErrorPrototype.h"
     28
     29#if ENABLE(WEBASSEMBLY)
    2830
    2931#include "FunctionPrototype.h"
     
    6466
    6567} // namespace JSC
     68
     69#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyCompileErrorPrototype.h

    r207572 r207650  
    2626#pragma once
    2727
     28#if ENABLE(WEBASSEMBLY)
     29
    2830#include "JSDestructibleObject.h"
    2931#include "JSObject.h"
     
    4951
    5052} // namespace JSC
     53
     54#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.cpp

    r207572 r207650  
    2626#include "config.h"
    2727#include "WebAssemblyInstanceConstructor.h"
     28
     29#if ENABLE(WEBASSEMBLY)
    2830
    2931#include "FunctionPrototype.h"
     
    102104
    103105} // namespace JSC
     106
     107#endif // ENABLE(WEBASSEMBLY)
     108
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstanceConstructor.h

    r207572 r207650  
    2525
    2626#pragma once
     27
     28#if ENABLE(WEBASSEMBLY)
    2729
    2830#include "InternalFunction.h"
     
    5860
    5961} // namespace JSC
     62
     63#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstancePrototype.cpp

    r207572 r207650  
    2626#include "config.h"
    2727#include "WebAssemblyInstancePrototype.h"
     28
     29#if ENABLE(WEBASSEMBLY)
    2830
    2931#include "FunctionPrototype.h"
     
    6466
    6567} // namespace JSC
     68
     69#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyInstancePrototype.h

    r207572 r207650  
    2626#pragma once
    2727
     28#if ENABLE(WEBASSEMBLY)
     29
    2830#include "JSDestructibleObject.h"
    2931#include "JSObject.h"
     
    4951
    5052} // namespace JSC
     53
     54#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.cpp

    r207572 r207650  
    2626#include "config.h"
    2727#include "WebAssemblyMemoryConstructor.h"
     28
     29#if ENABLE(WEBASSEMBLY)
    2830
    2931#include "FunctionPrototype.h"
     
    102104
    103105} // namespace JSC
     106
     107#endif // ENABLE(WEBASSEMBLY)
     108
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.h

    r207572 r207650  
    2525
    2626#pragma once
     27
     28#if ENABLE(WEBASSEMBLY)
    2729
    2830#include "InternalFunction.h"
     
    5860
    5961} // namespace JSC
     62
     63#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryPrototype.cpp

    r207572 r207650  
    2626#include "config.h"
    2727#include "WebAssemblyMemoryPrototype.h"
     28
     29#if ENABLE(WEBASSEMBLY)
    2830
    2931#include "FunctionPrototype.h"
     
    6466
    6567} // namespace JSC
     68
     69#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryPrototype.h

    r207572 r207650  
    2626#pragma once
    2727
     28#if ENABLE(WEBASSEMBLY)
     29
    2830#include "JSDestructibleObject.h"
    2931#include "JSObject.h"
     
    4951
    5052} // namespace JSC
     53
     54#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.cpp

    r207572 r207650  
    2626#include "config.h"
    2727#include "WebAssemblyModuleConstructor.h"
     28
     29#if ENABLE(WEBASSEMBLY)
    2830
    2931#include "FunctionPrototype.h"
     
    102104
    103105} // namespace JSC
     106
     107#endif // ENABLE(WEBASSEMBLY)
     108
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModuleConstructor.h

    r207572 r207650  
    2525
    2626#pragma once
     27
     28#if ENABLE(WEBASSEMBLY)
    2729
    2830#include "InternalFunction.h"
     
    5860
    5961} // namespace JSC
     62
     63#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModulePrototype.cpp

    r207572 r207650  
    2626#include "config.h"
    2727#include "WebAssemblyModulePrototype.h"
     28
     29#if ENABLE(WEBASSEMBLY)
    2830
    2931#include "FunctionPrototype.h"
     
    6466
    6567} // namespace JSC
     68
     69#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyModulePrototype.h

    r207572 r207650  
    2626#pragma once
    2727
     28#if ENABLE(WEBASSEMBLY)
     29
    2830#include "JSDestructibleObject.h"
    2931#include "JSObject.h"
     
    4951
    5052} // namespace JSC
     53
     54#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyPrototype.cpp

    r207649 r207650  
    2525
    2626#include "config.h"
    27 #include "WebAssemblyCompileErrorPrototype.h"
     27#include "WebAssemblyPrototype.h"
     28
     29#if ENABLE(WEBASSEMBLY)
    2830
    2931#include "FunctionPrototype.h"
    3032#include "JSCInlines.h"
    3133
    32 #include "WebAssemblyCompileErrorPrototype.lut.h"
     34namespace JSC {
     35
     36static EncodedJSValue JSC_HOST_CALL webAssemblyFunctionValidate(ExecState* state)
     37{
     38    VM& vm = state->vm();
     39    auto scope = DECLARE_THROW_SCOPE(vm);
     40    return JSValue::encode(throwException(state, scope, createError(state, ASCIILiteral("WebAssembly doesn't yet implement the validate function property"))));
     41}
     42
     43static EncodedJSValue JSC_HOST_CALL webAssemblyFunctionCompile(ExecState* state)
     44{
     45    VM& vm = state->vm();
     46    auto scope = DECLARE_THROW_SCOPE(vm);
     47    return JSValue::encode(throwException(state, scope, createError(state, ASCIILiteral("WebAssembly doesn't yet implement the compile function property"))));
     48}
     49
     50}
     51
     52#include "WebAssemblyPrototype.lut.h"
    3353
    3454namespace JSC {
    3555
    36 const ClassInfo WebAssemblyCompileErrorPrototype::s_info = { "WebAssembly.CompileError.prototype", &Base::s_info, &prototypeTableWebAssemblyCompileError, CREATE_METHOD_TABLE(WebAssemblyCompileErrorPrototype) };
     56const ClassInfo WebAssemblyPrototype::s_info = { "WebAssembly.prototype", &Base::s_info, &prototypeTableWebAssembly, CREATE_METHOD_TABLE(WebAssemblyPrototype) };
    3757
    38 /* Source for WebAssemblyCompileErrorPrototype.lut.h
    39  @begin prototypeTableWebAssemblyCompileError
     58/* Source for WebAssemblyPrototype.lut.h
     59 @begin prototypeTableWebAssembly
     60 validate webAssemblyFunctionValidate  DontEnum|Function 1
     61 compile  webAssemblyFunctionCompile   DontEnum|Function 1
    4062 @end
    4163 */
    4264
    43 WebAssemblyCompileErrorPrototype* WebAssemblyCompileErrorPrototype::create(VM& vm, JSGlobalObject*, Structure* structure)
     65WebAssemblyPrototype* WebAssemblyPrototype::create(VM& vm, JSGlobalObject*, Structure* structure)
    4466{
    45     auto* object = new (NotNull, allocateCell<WebAssemblyCompileErrorPrototype>(vm.heap)) WebAssemblyCompileErrorPrototype(vm, structure);
     67    auto* object = new (NotNull, allocateCell<WebAssemblyPrototype>(vm.heap)) WebAssemblyPrototype(vm, structure);
    4668    object->finishCreation(vm);
    4769    return object;
    4870}
    4971
    50 Structure* WebAssemblyCompileErrorPrototype::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
     72Structure* WebAssemblyPrototype::createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
    5173{
    5274    return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
    5375}
    5476
    55 void WebAssemblyCompileErrorPrototype::finishCreation(VM& vm)
     77void WebAssemblyPrototype::finishCreation(VM& vm)
    5678{
    5779    Base::finishCreation(vm);
    5880}
    5981
    60 WebAssemblyCompileErrorPrototype::WebAssemblyCompileErrorPrototype(VM& vm, Structure* structure)
     82WebAssemblyPrototype::WebAssemblyPrototype(VM& vm, Structure* structure)
    6183    : Base(vm, structure)
    6284{
     
    6486
    6587} // namespace JSC
     88
     89#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyPrototype.h

    r207649 r207650  
    2626#pragma once
    2727
     28#if ENABLE(WEBASSEMBLY)
     29
    2830#include "JSDestructibleObject.h"
    2931#include "JSObject.h"
     
    3133namespace JSC {
    3234
    33 class WebAssemblyMemoryPrototype : public JSNonFinalObject {
     35class WebAssemblyPrototype : public JSNonFinalObject {
    3436public:
    3537    typedef JSNonFinalObject Base;
    3638    static const unsigned StructureFlags = Base::StructureFlags | HasStaticPropertyTable;
    3739
    38     static WebAssemblyMemoryPrototype* create(VM&, JSGlobalObject*, Structure*);
     40    static WebAssemblyPrototype* create(VM&, JSGlobalObject*, Structure*);
    3941    static Structure* createStructure(VM&, JSGlobalObject*, JSValue);
    4042
     
    4547
    4648private:
    47     WebAssemblyMemoryPrototype(VM&, Structure*);
     49    WebAssemblyPrototype(VM&, Structure*);
    4850};
    4951
    5052} // namespace JSC
     53
     54#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.cpp

    r207572 r207650  
    2727#include "WebAssemblyRuntimeErrorConstructor.h"
    2828
     29#if ENABLE(WEBASSEMBLY)
     30
    2931#include "FunctionPrototype.h"
    3032#include "JSCInlines.h"
     33#include "JSWebAssemblyRuntimeError.h"
    3134#include "WebAssemblyRuntimeErrorPrototype.h"
    3235
     
    4447static EncodedJSValue JSC_HOST_CALL constructJSWebAssemblyRuntimeError(ExecState* state)
    4548{
    46     VM& vm = state->vm();
     49    auto& vm = state->vm();
    4750    auto scope = DECLARE_THROW_SCOPE(vm);
    48     return JSValue::encode(throwException(state, scope, createError(state, ASCIILiteral("WebAssembly doesn't yet implement the RuntimeError constructor property"))));
     51    JSValue message = state->argumentCount() ? state->argument(0) : jsUndefined();
     52    auto* structure = InternalFunction::createSubclassStructure(state, state->newTarget(), asInternalFunction(state->callee())->globalObject()->WebAssemblyRuntimeErrorStructure());
     53    RETURN_IF_EXCEPTION(scope, encodedJSValue());
     54    return JSValue::encode(JSWebAssemblyRuntimeError::create(state, structure, message, false));
    4955}
    5056
     
    6874}
    6975
    70 void WebAssemblyRuntimeErrorConstructor::finishCreation(VM& vm, WebAssemblyRuntimeErrorPrototype* prototype, Structure* structure)
     76void WebAssemblyRuntimeErrorConstructor::finishCreation(VM& vm, WebAssemblyRuntimeErrorPrototype* prototype, Structure*)
    7177{
    7278    Base::finishCreation(vm, ASCIILiteral("RuntimeError"));
    73     putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, DontEnum | DontDelete | ReadOnly);
     79    putDirectWithoutTransition(vm, vm.propertyNames->prototype, prototype, ReadOnly | DontEnum | DontDelete);
    7480    putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontEnum | DontDelete);
    75     m_RuntimeErrorStructure.set(vm, this, structure);
    7681}
    7782
     
    9398}
    9499
    95 void WebAssemblyRuntimeErrorConstructor::visitChildren(JSCell* cell, SlotVisitor& visitor)
    96 {
    97     auto* thisObject = jsCast<WebAssemblyRuntimeErrorConstructor*>(cell);
    98     ASSERT_GC_OBJECT_INHERITS(thisObject, info());
    99     Base::visitChildren(thisObject, visitor);
    100     visitor.append(&thisObject->m_RuntimeErrorStructure);
    101 }
     100} // namespace JSC
    102101
    103 } // namespace JSC
     102#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorConstructor.h

    r207572 r207650  
    2626#pragma once
    2727
     28#if ENABLE(WEBASSEMBLY)
     29
    2830#include "InternalFunction.h"
    2931#include "JSObject.h"
     
    4345    DECLARE_INFO;
    4446
    45     Structure* RuntimeErrorStructure() const { return m_RuntimeErrorStructure.get(); }
    46 
    4747protected:
    4848    void finishCreation(VM&, WebAssemblyRuntimeErrorPrototype*, Structure*);
     
    5252    static ConstructType getConstructData(JSCell*, ConstructData&);
    5353    static CallType getCallData(JSCell*, CallData&);
    54     static void visitChildren(JSCell*, SlotVisitor&);
    55 
    56     WriteBarrier<Structure> m_RuntimeErrorStructure;
    5754};
    5855
    5956} // namespace JSC
     57
     58#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorPrototype.cpp

    r207572 r207650  
    2626#include "config.h"
    2727#include "WebAssemblyRuntimeErrorPrototype.h"
     28
     29#if ENABLE(WEBASSEMBLY)
    2830
    2931#include "FunctionPrototype.h"
     
    6466
    6567} // namespace JSC
     68
     69#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyRuntimeErrorPrototype.h

    r207572 r207650  
    2626#pragma once
    2727
     28#if ENABLE(WEBASSEMBLY)
     29
    2830#include "JSDestructibleObject.h"
    2931#include "JSObject.h"
     
    4951
    5052} // namespace JSC
     53
     54#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.cpp

    r207572 r207650  
    2626#include "config.h"
    2727#include "WebAssemblyTableConstructor.h"
     28
     29#if ENABLE(WEBASSEMBLY)
    2830
    2931#include "FunctionPrototype.h"
     
    102104
    103105} // namespace JSC
     106
     107#endif // ENABLE(WEBASSEMBLY)
     108
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.h

    r207572 r207650  
    2525
    2626#pragma once
     27
     28#if ENABLE(WEBASSEMBLY)
    2729
    2830#include "InternalFunction.h"
     
    5860
    5961} // namespace JSC
     62
     63#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTablePrototype.cpp

    r207572 r207650  
    2626#include "config.h"
    2727#include "WebAssemblyTablePrototype.h"
     28
     29#if ENABLE(WEBASSEMBLY)
    2830
    2931#include "FunctionPrototype.h"
     
    6466
    6567} // namespace JSC
     68
     69#endif // ENABLE(WEBASSEMBLY)
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTablePrototype.h

    r207572 r207650  
    2626#pragma once
    2727
     28#if ENABLE(WEBASSEMBLY)
     29
    2830#include "JSDestructibleObject.h"
    2931#include "JSObject.h"
     
    4951
    5052} // namespace JSC
     53
     54#endif // ENABLE(WEBASSEMBLY)
Note: See TracChangeset for help on using the changeset viewer.