Changeset 272081 in webkit


Ignore:
Timestamp:
Jan 29, 2021 3:07:25 PM (18 months ago)
Author:
ysuzuki@apple.com
Message:

[JSC] Fix WebAssembly.Global's error message and support "funcref"
https://bugs.webkit.org/show_bug.cgi?id=221157

Reviewed by Keith Miller.

JSTests:

  • wasm/stress/global-wrong-type.js: Added.

(assert.throws):

LayoutTests/imported/w3c:

We also update test expect files failing after r272074.

  • web-platform-tests/wasm/jsapi/global/type.tentative.any-expected.txt:
  • web-platform-tests/wasm/jsapi/global/type.tentative.any.worker-expected.txt:

Source/JavaScriptCore:

Since it accepts "anyfunc" and "externref", we should update the error message.
And we should support "funcref" too.

  • wasm/js/WebAssemblyGlobalConstructor.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):

  • wasm/js/WebAssemblyTableConstructor.cpp:

(JSC::JSC_DEFINE_HOST_FUNCTION):

Location:
trunk
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r272071 r272081  
     12021-01-29  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Fix WebAssembly.Global's error message and support "funcref"
     4        https://bugs.webkit.org/show_bug.cgi?id=221157
     5
     6        Reviewed by Keith Miller.
     7
     8        * wasm/stress/global-wrong-type.js: Added.
     9        (assert.throws):
     10
    1112021-01-29  Dmitry Bezhetskov  <dbezhetskov@igalia.com>
    212
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r272035 r272081  
     12021-01-29  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Fix WebAssembly.Global's error message and support "funcref"
     4        https://bugs.webkit.org/show_bug.cgi?id=221157
     5
     6        Reviewed by Keith Miller.
     7
     8        We also update test expect files failing after r272074.
     9
     10        * web-platform-tests/wasm/jsapi/global/type.tentative.any-expected.txt:
     11        * web-platform-tests/wasm/jsapi/global/type.tentative.any.worker-expected.txt:
     12
    1132021-01-28  Martin Robinson  <mrobinson@webkit.org>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/global/type.tentative.any-expected.txt

    r271774 r272081  
    88FAIL f64, mutable undefined is not an object (evaluating 'myglobal.type.value')
    99FAIL f64, immutable undefined is not an object (evaluating 'myglobal.type.value')
    10 FAIL anyref, mutable WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', or 'f64'
    11 FAIL anyref, immutable WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', or 'f64'
    12 FAIL funcref, mutable WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', or 'f64'
    13 FAIL funcref, immutable WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', or 'f64'
     10FAIL anyref, mutable undefined is not an object (evaluating 'myglobal.type.value')
     11FAIL anyref, immutable undefined is not an object (evaluating 'myglobal.type.value')
     12FAIL funcref, mutable undefined is not an object (evaluating 'myglobal.type.value')
     13FAIL funcref, immutable undefined is not an object (evaluating 'myglobal.type.value')
    1414FAIL key ordering undefined is not an object (evaluating 'Object.getOwnPropertyNames(myglobal.type)')
    1515
  • trunk/LayoutTests/imported/w3c/web-platform-tests/wasm/jsapi/global/type.tentative.any.worker-expected.txt

    r271774 r272081  
    88FAIL f64, mutable undefined is not an object (evaluating 'myglobal.type.value')
    99FAIL f64, immutable undefined is not an object (evaluating 'myglobal.type.value')
    10 FAIL anyref, mutable WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', or 'f64'
    11 FAIL anyref, immutable WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', or 'f64'
    12 FAIL funcref, mutable WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', or 'f64'
    13 FAIL funcref, immutable WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', or 'f64'
     10FAIL anyref, mutable undefined is not an object (evaluating 'myglobal.type.value')
     11FAIL anyref, immutable undefined is not an object (evaluating 'myglobal.type.value')
     12FAIL funcref, mutable undefined is not an object (evaluating 'myglobal.type.value')
     13FAIL funcref, immutable undefined is not an object (evaluating 'myglobal.type.value')
    1414FAIL key ordering undefined is not an object (evaluating 'Object.getOwnPropertyNames(myglobal.type)')
    1515
  • trunk/Source/JavaScriptCore/ChangeLog

    r272074 r272081  
     12021-01-29  Yusuke Suzuki  <ysuzuki@apple.com>
     2
     3        [JSC] Fix WebAssembly.Global's error message and support "funcref"
     4        https://bugs.webkit.org/show_bug.cgi?id=221157
     5
     6        Reviewed by Keith Miller.
     7
     8        Since it accepts "anyfunc" and "externref", we should update the error message.
     9        And we should support "funcref" too.
     10
     11        * wasm/js/WebAssemblyGlobalConstructor.cpp:
     12        (JSC::JSC_DEFINE_HOST_FUNCTION):
     13        * wasm/js/WebAssemblyTableConstructor.cpp:
     14        (JSC::JSC_DEFINE_HOST_FUNCTION):
     15
    1162021-01-29  Dmitry Bezhetskov  <dbezhetskov@igalia.com>
    217
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyGlobalConstructor.cpp

    r272071 r272081  
    8787        String valueString = valueValue.toWTFString(globalObject);
    8888        RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    89         if (valueString == "i32")
     89        if (valueString == "i32"_s)
    9090            type = Wasm::Type::I32;
    91         else if (valueString == "i64")
     91        else if (valueString == "i64"_s)
    9292            type = Wasm::Type::I64;
    93         else if (valueString == "f32")
     93        else if (valueString == "f32"_s)
    9494            type = Wasm::Type::F32;
    95         else if (valueString == "f64")
     95        else if (valueString == "f64"_s)
    9696            type = Wasm::Type::F64;
    97         else if (Options::useWebAssemblyReferences() && valueString == "anyfunc")
     97        else if (Options::useWebAssemblyReferences() && (valueString == "anyfunc"_s || valueString == "funcref"_s))
    9898            type = Wasm::Type::Funcref;
    99         else if (Options::useWebAssemblyReferences() && valueString == "externref")
     99        else if (Options::useWebAssemblyReferences() && valueString == "externref"_s)
    100100            type = Wasm::Type::Externref;
    101101        else
    102             return JSValue::encode(throwException(globalObject, throwScope, createTypeError(globalObject, "WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', or 'f64'"_s)));
     102            return JSValue::encode(throwException(globalObject, throwScope, createTypeError(globalObject, "WebAssembly.Global expects its 'value' field to be the string 'i32', 'i64', 'f32', 'f64', 'anyfunc', 'funcref', or 'externref'"_s)));
    103103    }
    104104
  • trunk/Source/JavaScriptCore/wasm/js/WebAssemblyTableConstructor.cpp

    r272071 r272081  
    7777        String elementString = elementValue.toWTFString(globalObject);
    7878        RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    79         if (elementString == "funcref" || elementString == "anyfunc")
     79        if (elementString == "funcref"_s || elementString == "anyfunc"_s)
    8080            type = Wasm::TableElementType::Funcref;
    81         else if (elementString == "externref")
     81        else if (elementString == "externref"_s)
    8282            type = Wasm::TableElementType::Externref;
    8383        else
Note: See TracChangeset for help on using the changeset viewer.