Changeset 223274 in webkit for trunk/Source/JavaScriptCore


Ignore:
Timestamp:
Oct 12, 2017, 7:13:20 PM (8 years ago)
Author:
Yusuke Suzuki
Message:

WebAssembly: Wasm functions should have either JSFunctionType or TypeOfShouldCallGetCallData
https://bugs.webkit.org/show_bug.cgi?id=178210

Reviewed by Saam Barati.

JSTests:

  • wasm/function-tests/trap-from-start-async.js:

(async.StartTrapsAsync):

  • wasm/function-tests/trap-from-start.js:

(StartTraps):

  • wasm/js-api/web-assembly-function.js:

(assert.eq.Object.getPrototypeOf):

  • wasm/js-api/wrapper-function.js:

(return.new.WebAssembly.Module):
(assert.throws.makeInstance): Deleted.
(assert.throws.Bar): Deleted.
(assert.throws): Deleted.

Source/JavaScriptCore:

In Wasm, we have two JS functions exposed to users: WebAssemblyFunction and WebAssemblyWrapperFunction.
The former is an exported wasm function and the latter is an imported & exported function. Since they
have Call, they should be categorized into "function" in typeof operation.

However, these functions do not implement our function protocol correctly. They inherit JSFunction.
But JSType of WebAssemblyFunction is WebAssemblyFunctionType, and one of WebAssemblyWrapperFunction is
ObjectType. Since both do not have TypeOfShouldCallGetCallData, they return "object" when performing
typeof operation.

In this patch, we address the above issue by the following 2 fixes.

  1. We add TypeOfShouldCallGetCallData to WebAssemblyFunction. This is the same way how we implement

InternalFunction. Since WebAssemblyFunction requires WebAssemblyFunctionType for fast checking in Wasm
implementation, we cannot make this JSFunctionType.

  1. On the other hand, WebAssemblyWrapperFunction does not require a specific JSType. So this patch

changes JSType of WebAssemblyWrapperFunction to JSFunctionType. JSFunctionType can be usable for derived
classes of JSFunction (e.g. JSCustomGetterSetterFunction).

  • wasm/js/WebAssemblyFunction.h:

(JSC::WebAssemblyFunction::signatureIndex const): Deleted.
(JSC::WebAssemblyFunction::wasmEntrypointLoadLocation const): Deleted.
(JSC::WebAssemblyFunction::callableFunction const): Deleted.
(JSC::WebAssemblyFunction::jsEntrypoint): Deleted.
(JSC::WebAssemblyFunction::offsetOfWasmEntrypointLoadLocation): Deleted.

  • wasm/js/WebAssemblyWrapperFunction.cpp:

(JSC::WebAssemblyWrapperFunction::createStructure):

  • wasm/js/WebAssemblyWrapperFunction.h:

(JSC::WebAssemblyWrapperFunction::signatureIndex const): Deleted.
(JSC::WebAssemblyWrapperFunction::wasmEntrypointLoadLocation const): Deleted.
(JSC::WebAssemblyWrapperFunction::callableFunction const): Deleted.
(JSC::WebAssemblyWrapperFunction::function): Deleted.

Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r223248 r223274  
     12017-10-12  Yusuke Suzuki  <[email protected]>
     2
     3        WebAssembly: Wasm functions should have either JSFunctionType or TypeOfShouldCallGetCallData
     4        https://bugs.webkit.org/show_bug.cgi?id=178210
     5
     6        Reviewed by Saam Barati.
     7
     8        In Wasm, we have two JS functions exposed to users: WebAssemblyFunction and WebAssemblyWrapperFunction.
     9        The former is an exported wasm function and the latter is an imported & exported function. Since they
     10        have [[Call]], they should be categorized into "function" in typeof operation.
     11
     12        However, these functions do not implement our function protocol correctly. They inherit JSFunction.
     13        But JSType of WebAssemblyFunction is WebAssemblyFunctionType, and one of WebAssemblyWrapperFunction is
     14        ObjectType. Since both do not have TypeOfShouldCallGetCallData, they return "object" when performing
     15        typeof operation.
     16
     17        In this patch, we address the above issue by the following 2 fixes.
     18
     19        1. We add TypeOfShouldCallGetCallData to WebAssemblyFunction. This is the same way how we implement
     20        InternalFunction. Since WebAssemblyFunction requires WebAssemblyFunctionType for fast checking in Wasm
     21        implementation, we cannot make this JSFunctionType.
     22
     23        2. On the other hand, WebAssemblyWrapperFunction does not require a specific JSType. So this patch
     24        changes JSType of WebAssemblyWrapperFunction to JSFunctionType. JSFunctionType can be usable for derived
     25        classes of JSFunction (e.g. JSCustomGetterSetterFunction).
     26
     27        * wasm/js/WebAssemblyFunction.h:
     28        (JSC::WebAssemblyFunction::signatureIndex const): Deleted.
     29        (JSC::WebAssemblyFunction::wasmEntrypointLoadLocation const): Deleted.
     30        (JSC::WebAssemblyFunction::callableFunction const): Deleted.
     31        (JSC::WebAssemblyFunction::jsEntrypoint): Deleted.
     32        (JSC::WebAssemblyFunction::offsetOfWasmEntrypointLoadLocation): Deleted.
     33        * wasm/js/WebAssemblyWrapperFunction.cpp:
     34        (JSC::WebAssemblyWrapperFunction::createStructure):
     35        * wasm/js/WebAssemblyWrapperFunction.h:
     36        (JSC::WebAssemblyWrapperFunction::signatureIndex const): Deleted.
     37        (JSC::WebAssemblyWrapperFunction::wasmEntrypointLoadLocation const): Deleted.
     38        (JSC::WebAssemblyWrapperFunction::callableFunction const): Deleted.
     39        (JSC::WebAssemblyWrapperFunction::function): Deleted.
     40
    1412017-10-12  Per Arne Vollan  <[email protected]>
    242
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyFunction.h

    r217645 r223274  
    4242}
    4343
    44 class WebAssemblyFunction : public WebAssemblyFunctionBase {
     44class WebAssemblyFunction final : public WebAssemblyFunctionBase {
    4545public:
    4646    using Base = WebAssemblyFunctionBase;
    4747
    48     const static unsigned StructureFlags = Base::StructureFlags;
     48    const static unsigned StructureFlags = Base::StructureFlags | TypeOfShouldCallGetCallData;
    4949
    5050    DECLARE_EXPORT_INFO;
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyWrapperFunction.cpp

    r223002 r223274  
    8080{
    8181    ASSERT(globalObject);
    82     return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
     82    return Structure::create(vm, globalObject, prototype, TypeInfo(JSFunctionType, StructureFlags), info());
    8383}
    8484
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyWrapperFunction.h

    r217017 r223274  
    3333namespace JSC {
    3434
    35 class WebAssemblyWrapperFunction : public WebAssemblyFunctionBase {
     35class WebAssemblyWrapperFunction final : public WebAssemblyFunctionBase {
    3636public:
    3737    using Base = WebAssemblyFunctionBase;
Note: See TracChangeset for help on using the changeset viewer.