Changeset 260312 in webkit


Ignore:
Timestamp:
Apr 18, 2020 9:01:02 AM (4 years ago)
Author:
Alexey Shvayka
Message:

RegExp.prototype[@@search] should use SameValue
https://bugs.webkit.org/show_bug.cgi?id=173226

Reviewed by Yusuke Suzuki.

JSTests:

  • stress/same-value-intrinsic.js: Added.
  • test262/expectations.yaml: Mark 4 test cases as passing.

Source/JavaScriptCore:

This change exposes Object.is implementation as link-time-constant @sameValue and utilizes
it in RegExp.prototype[@@search] per spec [1], aligning JSC with V8 and SpiderMonkey.

[1]: https://tc39.es/ecma262/#sec-regexp.prototype-@@search (steps 5, 8)

  • builtins/BuiltinNames.h:
  • builtins/RegExpPrototype.js:

(Symbol.search):

  • bytecode/LinkTimeConstant.h:
  • runtime/JSGlobalObject.cpp:

(JSC::JSGlobalObject::init):

  • runtime/ObjectConstructor.cpp:
  • runtime/ObjectConstructor.h:
Location:
trunk
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r260289 r260312  
     12020-04-18  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        RegExp.prototype[@@search] should use SameValue
     4        https://bugs.webkit.org/show_bug.cgi?id=173226
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * stress/same-value-intrinsic.js: Added.
     9        * test262/expectations.yaml: Mark 4 test cases as passing.
     10
    1112020-04-17  Saam Barati  <sbarati@apple.com>
    212
  • trunk/JSTests/test262/expectations.yaml

    r260273 r260312  
    16581658  default: 'Test262Error: Expected SameValue(«�», «null») to be true'
    16591659  strict mode: 'Test262Error: Expected SameValue(«�», «null») to be true'
    1660 test/built-ins/RegExp/prototype/Symbol.search/set-lastindex-init-samevalue.js:
    1661   default: 'Test262Error: Expected SameValue(«-0», «0») to be true'
    1662   strict mode: 'Test262Error: Expected SameValue(«-0», «0») to be true'
    1663 test/built-ins/RegExp/prototype/Symbol.search/set-lastindex-restore-samevalue.js:
    1664   default: 'Test262Error: Expected SameValue(«-0», «0») to be true'
    1665   strict mode: 'Test262Error: Expected SameValue(«-0», «0») to be true'
    16661660test/built-ins/RegExp/prototype/Symbol.search/u-lastindex-advance.js:
    16671661  default: 'Test262Error: Expected SameValue(«1», «-1») to be true'
  • trunk/Source/JavaScriptCore/ChangeLog

    r260310 r260312  
     12020-04-18  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        RegExp.prototype[@@search] should use SameValue
     4        https://bugs.webkit.org/show_bug.cgi?id=173226
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        This change exposes Object.is implementation as link-time-constant @sameValue and utilizes
     9        it in RegExp.prototype[@@search] per spec [1], aligning JSC with V8 and SpiderMonkey.
     10
     11        [1]: https://tc39.es/ecma262/#sec-regexp.prototype-@@search (steps 5, 8)
     12
     13        * builtins/BuiltinNames.h:
     14        * builtins/RegExpPrototype.js:
     15        (Symbol.search):
     16        * bytecode/LinkTimeConstant.h:
     17        * runtime/JSGlobalObject.cpp:
     18        (JSC::JSGlobalObject::init):
     19        * runtime/ObjectConstructor.cpp:
     20        * runtime/ObjectConstructor.h:
     21
    1222020-04-18  Angelos Oikonomopoulos  <angelos@igalia.com>
    223
  • trunk/Source/JavaScriptCore/builtins/BuiltinNames.h

    r260273 r260312  
    123123    macro(isArraySlow) \
    124124    macro(isConstructor) \
     125    macro(sameValue) \
    125126    macro(concatMemcpy) \
    126127    macro(appendMemcpy) \
  • trunk/Source/JavaScriptCore/builtins/RegExpPrototype.js

    r259029 r260312  
    404404    var previousLastIndex = regexp.lastIndex;
    405405
    406     // 5.If SameValue(previousLastIndex, 0) is false, then
     406    // 5. If SameValue(previousLastIndex, 0) is false, then
    407407    // 5.a. Perform ? Set(rx, "lastIndex", 0, true).
    408     // FIXME: Add SameValue support. https://bugs.webkit.org/show_bug.cgi?id=173226
    409     if (previousLastIndex !== 0)
     408    if (!@sameValue(previousLastIndex, 0))
    410409        regexp.lastIndex = 0;
    411410
     
    416415    // 8. If SameValue(currentLastIndex, previousLastIndex) is false, then
    417416    // 8.a. Perform ? Set(rx, "lastIndex", previousLastIndex, true).
    418     // FIXME: Add SameValue support. https://bugs.webkit.org/show_bug.cgi?id=173226
    419     if (regexp.lastIndex !== previousLastIndex)
     417    if (!@sameValue(regexp.lastIndex, previousLastIndex))
    420418        regexp.lastIndex = previousLastIndex;
    421419
  • trunk/Source/JavaScriptCore/bytecode/LinkTimeConstant.h

    r260273 r260312  
    7575    v(thisTimeValue, nullptr) \
    7676    v(isConstructor, nullptr) \
     77    v(sameValue, nullptr) \
    7778    v(regExpProtoFlagsGetter, nullptr) \
    7879    v(regExpProtoGlobalGetter, nullptr) \
  • trunk/Source/JavaScriptCore/runtime/JSGlobalObject.cpp

    r260273 r260312  
    11361136            init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 1, String(), esSpecIsConstructor, NoIntrinsic));
    11371137        });
     1138    m_linkTimeConstants[static_cast<unsigned>(LinkTimeConstant::sameValue)].initLater([] (const Initializer<JSCell>& init) {
     1139            init.set(JSFunction::create(init.vm, jsCast<JSGlobalObject*>(init.owner), 2, String(), objectConstructorIs, ObjectIsIntrinsic));
     1140        });
    11381141
    11391142    // RegExp.prototype helpers.
  • trunk/Source/JavaScriptCore/runtime/ObjectConstructor.cpp

    r254626 r260312  
    5555EncodedJSValue JSC_HOST_CALL objectConstructorIsFrozen(JSGlobalObject*, CallFrame*);
    5656EncodedJSValue JSC_HOST_CALL objectConstructorIsExtensible(JSGlobalObject*, CallFrame*);
    57 EncodedJSValue JSC_HOST_CALL objectConstructorIs(JSGlobalObject*, CallFrame*);
    5857
    5958}
  • trunk/Source/JavaScriptCore/runtime/ObjectConstructor.h

    r253019 r260312  
    126126bool toPropertyDescriptor(JSGlobalObject*, JSValue, PropertyDescriptor&);
    127127
     128EncodedJSValue JSC_HOST_CALL objectConstructorIs(JSGlobalObject*, CallFrame*);
     129
    128130} // namespace JSC
Note: See TracChangeset for help on using the changeset viewer.