Changeset 288065 in webkit


Ignore:
Timestamp:
Jan 15, 2022 1:32:37 PM (6 months ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Fix misc issues in WebAssembly.Exception
https://bugs.webkit.org/show_bug.cgi?id=235261

Reviewed by Alexey Shvayka.

JSTests:

  • wasm/stress/create-tag-from.js:
  • wasm/v8/exceptions-api.js:

(TestGetArg):

LayoutTests/imported/w3c:

Remove web-platform-tests/wasm/jsapi/exception/type.tentative.any.js test since
this behavior is not defined in wasm exception-handling and/or wasm js-types spec.
Probably this test was confused with WebAssembly.Tag (and that test is in wasm/jsapi/tag/).

Also change RangeError to TypeError according to the spec[1].

[1]: https://webassembly.github.io/exception-handling/js-api/index.html#dom-exception-getarg

  • web-platform-tests/wasm/jsapi/exception/getArg.tentative.any-expected.txt:
  • web-platform-tests/wasm/jsapi/exception/getArg.tentative.any.js:

(test):

  • web-platform-tests/wasm/jsapi/exception/getArg.tentative.any.worker-expected.txt:
  • web-platform-tests/wasm/jsapi/exception/toString.tentative.any-expected.txt:
  • web-platform-tests/wasm/jsapi/exception/toString.tentative.any.worker-expected.txt:
  • web-platform-tests/wasm/jsapi/exception/type.tentative.any-expected.txt: Removed.
  • web-platform-tests/wasm/jsapi/exception/type.tentative.any.html: Removed.
  • web-platform-tests/wasm/jsapi/exception/type.tentative.any.js: Removed.
  • web-platform-tests/wasm/jsapi/exception/type.tentative.any.worker-expected.txt: Removed.
  • web-platform-tests/wasm/jsapi/exception/type.tentative.any.worker.html: Removed.

Source/JavaScriptCore:

  1. Add @toStringTag to WebAssembly.Exception.prototype.
  2. Add argument count check for WebAssembly.Exception methods (since it is specified in WebIDL and these methods do not have optional parameters).
  • wasm/js/WebAssemblyExceptionPrototype.cpp:

(JSC::WebAssemblyExceptionPrototype::finishCreation):
(JSC::JSC_DEFINE_HOST_FUNCTION):

Location:
trunk
Files:
5 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r288062 r288065  
     12022-01-15  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Fix misc issues in WebAssembly.Exception
     4        https://bugs.webkit.org/show_bug.cgi?id=235261
     5
     6        Reviewed by Alexey Shvayka.
     7
     8        * wasm/stress/create-tag-from.js:
     9        * wasm/v8/exceptions-api.js:
     10        (TestGetArg):
     11
    1122022-01-15  Yusuke Suzuki  <ysuzuki@apple.com>
    213
  • trunk/JSTests/wasm/stress/create-tag-from.js

    r283852 r288065  
    1818assert.eq(exception.getArg(tag, 2), parameters);
    1919
    20 assert.throws(() => exception.getArg(tag, 3), RangeError, "WebAssembly.Exception.getArg(): Index out of range");
     20assert.throws(() => exception.getArg(tag, 3), TypeError, "WebAssembly.Exception.getArg(): Index out of range");
    2121
    2222assert.eq(WebAssembly.Exception.prototype.__proto__, Object.prototype)
  • trunk/JSTests/wasm/v8/exceptions-api.js

    r283852 r288065  
    203203  //assertThrows(() => exception.getArg(tag, undefined), TypeError,
    204204      ///Index must be convertible to a valid number/);
    205   assertThrows(() => exception.getArg(tag, 0xFFFFFFFF), RangeError,
     205  assertThrows(() => exception.getArg(tag, 0xFFFFFFFF), TypeError,
    206206      /Index out of range/);
    207207  let wrong_tag = new WebAssembly.Tag({parameters: ['i32']});
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r288064 r288065  
     12022-01-15  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Fix misc issues in WebAssembly.Exception
     4        https://bugs.webkit.org/show_bug.cgi?id=235261
     5
     6        Reviewed by Alexey Shvayka.
     7
     8        Remove web-platform-tests/wasm/jsapi/exception/type.tentative.any.js test since
     9        this behavior is not defined in wasm exception-handling and/or wasm js-types spec.
     10        Probably this test was confused with WebAssembly.Tag (and that test is in wasm/jsapi/tag/).
     11
     12        Also change RangeError to TypeError according to the spec[1].
     13
     14        [1]: https://webassembly.github.io/exception-handling/js-api/index.html#dom-exception-getarg
     15
     16        * web-platform-tests/wasm/jsapi/exception/getArg.tentative.any-expected.txt:
     17        * web-platform-tests/wasm/jsapi/exception/getArg.tentative.any.js:
     18        (test):
     19        * web-platform-tests/wasm/jsapi/exception/getArg.tentative.any.worker-expected.txt:
     20        * web-platform-tests/wasm/jsapi/exception/toString.tentative.any-expected.txt:
     21        * web-platform-tests/wasm/jsapi/exception/toString.tentative.any.worker-expected.txt:
     22        * web-platform-tests/wasm/jsapi/exception/type.tentative.any-expected.txt: Removed.
     23        * web-platform-tests/wasm/jsapi/exception/type.tentative.any.html: Removed.
     24        * web-platform-tests/wasm/jsapi/exception/type.tentative.any.js: Removed.
     25        * web-platform-tests/wasm/jsapi/exception/type.tentative.any.worker-expected.txt: Removed.
     26        * web-platform-tests/wasm/jsapi/exception/type.tentative.any.worker.html: Removed.
     27
    1282022-01-15  Yusuke Suzuki  <ysuzuki@apple.com>
    229
  • trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/getArg.tentative.any-expected.txt

    r288049 r288065  
    11
    2 FAIL Missing arguments assert_throws_js: function "() => exn.getArg(tag)" threw object "RangeError: WebAssembly.Exception.getArg(): Index out of range" ("RangeError") expected instance of function "function TypeError() {
    3     [native code]
    4 }" ("TypeError")
     2PASS Missing arguments
    53PASS Invalid exception argument
    64PASS Index out of bounds
    7 FAIL Getting out-of-range argument assert_throws_js: function "() => exn.getArg(tag, value)" threw object "RangeError: WebAssembly.Exception.getArg(): Index out of range" ("RangeError") expected instance of function "function TypeError() {
    8     [native code]
    9 }" ("TypeError")
     5PASS Getting out-of-range argument
    106PASS getArg
    117
  • trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/getArg.tentative.any.js

    r288049 r288065  
    2121  const tag = new WebAssembly.Tag({ parameters: [] });
    2222  const exn = new WebAssembly.Exception(tag, []);
    23   assert_throws_js(RangeError, () => exn.getArg(tag, 1));
     23  assert_throws_js(TypeError, () => exn.getArg(tag, 1));
    2424}, "Index out of bounds");
    2525
  • trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/getArg.tentative.any.worker-expected.txt

    r288049 r288065  
    11
    2 FAIL Missing arguments assert_throws_js: function "() => exn.getArg(tag)" threw object "RangeError: WebAssembly.Exception.getArg(): Index out of range" ("RangeError") expected instance of function "function TypeError() {
    3     [native code]
    4 }" ("TypeError")
     2PASS Missing arguments
    53PASS Invalid exception argument
    64PASS Index out of bounds
    7 FAIL Getting out-of-range argument assert_throws_js: function "() => exn.getArg(tag, value)" threw object "RangeError: WebAssembly.Exception.getArg(): Index out of range" ("RangeError") expected instance of function "function TypeError() {
    8     [native code]
    9 }" ("TypeError")
     5PASS Getting out-of-range argument
    106PASS getArg
    117
  • trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/toString.tentative.any-expected.txt

    r288049 r288065  
    11
    22PASS Object.prototype.toString on an Exception
    3 FAIL @@toStringTag exists on the prototype with the appropriate descriptor assert_own_property: expected property symbol "Symbol(Symbol.toStringTag)" missing
     3PASS @@toStringTag exists on the prototype with the appropriate descriptor
    44
  • trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/exception/toString.tentative.any.worker-expected.txt

    r288049 r288065  
    11
    22PASS Object.prototype.toString on an Exception
    3 FAIL @@toStringTag exists on the prototype with the appropriate descriptor assert_own_property: expected property symbol "Symbol(Symbol.toStringTag)" missing
     3PASS @@toStringTag exists on the prototype with the appropriate descriptor
    44
  • trunk/Source/JavaScriptCore/ChangeLog

    r288064 r288065  
     12022-01-15  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Fix misc issues in WebAssembly.Exception
     4        https://bugs.webkit.org/show_bug.cgi?id=235261
     5
     6        Reviewed by Alexey Shvayka.
     7
     8        1. Add @toStringTag to WebAssembly.Exception.prototype.
     9        2. Add argument count check for WebAssembly.Exception methods (since it is specified in WebIDL and these methods do not have optional parameters).
     10
     11        * wasm/js/WebAssemblyExceptionPrototype.cpp:
     12        (JSC::WebAssemblyExceptionPrototype::finishCreation):
     13        (JSC::JSC_DEFINE_HOST_FUNCTION):
     14
    1152022-01-15  Yusuke Suzuki  <ysuzuki@apple.com>
    216
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyExceptionPrototype.cpp

    r285730 r288065  
    4848 @begin prototypeTableWebAssemblyException
    4949 getArg   webAssemblyExceptionProtoFuncGetArg   Function 2
    50  is   webAssemblyExceptionProtoFuncIs   Function 1
     50 is       webAssemblyExceptionProtoFuncIs       Function 1
    5151 @end
    5252 */
     
    6868    Base::finishCreation(vm);
    6969    ASSERT(inherits(vm, info()));
     70    JSC_TO_STRING_TAG_WITHOUT_TRANSITION();
    7071}
    7172
     
    107108    };
    108109    const auto& typeError = [&](const auto& message) {
    109         throwTypeError(globalObject, throwScope, formatMessage(message));
    110         return encodedJSValue();
     110        return throwVMTypeError(globalObject, throwScope, formatMessage(message));
    111111    };
    112112
    113113    JSWebAssemblyException* jsException = getException(globalObject, callFrame->thisValue());
    114     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     114    RETURN_IF_EXCEPTION(throwScope, { });
     115
     116    if (UNLIKELY(callFrame->argumentCount() < 2))
     117        return JSValue::encode(throwException(globalObject, throwScope, createNotEnoughArgumentsError(globalObject)));
    115118
    116119    JSWebAssemblyTag* tag = getTag(vm, callFrame->argument(0));
     
    122125
    123126    uint32_t index = callFrame->argument(1).toUInt32(globalObject);
    124     if (index >= tag->tag().parameterCount()) {
    125         throwRangeError(globalObject, throwScope, formatMessage("Index out of range"));
    126         return encodedJSValue();
    127     }
     127    if (index >= tag->tag().parameterCount())
     128        return typeError("Index out of range");
    128129
    129130    RELEASE_AND_RETURN(throwScope, JSValue::encode(jsException->getArg(globalObject, index)));
     
    136137
    137138    JSWebAssemblyException* jsException = getException(globalObject, callFrame->thisValue());
    138     RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     139    RETURN_IF_EXCEPTION(throwScope, { });
     140
     141    if (UNLIKELY(callFrame->argumentCount() < 1))
     142        return JSValue::encode(throwException(globalObject, throwScope, createNotEnoughArgumentsError(globalObject)));
    139143
    140144    JSWebAssemblyTag* tag = getTag(vm, callFrame->argument(0));
    141     if (!tag) {
    142         throwTypeError(globalObject, throwScope, "WebAssembly.Exception.is(): First argument must be a WebAssembly.Tag");
    143         return encodedJSValue();
    144     }
     145    if (!tag)
     146        return throwVMTypeError(globalObject, throwScope, "WebAssembly.Exception.is(): First argument must be a WebAssembly.Tag");
    145147
    146148    RELEASE_AND_RETURN(throwScope, JSValue::encode(jsBoolean(jsException->tag() == tag->tag())));
Note: See TracChangeset for help on using the changeset viewer.