Changeset 207432 in webkit


Ignore:
Timestamp:
Oct 17, 2016 2:36:05 PM (8 years ago)
Author:
jfbastien@apple.com
Message:

WebAssembly JS API: implement basic stub

Implement the global WebAssembly JavaScript object, and its constructor +
function properties as described in:

https://github.com/WebAssembly/design/blob/master/JS.md

These don't do anything at the moment, the parent bug will take care of adding
more functionality and associated tests.

WebAssembly JS API: implement basic stub
https://bugs.webkit.org/show_bug.cgi?id=163404

Reviewed by Keith Miller.

JSTests:

  • wasm.yaml:
  • wasm/js-api/test_basic_api.js: Added.

(const.f.of.functionProperties.WebAssembly.f.undefined.throw.new.Error.Couldn.const.c.of.constructorProperties.WebAssembly.c.undefined.throw.new.Error.Couldn):
(const.c.of.constructorProperties.catch):

Source/JavaScriptCore:

  • CMakeLists.txt:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • builtins/BuiltinNames.h: register the new WebAssembly object's name and its constructor properties
  • jsc.cpp: remove useless include
  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::init): add the WebAssembly global object and its constructor properties, but only if the JSC option enables it

  • runtime/Options.h: add the useWebAssembly (alias: enableWebAssembly) option, defaulting to false
  • wasm/WebAssemblyObject.cpp: Added.

(JSC::WebAssemblyObject::create): boilerplate
(JSC::WebAssemblyObject::createStructure): boilerplate
(JSC::WebAssemblyObject::finishCreation): boilerplate
(JSC::WebAssemblyObject::WebAssemblyObject): boilerplate
(JSC::wasmObjectFuncvalidate): auto-throws for now
(JSC::wasmObjectFunccompile): auto-throws for now

  • wasm/WebAssemblyObject.h: Added.

Tools:

  • Scripts/run-jsc-stress-tests: use the new JSC option which exposes the WebAssembly object.
Location:
trunk
Files:
4 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r207427 r207432  
     12016-10-17  JF Bastien  <jfbastien@apple.com>
     2
     3        WebAssembly JS API: implement basic stub
     4
     5        Implement the global WebAssembly JavaScript object, and its constructor +
     6        function properties as described in:
     7          https://github.com/WebAssembly/design/blob/master/JS.md
     8
     9        These don't do anything at the moment, the parent bug will take care of adding
     10        more functionality and associated tests.
     11
     12        WebAssembly JS API: implement basic stub
     13        https://bugs.webkit.org/show_bug.cgi?id=163404
     14
     15        Reviewed by Keith Miller.
     16
     17        * wasm.yaml:
     18        * wasm/js-api/test_basic_api.js: Added.
     19        (const.f.of.functionProperties.WebAssembly.f.undefined.throw.new.Error.Couldn.const.c.of.constructorProperties.WebAssembly.c.undefined.throw.new.Error.Couldn):
     20        (const.c.of.constructorProperties.catch):
     21
    1222016-10-17  Yusuke Suzuki  <utatane.tea@gmail.com>
    223
  • trunk/JSTests/wasm.yaml

    r207363 r207432  
    2424- path: wasm/self-test/
    2525  cmd: runWebAssembly
     26- path: wasm/js-api/
     27  cmd: runWebAssembly
  • trunk/Source/JavaScriptCore/CMakeLists.txt

    r207427 r207432  
    865865    wasm/WASMModuleParser.cpp
    866866    wasm/WASMPlan.cpp
     867    wasm/WebAssemblyObject.cpp
    867868
    868869    yarr/RegularExpression.cpp
  • trunk/Source/JavaScriptCore/ChangeLog

    r207430 r207432  
     12016-10-17  JF Bastien  <jfbastien@apple.com>
     2
     3        WebAssembly JS API: implement basic stub
     4
     5        Implement the global WebAssembly JavaScript object, and its constructor +
     6        function properties as described in:
     7          https://github.com/WebAssembly/design/blob/master/JS.md
     8
     9        These don't do anything at the moment, the parent bug will take care of adding
     10        more functionality and associated tests.
     11
     12        WebAssembly JS API: implement basic stub
     13        https://bugs.webkit.org/show_bug.cgi?id=163404
     14
     15        Reviewed by Keith Miller.
     16
     17        * CMakeLists.txt:
     18        * JavaScriptCore.xcodeproj/project.pbxproj:
     19        * builtins/BuiltinNames.h: register the new WebAssembly object's name and its constructor properties
     20        * jsc.cpp: remove useless include
     21        * runtime/JSGlobalObject.cpp:
     22        (JSC::JSGlobalObject::init): add the WebAssembly global object and its constructor properties, but only if the JSC option enables it
     23        * runtime/Options.h: add the useWebAssembly (alias: enableWebAssembly) option, defaulting to false
     24        * wasm/WebAssemblyObject.cpp: Added.
     25        (JSC::WebAssemblyObject::create): boilerplate
     26        (JSC::WebAssemblyObject::createStructure): boilerplate
     27        (JSC::WebAssemblyObject::finishCreation): boilerplate
     28        (JSC::WebAssemblyObject::WebAssemblyObject): boilerplate
     29        (JSC::wasmObjectFuncvalidate): auto-throws for now
     30        (JSC::wasmObjectFunccompile): auto-throws for now
     31        * wasm/WebAssemblyObject.h: Added.
     32
    1332016-10-17  Yusuke Suzuki  <utatane.tea@gmail.com>
    234
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r207427 r207432  
    18761876                A7FCC26D17A0B6AA00786D1A /* FTLSwitchCase.h in Headers */ = {isa = PBXBuildFile; fileRef = A7FCC26C17A0B6AA00786D1A /* FTLSwitchCase.h */; settings = {ATTRIBUTES = (Private, ); }; };
    18771877                A8A4748E151A8306004123FF /* libWTF.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A8A4748D151A8306004123FF /* libWTF.a */; };
     1878                AD2FCB881DAEBF3C00B3E736 /* WebAssemblyObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD2FCB861DAEBF3700B3E736 /* WebAssemblyObject.cpp */; };
     1879                AD2FCB891DAEBF3F00B3E736 /* WebAssemblyObject.h in Headers */ = {isa = PBXBuildFile; fileRef = AD2FCB871DAEBF3700B3E736 /* WebAssemblyObject.h */; };
    18781880                AD86A93E1AA4D88D002FE77F /* WeakGCMapInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = AD86A93D1AA4D87C002FE77F /* WeakGCMapInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
    18791881                ADDB1F6318D77DBE009B58A8 /* OpaqueRootSet.h in Headers */ = {isa = PBXBuildFile; fileRef = ADDB1F6218D77DB7009B58A8 /* OpaqueRootSet.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    42014203                A8E894330CD0603F00367179 /* JSGlobalObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSGlobalObject.h; sourceTree = "<group>"; };
    42024204                AD1CF06816DCAB2D00B97123 /* PropertyTable.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PropertyTable.cpp; sourceTree = "<group>"; };
     4205                AD2FCB861DAEBF3700B3E736 /* WebAssemblyObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebAssemblyObject.cpp; sourceTree = "<group>"; };
     4206                AD2FCB871DAEBF3700B3E736 /* WebAssemblyObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAssemblyObject.h; sourceTree = "<group>"; };
    42034207                AD86A93D1AA4D87C002FE77F /* WeakGCMapInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakGCMapInlines.h; sourceTree = "<group>"; };
    42044208                ADDB1F6218D77DB7009B58A8 /* OpaqueRootSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpaqueRootSet.h; sourceTree = "<group>"; };
     
    56795683                        isa = PBXGroup;
    56805684                        children = (
     5685                                AD2FCB861DAEBF3700B3E736 /* WebAssemblyObject.cpp */,
     5686                                AD2FCB871DAEBF3700B3E736 /* WebAssemblyObject.h */,
    56815687                                7B98D1341B60CD5A0023B1A4 /* JSWASMModule.cpp */,
    56825688                                7B98D1351B60CD5A0023B1A4 /* JSWASMModule.h */,
     
    74387444                                0FD8A31417D4326C00CA2C40 /* CodeBlockSet.h in Headers */,
    74397445                                0F96EBB316676EF6008BADE3 /* CodeBlockWithJITType.h in Headers */,
     7446                                AD2FCB891DAEBF3F00B3E736 /* WebAssemblyObject.h in Headers */,
    74407447                                A77F1822164088B200640A47 /* CodeCache.h in Headers */,
    74417448                                99CC0B6318BE9950006CEBCC /* CodeGeneratorReplayInputs.py in Headers */,
     
    97159722                                0FE050271AA9095600D33B33 /* ScopedArguments.cpp in Sources */,
    97169723                                0FE0502F1AAA806900D33B33 /* ScopedArgumentsTable.cpp in Sources */,
     9724                                AD2FCB881DAEBF3C00B3E736 /* WebAssemblyObject.cpp in Sources */,
    97179725                                992ABCF91BEA9BD2006403A0 /* RemoteAutomationTarget.cpp in Sources */,
    97189726                                0FE0502A1AA9095600D33B33 /* ScopeOffset.cpp in Sources */,
  • trunk/Source/JavaScriptCore/builtins/BuiltinNames.h

    r206525 r207432  
    160160    macro(makeBoundFunction) \
    161161    macro(hasOwnLengthProperty) \
     162    macro(WebAssembly) \
     163    macro(Module) \
     164    macro(Instance) \
     165    macro(Memory) \
     166    macro(Table) \
     167    macro(CompileError) \
     168    macro(RuntimeError) \
    162169
    163170
  • trunk/Source/JavaScriptCore/jsc.cpp

    r207427 r207432  
    5454#include "JSString.h"
    5555#include "JSTypedArrays.h"
    56 #include "JSWASMModule.h"
    5756#include "LLIntData.h"
    5857#include "ObjectConstructor.h"
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r206778 r207432  
    107107#include "JSTypedArrayViewPrototype.h"
    108108#include "JSTypedArrays.h"
    109 #include "JSWASMModule.h"
    110109#include "JSWeakMap.h"
    111110#include "JSWeakSet.h"
     
    156155#include "WeakSetConstructor.h"
    157156#include "WeakSetPrototype.h"
     157#include "WebAssemblyObject.h"
    158158#include <wtf/RandomNumber.h>
    159159
     
    818818        putDirectWithoutTransition(vm, Identifier::fromString(exec, "$vm"), dollarVM, DontEnum);
    819819    }
     820
     821#if ENABLE(WEBASSEMBLY)
     822    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            GlobalPropertyInfo(vm.propertyNames->builtinNames().ModulePrivateName(), wasm->getDirect(vm, Identifier::fromString(exec, "Module")), DontEnum | DontDelete | ReadOnly),
     827            GlobalPropertyInfo(vm.propertyNames->builtinNames().InstancePrivateName(), wasm->getDirect(vm, Identifier::fromString(exec, "Instance")), DontEnum | DontDelete | ReadOnly),
     828            GlobalPropertyInfo(vm.propertyNames->builtinNames().MemoryPrivateName(), wasm->getDirect(vm, Identifier::fromString(exec, "Memory")), DontEnum | DontDelete | ReadOnly),
     829            GlobalPropertyInfo(vm.propertyNames->builtinNames().TablePrivateName(), wasm->getDirect(vm, Identifier::fromString(exec, "Table")), DontEnum | DontDelete | ReadOnly),
     830            GlobalPropertyInfo(vm.propertyNames->builtinNames().CompileErrorPrivateName(), wasm->getDirect(vm, Identifier::fromString(exec, "CompileError")), DontEnum | DontDelete | ReadOnly),
     831            GlobalPropertyInfo(vm.propertyNames->builtinNames().RuntimeErrorPrivateName(), wasm->getDirect(vm, Identifier::fromString(exec, "RuntimeError")), DontEnum | DontDelete | ReadOnly),
     832        };
     833        addStaticGlobals(extraStaticGlobals, WTF_ARRAY_LENGTH(extraStaticGlobals));
     834    }
     835#endif // ENABLE(WEBASSEMBLY)
    820836
    821837    resetPrototype(vm, getPrototypeDirect());
  • trunk/Source/JavaScriptCore/runtime/Options.h

    r206555 r207432  
    391391    v(bool, useSourceProviderCache, true, Normal, "If false, the parser will not use the source provider cache. It's good to verify everything works when this is false. Because the cache is so successful, it can mask bugs.") \
    392392    v(bool, useCodeCache, true, Normal, "If false, the unlinked byte code cache will not be used.") \
     393    \
     394    v(bool, useWebAssembly, false, Normal, "Expose the WebAssembly global object.") \
    393395
    394396enum OptionEquivalence {
     
    428430    v(enableOSRExitFuzz, useOSRExitFuzz, SameOption) \
    429431    v(enableDollarVM, useDollarVM, SameOption) \
     432    v(enableWebAssembly, useWebAssembly, SameOption) \
    430433
    431434class Options {
  • trunk/Tools/ChangeLog

    r207416 r207432  
     12016-10-17  JF Bastien  <jfbastien@apple.com>
     2
     3        WebAssembly JS API: implement basic stub
     4
     5        Implement the global WebAssembly JavaScript object, and its constructor +
     6        function properties as described in:
     7          https://github.com/WebAssembly/design/blob/master/JS.md
     8
     9        These don't do anything at the moment, the parent bug will take care of adding
     10        more functionality and associated tests.
     11
     12        WebAssembly JS API: implement basic stub
     13        https://bugs.webkit.org/show_bug.cgi?id=163404
     14
     15        Reviewed by Keith Miller.
     16
     17        * Scripts/run-jsc-stress-tests: use the new JSC option which exposes the WebAssembly object.
     18
    1192016-10-17  Fujii Hironori  <Hironori.Fujii@sony.com>
    220
  • trunk/Tools/Scripts/run-jsc-stress-tests

    r207363 r207432  
    11611161    prepareExtraAbsoluteFiles(WASMTESTS_PATH, ["wasm.json"])
    11621162    prepareExtraRelativeFiles(modules.map { |f| "../" + f }, $collection)
    1163     run("default-wasm", "-m")
     1163    run("default-wasm", "-m", "--useWebAssembly=1")
    11641164end
    11651165
Note: See TracChangeset for help on using the changeset viewer.