Changeset 271115 in webkit


Ignore:
Timestamp:
Dec 30, 2020 7:27:12 PM (19 months ago)
Author:
ysuzuki@apple.com
Message:

[JSC] WebAssembly Table/Memory/Global should allow inheritance
https://bugs.webkit.org/show_bug.cgi?id=220207

Reviewed by Alexey Shvayka.

LayoutTests/imported/w3c:

  • web-platform-tests/wasm/jsapi/proto-from-ctor-realm-expected.txt:
  • web-platform-tests/wasm/jsapi/prototypes.any-expected.txt:
  • web-platform-tests/wasm/jsapi/prototypes.any.worker-expected.txt:

Source/JavaScriptCore:

WebAssembly.{Table,Memory,Global} should accept inheritance by JS class syntax.
We need to create structure from new.target value.

  • wasm/js/WebAssemblyGlobalConstructor.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):

  • wasm/js/WebAssemblyMemoryConstructor.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):

  • wasm/js/WebAssemblyTableConstructor.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r271113 r271115  
     12020-12-30  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] WebAssembly Table/Memory/Global should allow inheritance
     4        https://bugs.webkit.org/show_bug.cgi?id=220207
     5
     6        Reviewed by Alexey Shvayka.
     7
     8        * web-platform-tests/wasm/jsapi/proto-from-ctor-realm-expected.txt:
     9        * web-platform-tests/wasm/jsapi/prototypes.any-expected.txt:
     10        * web-platform-tests/wasm/jsapi/prototypes.any.worker-expected.txt:
     11
    1122020-12-30  Yusuke Suzuki  <ysuzuki@apple.com>
    213
  • trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/proto-from-ctor-realm-expected.txt

    r267649 r271115  
    3030PASS WebAssembly.Instance: Proxy of Proxy of cross-realm NewTarget with `-0` prototype
    3131PASS WebAssembly.Instance: Proxy of bound cross-realm NewTarget with `NaN` prototype
    32 FAIL WebAssembly.Memory: cross-realm NewTarget with `undefined` prototype assert_true: expected true got false
    33 FAIL WebAssembly.Memory: cross-realm NewTarget with `null` prototype assert_true: expected true got false
    34 FAIL WebAssembly.Memory: cross-realm NewTarget with `false` prototype assert_true: expected true got false
    35 FAIL WebAssembly.Memory: cross-realm NewTarget with `true` prototype assert_true: expected true got false
    36 FAIL WebAssembly.Memory: cross-realm NewTarget with `0` prototype assert_true: expected true got false
    37 FAIL WebAssembly.Memory: cross-realm NewTarget with `-1` prototype assert_true: expected true got false
    38 FAIL WebAssembly.Memory: cross-realm NewTarget with `""` prototype assert_true: expected true got false
    39 FAIL WebAssembly.Memory: cross-realm NewTarget with `"str"` prototype assert_true: expected true got false
    40 FAIL WebAssembly.Memory: cross-realm NewTarget with `symbol "Symbol()"` prototype assert_true: expected true got false
    41 FAIL WebAssembly.Memory: bound cross-realm NewTarget with `undefined` prototype assert_true: expected true got false
    42 FAIL WebAssembly.Memory: bound bound cross-realm NewTarget with `null` prototype assert_true: expected true got false
    43 FAIL WebAssembly.Memory: bound Proxy of cross-realm NewTarget with `false` prototype assert_true: expected true got false
    44 FAIL WebAssembly.Memory: Proxy of cross-realm NewTarget with `true` prototype assert_true: expected true got false
    45 FAIL WebAssembly.Memory: Proxy of Proxy of cross-realm NewTarget with `-0` prototype assert_true: expected true got false
    46 FAIL WebAssembly.Memory: Proxy of bound cross-realm NewTarget with `NaN` prototype assert_true: expected true got false
    47 FAIL WebAssembly.Table: cross-realm NewTarget with `undefined` prototype assert_true: expected true got false
    48 FAIL WebAssembly.Table: cross-realm NewTarget with `null` prototype assert_true: expected true got false
    49 FAIL WebAssembly.Table: cross-realm NewTarget with `false` prototype assert_true: expected true got false
    50 FAIL WebAssembly.Table: cross-realm NewTarget with `true` prototype assert_true: expected true got false
    51 FAIL WebAssembly.Table: cross-realm NewTarget with `0` prototype assert_true: expected true got false
    52 FAIL WebAssembly.Table: cross-realm NewTarget with `-1` prototype assert_true: expected true got false
    53 FAIL WebAssembly.Table: cross-realm NewTarget with `""` prototype assert_true: expected true got false
    54 FAIL WebAssembly.Table: cross-realm NewTarget with `"str"` prototype assert_true: expected true got false
    55 FAIL WebAssembly.Table: cross-realm NewTarget with `symbol "Symbol()"` prototype assert_true: expected true got false
    56 FAIL WebAssembly.Table: bound cross-realm NewTarget with `undefined` prototype assert_true: expected true got false
    57 FAIL WebAssembly.Table: bound bound cross-realm NewTarget with `null` prototype assert_true: expected true got false
    58 FAIL WebAssembly.Table: bound Proxy of cross-realm NewTarget with `false` prototype assert_true: expected true got false
    59 FAIL WebAssembly.Table: Proxy of cross-realm NewTarget with `true` prototype assert_true: expected true got false
    60 FAIL WebAssembly.Table: Proxy of Proxy of cross-realm NewTarget with `-0` prototype assert_true: expected true got false
    61 FAIL WebAssembly.Table: Proxy of bound cross-realm NewTarget with `NaN` prototype assert_true: expected true got false
    62 FAIL WebAssembly.Global: cross-realm NewTarget with `undefined` prototype assert_true: expected true got false
    63 FAIL WebAssembly.Global: cross-realm NewTarget with `null` prototype assert_true: expected true got false
    64 FAIL WebAssembly.Global: cross-realm NewTarget with `false` prototype assert_true: expected true got false
    65 FAIL WebAssembly.Global: cross-realm NewTarget with `true` prototype assert_true: expected true got false
    66 FAIL WebAssembly.Global: cross-realm NewTarget with `0` prototype assert_true: expected true got false
    67 FAIL WebAssembly.Global: cross-realm NewTarget with `-1` prototype assert_true: expected true got false
    68 FAIL WebAssembly.Global: cross-realm NewTarget with `""` prototype assert_true: expected true got false
    69 FAIL WebAssembly.Global: cross-realm NewTarget with `"str"` prototype assert_true: expected true got false
    70 FAIL WebAssembly.Global: cross-realm NewTarget with `symbol "Symbol()"` prototype assert_true: expected true got false
    71 FAIL WebAssembly.Global: bound cross-realm NewTarget with `undefined` prototype assert_true: expected true got false
    72 FAIL WebAssembly.Global: bound bound cross-realm NewTarget with `null` prototype assert_true: expected true got false
    73 FAIL WebAssembly.Global: bound Proxy of cross-realm NewTarget with `false` prototype assert_true: expected true got false
    74 FAIL WebAssembly.Global: Proxy of cross-realm NewTarget with `true` prototype assert_true: expected true got false
    75 FAIL WebAssembly.Global: Proxy of Proxy of cross-realm NewTarget with `-0` prototype assert_true: expected true got false
    76 FAIL WebAssembly.Global: Proxy of bound cross-realm NewTarget with `NaN` prototype assert_true: expected true got false
     32PASS WebAssembly.Memory: cross-realm NewTarget with `undefined` prototype
     33PASS WebAssembly.Memory: cross-realm NewTarget with `null` prototype
     34PASS WebAssembly.Memory: cross-realm NewTarget with `false` prototype
     35PASS WebAssembly.Memory: cross-realm NewTarget with `true` prototype
     36PASS WebAssembly.Memory: cross-realm NewTarget with `0` prototype
     37PASS WebAssembly.Memory: cross-realm NewTarget with `-1` prototype
     38PASS WebAssembly.Memory: cross-realm NewTarget with `""` prototype
     39PASS WebAssembly.Memory: cross-realm NewTarget with `"str"` prototype
     40PASS WebAssembly.Memory: cross-realm NewTarget with `symbol "Symbol()"` prototype
     41PASS WebAssembly.Memory: bound cross-realm NewTarget with `undefined` prototype
     42PASS WebAssembly.Memory: bound bound cross-realm NewTarget with `null` prototype
     43PASS WebAssembly.Memory: bound Proxy of cross-realm NewTarget with `false` prototype
     44PASS WebAssembly.Memory: Proxy of cross-realm NewTarget with `true` prototype
     45PASS WebAssembly.Memory: Proxy of Proxy of cross-realm NewTarget with `-0` prototype
     46PASS WebAssembly.Memory: Proxy of bound cross-realm NewTarget with `NaN` prototype
     47PASS WebAssembly.Table: cross-realm NewTarget with `undefined` prototype
     48PASS WebAssembly.Table: cross-realm NewTarget with `null` prototype
     49PASS WebAssembly.Table: cross-realm NewTarget with `false` prototype
     50PASS WebAssembly.Table: cross-realm NewTarget with `true` prototype
     51PASS WebAssembly.Table: cross-realm NewTarget with `0` prototype
     52PASS WebAssembly.Table: cross-realm NewTarget with `-1` prototype
     53PASS WebAssembly.Table: cross-realm NewTarget with `""` prototype
     54PASS WebAssembly.Table: cross-realm NewTarget with `"str"` prototype
     55PASS WebAssembly.Table: cross-realm NewTarget with `symbol "Symbol()"` prototype
     56PASS WebAssembly.Table: bound cross-realm NewTarget with `undefined` prototype
     57PASS WebAssembly.Table: bound bound cross-realm NewTarget with `null` prototype
     58PASS WebAssembly.Table: bound Proxy of cross-realm NewTarget with `false` prototype
     59PASS WebAssembly.Table: Proxy of cross-realm NewTarget with `true` prototype
     60PASS WebAssembly.Table: Proxy of Proxy of cross-realm NewTarget with `-0` prototype
     61PASS WebAssembly.Table: Proxy of bound cross-realm NewTarget with `NaN` prototype
     62PASS WebAssembly.Global: cross-realm NewTarget with `undefined` prototype
     63PASS WebAssembly.Global: cross-realm NewTarget with `null` prototype
     64PASS WebAssembly.Global: cross-realm NewTarget with `false` prototype
     65PASS WebAssembly.Global: cross-realm NewTarget with `true` prototype
     66PASS WebAssembly.Global: cross-realm NewTarget with `0` prototype
     67PASS WebAssembly.Global: cross-realm NewTarget with `-1` prototype
     68PASS WebAssembly.Global: cross-realm NewTarget with `""` prototype
     69PASS WebAssembly.Global: cross-realm NewTarget with `"str"` prototype
     70PASS WebAssembly.Global: cross-realm NewTarget with `symbol "Symbol()"` prototype
     71PASS WebAssembly.Global: bound cross-realm NewTarget with `undefined` prototype
     72PASS WebAssembly.Global: bound bound cross-realm NewTarget with `null` prototype
     73PASS WebAssembly.Global: bound Proxy of cross-realm NewTarget with `false` prototype
     74PASS WebAssembly.Global: Proxy of cross-realm NewTarget with `true` prototype
     75PASS WebAssembly.Global: Proxy of Proxy of cross-realm NewTarget with `-0` prototype
     76PASS WebAssembly.Global: Proxy of bound cross-realm NewTarget with `NaN` prototype
    7777PASS WebAssembly.CompileError: cross-realm NewTarget with `undefined` prototype
    7878PASS WebAssembly.CompileError: cross-realm NewTarget with `null` prototype
  • trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/prototypes.any-expected.txt

    r269866 r271115  
    22PASS _Module
    33PASS _Instance
    4 FAIL _Memory assert_true: _Memory instanceof _Memory expected true got false
    5 FAIL _Table assert_true: _Table instanceof _Table expected true got false
    6 FAIL _Global assert_true: _Global instanceof _Global expected true got false
     4PASS _Memory
     5PASS _Table
     6PASS _Global
    77
  • trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/prototypes.any.worker-expected.txt

    r269866 r271115  
    22PASS _Module
    33PASS _Instance
    4 FAIL _Memory assert_true: _Memory instanceof _Memory expected true got false
    5 FAIL _Table assert_true: _Table instanceof _Table expected true got false
    6 FAIL _Global assert_true: _Global instanceof _Global expected true got false
     4PASS _Memory
     5PASS _Table
     6PASS _Global
    77
  • trunk/Source/JavaScriptCore/ChangeLog

    r271114 r271115  
     12020-12-30  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] WebAssembly Table/Memory/Global should allow inheritance
     4        https://bugs.webkit.org/show_bug.cgi?id=220207
     5
     6        Reviewed by Alexey Shvayka.
     7
     8        WebAssembly.{Table,Memory,Global} should accept inheritance by JS class syntax.
     9        We need to create structure from new.target value.
     10
     11        * wasm/js/WebAssemblyGlobalConstructor.cpp:
     12        (JSC::JSC_DEFINE_HOST_FUNCTION):
     13        * wasm/js/WebAssemblyMemoryConstructor.cpp:
     14        (JSC::JSC_DEFINE_HOST_FUNCTION):
     15        * wasm/js/WebAssemblyTableConstructor.cpp:
     16        (JSC::JSC_DEFINE_HOST_FUNCTION):
     17
    1182020-12-30  Yusuke Suzuki  <ysuzuki@apple.com>
    219
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyGlobalConstructor.cpp

    r267594 r271115  
    5151    VM& vm = globalObject->vm();
    5252    auto throwScope = DECLARE_THROW_SCOPE(vm);
     53
     54    JSObject* newTarget = asObject(callFrame->newTarget());
     55    Structure* webAssemblyGlobalStructure = newTarget == callFrame->jsCallee()
     56        ? globalObject->webAssemblyGlobalStructure()
     57        : InternalFunction::createSubclassStructure(globalObject, newTarget, getFunctionRealm(vm, newTarget)->webAssemblyGlobalStructure());
     58    RETURN_IF_EXCEPTION(throwScope, { });
    5359
    5460    JSObject* globalDescriptor;
     
    123129
    124130    Ref<Wasm::Global> wasmGlobal = Wasm::Global::create(type, mutability, initialValue);
    125     RELEASE_AND_RETURN(throwScope, JSValue::encode(JSWebAssemblyGlobal::tryCreate(globalObject, vm, globalObject->webAssemblyGlobalStructure(), WTFMove(wasmGlobal))));
     131    RELEASE_AND_RETURN(throwScope, JSValue::encode(JSWebAssemblyGlobal::tryCreate(globalObject, vm, webAssemblyGlobalStructure, WTFMove(wasmGlobal))));
    126132}
    127133
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyMemoryConstructor.cpp

    r271039 r271115  
    5757    VM& vm = globalObject->vm();
    5858    auto throwScope = DECLARE_THROW_SCOPE(vm);
     59
     60    JSObject* newTarget = asObject(callFrame->newTarget());
     61    Structure* webAssemblyMemoryStructure = newTarget == callFrame->jsCallee()
     62        ? globalObject->webAssemblyMemoryStructure()
     63        : InternalFunction::createSubclassStructure(globalObject, newTarget, getFunctionRealm(vm, newTarget)->webAssemblyMemoryStructure());
     64    RETURN_IF_EXCEPTION(throwScope, { });
    5965
    6066    JSObject* memoryDescriptor;
     
    124130    }
    125131
    126     auto* jsMemory = JSWebAssemblyMemory::tryCreate(globalObject, vm, globalObject->webAssemblyMemoryStructure());
     132    auto* jsMemory = JSWebAssemblyMemory::tryCreate(globalObject, vm, webAssemblyMemoryStructure);
    127133    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    128134
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.cpp

    r271039 r271115  
    5555    VM& vm = globalObject->vm();
    5656    auto throwScope = DECLARE_THROW_SCOPE(vm);
     57
     58    JSObject* newTarget = asObject(callFrame->newTarget());
     59    Structure* webAssemblyTableStructure = newTarget == callFrame->jsCallee()
     60        ? globalObject->webAssemblyTableStructure()
     61        : InternalFunction::createSubclassStructure(globalObject, newTarget, getFunctionRealm(vm, newTarget)->webAssemblyTableStructure());
     62    RETURN_IF_EXCEPTION(throwScope, { });
    5763
    5864    JSObject* memoryDescriptor;
     
    116122    }
    117123
    118     RELEASE_AND_RETURN(throwScope, JSValue::encode(JSWebAssemblyTable::tryCreate(globalObject, vm, globalObject->webAssemblyTableStructure(), wasmTable.releaseNonNull())));
     124    RELEASE_AND_RETURN(throwScope, JSValue::encode(JSWebAssemblyTable::tryCreate(globalObject, vm, webAssemblyTableStructure, wasmTable.releaseNonNull())));
    119125}
    120126
Note: See TracChangeset for help on using the changeset viewer.