Changeset 262017 in webkit


Ignore:
Timestamp:
May 21, 2020 11:37:50 AM (4 years ago)
Author:
Alexey Shvayka
Message:

Use @isUndefinedOrNull instead of abstract equality with null
https://bugs.webkit.org/show_bug.cgi?id=210954

Reviewed by Yusuke Suzuki.

JSTests:

  • test262/expectations.yaml: Mark 16 test cases as passing.

Source/JavaScriptCore:

This patch:

a) Replaces 2 !== @undefined comparisons in String.prototype.{replace,replaceAll}
with @isUndefinedOrNull() as per spec [1], aligning JSC with V8 and SpiderMonkey.

b) Replaces 3 != @undefined and 7 != null comparisons with @isUndefinedOrNull()
as only the latter is correct with IsHTMLDDA? aka MasqueradesAsUndefined objects [2].

c) Removes @isDictionary() since it is unused, easy to inline and its name is quite
misleading: one might expect it to perform Structure::isDictionary().

[1]: https://tc39.es/ecma262/#sec-getmethod (step 3)
[2]: https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot

  • builtins/ArrayConstructor.js:
  • builtins/GlobalOperations.js:

(globalPrivate.isDictionary): Deleted.

  • builtins/RegExpPrototype.js:

(Symbol.split): Unobservable as there is === null check in @regExpExec.

  • builtins/StringPrototype.js:

(match):
(replace):
(replaceAll):
(search):
(split):

  • builtins/TypedArrayConstructor.js:
Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r261987 r262017  
     12020-05-21  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Use @isUndefinedOrNull instead of abstract equality with null
     4        https://bugs.webkit.org/show_bug.cgi?id=210954
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * test262/expectations.yaml: Mark 16 test cases as passing.
     9
    1102020-05-21  Alexey Shvayka  <shvaikalesh@gmail.com>
    211
  • trunk/JSTests/test262/expectations.yaml

    r261987 r262017  
    11---
    2 test/annexB/built-ins/Array/from/iterator-method-emulates-undefined.js:
    3   default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
    4   strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all'
    52test/annexB/built-ins/Function/createdynfn-html-close-comment-params.js:
    63  default: "SyntaxError: Unexpected token '}'. Expected a parameter pattern or a ')' in parameter list."
     
    129  default: 'Test262Error: Expected a SyntaxError to be thrown but no exception was thrown at all'
    1310  strict mode: 'Test262Error: Expected a SyntaxError to be thrown but no exception was thrown at all'
    14 test/annexB/built-ins/String/prototype/match/custom-matcher-emulates-undefined.js:
    15   default: 'Test262Error: Expected SameValue(«0», «1») to be true'
    16   strict mode: 'Test262Error: Expected SameValue(«0», «1») to be true'
    17 test/annexB/built-ins/String/prototype/replace/custom-replacer-emulates-undefined.js:
    18   default: 'Test262Error: Expected SameValue(«», «null») to be true'
    19   strict mode: 'Test262Error: Expected SameValue(«», «null») to be true'
    2011test/annexB/built-ins/String/prototype/replaceAll/custom-replacer-emulates-undefined.js:
    2112  default: 'Test262Error: Expected SameValue(«», «null») to be true'
    2213  strict mode: 'Test262Error: Expected SameValue(«», «null») to be true'
    23 test/annexB/built-ins/String/prototype/search/custom-searcher-emulates-undefined.js:
    24   default: 'Test262Error: Expected SameValue(«-1», «null») to be true'
    25   strict mode: 'Test262Error: Expected SameValue(«-1», «null») to be true'
    26 test/annexB/built-ins/String/prototype/split/custom-splitter-emulates-undefined.js:
    27   default: 'Test262Error: Expected SameValue(«», «null») to be true'
    28   strict mode: 'Test262Error: Expected SameValue(«», «null») to be true'
    29 test/annexB/built-ins/TypedArrayConstructors/from/iterator-method-emulates-undefined.js:
    30   default: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)'
    31   strict mode: 'Test262Error: Expected a TypeError to be thrown but no exception was thrown at all (Testing with Float64Array.)'
    3214test/annexB/language/eval-code/direct/func-block-decl-eval-func-skip-early-err-block.js:
    3315  default: 'Test262Error: An initialized binding is not created prior to evaluation Expected a ReferenceError to be thrown but no exception was thrown at all'
     
    15231505  default: 'SyntaxError: Invalid regular expression: number too large in {} quantifier'
    15241506  strict mode: 'SyntaxError: Invalid regular expression: number too large in {} quantifier'
    1525 test/built-ins/String/prototype/replace/cstm-replace-is-null.js:
    1526   default: 'TypeError: null is not a function'
    1527   strict mode: 'TypeError: null is not a function'
    1528 test/built-ins/String/prototype/replaceAll/searchValue-replacer-is-null.js:
    1529   default: 'TypeError: null is not a function'
    1530   strict mode: 'TypeError: null is not a function'
    15311507test/built-ins/ThrowTypeError/extensible.js:
    15321508  default: 'Test262Error: Expected SameValue(«true», «false») to be true'
  • trunk/Source/JavaScriptCore/ChangeLog

    r262014 r262017  
     12020-05-21  Alexey Shvayka  <shvaikalesh@gmail.com>
     2
     3        Use @isUndefinedOrNull instead of abstract equality with null
     4        https://bugs.webkit.org/show_bug.cgi?id=210954
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        This patch:
     9
     10        a) Replaces 2 `!== @undefined` comparisons in String.prototype.{replace,replaceAll}
     11        with @isUndefinedOrNull() as per spec [1], aligning JSC with V8 and SpiderMonkey.
     12
     13        b) Replaces 3 `!= @undefined` and 7 `!= null` comparisons with @isUndefinedOrNull()
     14        as only the latter is correct with [[IsHTMLDDA]] aka MasqueradesAsUndefined objects [2].
     15
     16        c) Removes @isDictionary() since it is unused, easy to inline and its name is quite
     17        misleading: one might expect it to perform Structure::isDictionary().
     18
     19        [1]: https://tc39.es/ecma262/#sec-getmethod (step 3)
     20        [2]: https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot
     21
     22        * builtins/ArrayConstructor.js:
     23        * builtins/GlobalOperations.js:
     24        (globalPrivate.isDictionary): Deleted.
     25        * builtins/RegExpPrototype.js:
     26        (Symbol.split): Unobservable as there is `=== null` check in @regExpExec.
     27        * builtins/StringPrototype.js:
     28        (match):
     29        (replace):
     30        (replaceAll):
     31        (search):
     32        (split):
     33        * builtins/TypedArrayConstructor.js:
     34
    1352020-05-21  Saam Barati  <sbarati@apple.com>
    236
  • trunk/Source/JavaScriptCore/builtins/ArrayConstructor.js

    r261987 r262017  
    5454
    5555    var iteratorMethod = items.@@iterator;
    56     if (iteratorMethod != null) {
     56    if (!@isUndefinedOrNull(iteratorMethod)) {
    5757        if (typeof iteratorMethod !== "function")
    5858            @throwTypeError("Array.from requires that the property of the first argument, items[Symbol.iterator], when exists, be a function");
  • trunk/Source/JavaScriptCore/builtins/GlobalOperations.js

    r257681 r262017  
    4848    // originally Math.min(Math.max(length, 0), maxSafeInteger));
    4949    return +(length > 0 ? (length < @MAX_SAFE_INTEGER ? length : @MAX_SAFE_INTEGER) : 0);
    50 }
    51 
    52 @globalPrivate
    53 function isDictionary(object)
    54 {
    55     "use strict";
    56 
    57     return object == null || typeof object === "object";
    5850}
    5951
  • trunk/Source/JavaScriptCore/builtins/RegExpPrototype.js

    r260312 r262017  
    530530        var z = @regExpExec(splitter, str);
    531531        // b. If z is not null, return A.
    532         if (z != null)
     532        if (z !== null)
    533533            return result;
    534534        // c. Perform ! CreateDataProperty(A, "0", S).
  • trunk/Source/JavaScriptCore/builtins/StringPrototype.js

    r259029 r262017  
    3333        @throwTypeError("String.prototype.match requires that |this| not be null or undefined");
    3434
    35     if (regexp != null) {
     35    if (!@isUndefinedOrNull(regexp)) {
    3636        var matcher = regexp.@@match;
    37         if (matcher != @undefined)
     37        if (!@isUndefinedOrNull(matcher))
    3838            return matcher.@call(regexp, this);
    3939    }
     
    246246        @throwTypeError("String.prototype.replace requires that |this| not be null or undefined");
    247247
    248     if (search != null) {
     248    if (!@isUndefinedOrNull(search)) {
    249249        var replacer = search.@@replace;
    250         if (replacer !== @undefined) {
     250        if (!@isUndefinedOrNull(replacer)) {
    251251            if (!@hasObservableSideEffectsForStringReplace(search, replacer))
    252252                return @toString(this).@replaceUsingRegExp(search, replace);
     
    267267        @throwTypeError("String.prototype.replaceAll requires |this| not to be null nor undefined");
    268268
    269     if (search != null) {
     269    if (!@isUndefinedOrNull(search)) {
    270270        if (@isRegExp(search) && !@stringIncludesInternal.@call(@toString(search.flags), "g"))
    271271            @throwTypeError("String.prototype.replaceAll argument must not be a non-global regular expression");
    272272
    273273        var replacer = search.@@replace;
    274         if (replacer !== @undefined) {
     274        if (!@isUndefinedOrNull(replacer)) {
    275275            if (!@hasObservableSideEffectsForStringReplace(search, replacer))
    276276                return @toString(this).@replaceUsingRegExp(search, replace);
     
    291291        @throwTypeError("String.prototype.search requires that |this| not be null or undefined");
    292292
    293     if (regexp != null) {
     293    if (!@isUndefinedOrNull(regexp)) {
    294294        var searcher = regexp.@@search;
    295         if (searcher != @undefined)
     295        if (!@isUndefinedOrNull(searcher))
    296296            return searcher.@call(regexp, this);
    297297    }
     
    309309        @throwTypeError("String.prototype.split requires that |this| not be null or undefined");
    310310   
    311     if (separator != null) {
     311    if (!@isUndefinedOrNull(separator)) {
    312312        var splitter = separator.@@split;
    313         if (splitter != @undefined)
     313        if (!@isUndefinedOrNull(splitter))
    314314            return splitter.@call(separator, this, limit);
    315315    }
  • trunk/Source/JavaScriptCore/builtins/TypedArrayConstructor.js

    r257681 r262017  
    6363
    6464    var iteratorMethod = items.@@iterator;
    65     if (iteratorMethod != null) {
     65    if (!@isUndefinedOrNull(iteratorMethod)) {
    6666        if (typeof iteratorMethod !== "function")
    6767            @throwTypeError("TypedArray.from requires that the property of the first argument, items[Symbol.iterator], when exists, be a function");
Note: See TracChangeset for help on using the changeset viewer.