Title: [268165] trunk
Revision
268165
Author
[email protected]
Date
2020-10-07 17:59:36 -0700 (Wed, 07 Oct 2020)

Log Message

[JSC] Revert String.prototype.item
https://bugs.webkit.org/show_bug.cgi?id=217449

Reviewed by Yusuke Suzuki.

JSTests:

* stress/item-method.js:
* test262/config.yaml:

Source/_javascript_Core:

This patch reverts the String part of r267814, as it has been shown to be web-incompatible:
https://github.com/tc39/proposal-item-method/issues/31

Thankfully, this was the inessential part of the proposal; the core parts (Array and %TypedArray%) remain for now.

* builtins/StringPrototype.js:
(item): Deleted.
* runtime/StringPrototype.cpp:

LayoutTests:

* js/Object-getOwnPropertyNames-expected.txt:
* js/script-tests/Object-getOwnPropertyNames.js:

Modified Paths

Diff

Modified: trunk/JSTests/ChangeLog (268164 => 268165)


--- trunk/JSTests/ChangeLog	2020-10-08 00:27:40 UTC (rev 268164)
+++ trunk/JSTests/ChangeLog	2020-10-08 00:59:36 UTC (rev 268165)
@@ -1,3 +1,13 @@
+2020-10-07  Ross Kirsling  <[email protected]>
+
+        [JSC] Revert String.prototype.item
+        https://bugs.webkit.org/show_bug.cgi?id=217449
+
+        Reviewed by Yusuke Suzuki.
+
+        * stress/item-method.js:
+        * test262/config.yaml:
+
 2020-10-07  Caio Lima  <[email protected]>
 
         [MIPS] Flaky test stress/array-species-create-should-handle-masquerader.js

Modified: trunk/JSTests/stress/item-method.js (268164 => 268165)


--- trunk/JSTests/stress/item-method.js	2020-10-08 00:27:40 UTC (rev 268164)
+++ trunk/JSTests/stress/item-method.js	2020-10-08 00:59:36 UTC (rev 268165)
@@ -47,21 +47,3 @@
   shouldBe(ta.item(null), ta[0]);
   shouldBe(ta.item({ valueOf: () => -1 }), ta[ta.length - 1]);
 }
-
-shouldBe(String.prototype.item.length, 1);
-shouldThrowTypeError(() => String.prototype.item.call(undefined));
-shouldThrowTypeError(() => String.prototype.item.call(null));
-
-const string = 'abc';
-// intentionally go one too far to ensure that we get undefined instead of wrapping
-for (let i = 0; i <= string.length; i++) {
-  shouldBe(string.item(i), string[i]);
-  shouldBe(string.item(-i - 1), string[string.length - i - 1]);
-}
-shouldBe(string.item(), string[0]);
-shouldBe(string.item(null), string[0]);
-shouldBe(string.item({ valueOf: () => -1 }), string[string.length - 1]);
-
-const emojiPseudoString = { toString: () => '😅' };
-shouldBe(String.prototype.item.call(emojiPseudoString, 0), '\u{d83d}');
-shouldBe(String.prototype.item.call(emojiPseudoString, -1), '\u{de05}');

Modified: trunk/JSTests/test262/config.yaml (268164 => 268165)


--- trunk/JSTests/test262/config.yaml	2020-10-08 00:27:40 UTC (rev 268164)
+++ trunk/JSTests/test262/config.yaml	2020-10-08 00:59:36 UTC (rev 268165)
@@ -25,6 +25,9 @@
     - regexp-match-indices
     - top-level-await
     - Intl.ListFormat
+
+    # remove once it's no longer in test262
+    - String.prototype.item
   paths:
     - test/built-ins/DataView/prototype/getBigInt64
     - test/built-ins/DataView/prototype/getBigUint64

Modified: trunk/LayoutTests/ChangeLog (268164 => 268165)


--- trunk/LayoutTests/ChangeLog	2020-10-08 00:27:40 UTC (rev 268164)
+++ trunk/LayoutTests/ChangeLog	2020-10-08 00:59:36 UTC (rev 268165)
@@ -1,3 +1,13 @@
+2020-10-07  Ross Kirsling  <[email protected]>
+
+        [JSC] Revert String.prototype.item
+        https://bugs.webkit.org/show_bug.cgi?id=217449
+
+        Reviewed by Yusuke Suzuki.
+
+        * js/Object-getOwnPropertyNames-expected.txt:
+        * js/script-tests/Object-getOwnPropertyNames.js:
+
 2020-10-07  Tim Horton  <[email protected]>
 
         REGRESSION: Safari unable to load PDF in <embed> (docs.legalconnect.com)

Modified: trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt (268164 => 268165)


--- trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt	2020-10-08 00:27:40 UTC (rev 268164)
+++ trunk/LayoutTests/js/Object-getOwnPropertyNames-expected.txt	2020-10-08 00:59:36 UTC (rev 268165)
@@ -49,7 +49,7 @@
 PASS getSortedOwnPropertyNames(Array) is ['from', 'isArray', 'length', 'name', 'of', 'prototype']
 PASS getSortedOwnPropertyNames(Array.prototype) is ['concat', 'constructor', 'copyWithin', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'flat', 'flatMap', 'forEach', 'includes', 'indexOf', 'item', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values']
 PASS getSortedOwnPropertyNames(String) is ['fromCharCode', 'fromCodePoint', 'length', 'name', 'prototype', 'raw']
-PASS getSortedOwnPropertyNames(String.prototype) is ['anchor', 'big', 'blink', 'bold', 'charAt', 'charCodeAt', 'codePointAt', 'concat', 'constructor', 'endsWith', 'fixed', 'fontcolor', 'fontsize', 'includes', 'indexOf', 'italics', 'item', 'lastIndexOf', 'length', 'link', 'localeCompare', 'match', 'matchAll', 'normalize', 'padEnd', 'padStart', 'repeat', 'replace', 'replaceAll', 'search', 'slice', 'small', 'split', 'startsWith', 'strike', 'sub', 'substr', 'substring', 'sup', 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toString', 'toUpperCase', 'trim', 'trimEnd', 'trimLeft', 'trimRight', 'trimStart', 'valueOf']
+PASS getSortedOwnPropertyNames(String.prototype) is ['anchor', 'big', 'blink', 'bold', 'charAt', 'charCodeAt', 'codePointAt', 'concat', 'constructor', 'endsWith', 'fixed', 'fontcolor', 'fontsize', 'includes', 'indexOf', 'italics', 'lastIndexOf', 'length', 'link', 'localeCompare', 'match', 'matchAll', 'normalize', 'padEnd', 'padStart', 'repeat', 'replace', 'replaceAll', 'search', 'slice', 'small', 'split', 'startsWith', 'strike', 'sub', 'substr', 'substring', 'sup', 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toString', 'toUpperCase', 'trim', 'trimEnd', 'trimLeft', 'trimRight', 'trimStart', 'valueOf']
 PASS getSortedOwnPropertyNames(Boolean) is ['length', 'name', 'prototype']
 PASS getSortedOwnPropertyNames(Boolean.prototype) is ['constructor', 'toString', 'valueOf']
 PASS getSortedOwnPropertyNames(Number) is ['EPSILON', 'MAX_SAFE_INTEGER', 'MAX_VALUE', 'MIN_SAFE_INTEGER', 'MIN_VALUE', 'NEGATIVE_INFINITY', 'NaN', 'POSITIVE_INFINITY', 'isFinite', 'isInteger', 'isNaN', 'isSafeInteger', 'length', 'name', 'parseFloat', 'parseInt', 'prototype']

Modified: trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js (268164 => 268165)


--- trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js	2020-10-08 00:27:40 UTC (rev 268164)
+++ trunk/LayoutTests/js/script-tests/Object-getOwnPropertyNames.js	2020-10-08 00:59:36 UTC (rev 268165)
@@ -58,7 +58,7 @@
     "Array": "['from', 'isArray', 'length', 'name', 'of', 'prototype']",
     "Array.prototype": "['concat', 'constructor', 'copyWithin', 'entries', 'every', 'fill', 'filter', 'find', 'findIndex', 'flat', 'flatMap', 'forEach', 'includes', 'indexOf', 'item', 'join', 'keys', 'lastIndexOf', 'length', 'map', 'pop', 'push', 'reduce', 'reduceRight', 'reverse', 'shift', 'slice', 'some', 'sort', 'splice', 'toLocaleString', 'toString', 'unshift', 'values']",
     "String": "['fromCharCode', 'fromCodePoint', 'length', 'name', 'prototype', 'raw']",
-    "String.prototype": "['anchor', 'big', 'blink', 'bold', 'charAt', 'charCodeAt', 'codePointAt', 'concat', 'constructor', 'endsWith', 'fixed', 'fontcolor', 'fontsize', 'includes', 'indexOf', 'italics', 'item', 'lastIndexOf', 'length', 'link', 'localeCompare', 'match', 'matchAll', 'normalize', 'padEnd', 'padStart', 'repeat', 'replace', 'replaceAll', 'search', 'slice', 'small', 'split', 'startsWith', 'strike', 'sub', 'substr', 'substring', 'sup', 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toString', 'toUpperCase', 'trim', 'trimEnd', 'trimLeft', 'trimRight', 'trimStart', 'valueOf']",
+    "String.prototype": "['anchor', 'big', 'blink', 'bold', 'charAt', 'charCodeAt', 'codePointAt', 'concat', 'constructor', 'endsWith', 'fixed', 'fontcolor', 'fontsize', 'includes', 'indexOf', 'italics', 'lastIndexOf', 'length', 'link', 'localeCompare', 'match', 'matchAll', 'normalize', 'padEnd', 'padStart', 'repeat', 'replace', 'replaceAll', 'search', 'slice', 'small', 'split', 'startsWith', 'strike', 'sub', 'substr', 'substring', 'sup', 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toString', 'toUpperCase', 'trim', 'trimEnd', 'trimLeft', 'trimRight', 'trimStart', 'valueOf']",
     "Boolean": "['length', 'name', 'prototype']",
     "Boolean.prototype": "['constructor', 'toString', 'valueOf']",
     "Number": "['EPSILON', 'MAX_SAFE_INTEGER', 'MAX_VALUE', 'MIN_SAFE_INTEGER', 'MIN_VALUE', 'NEGATIVE_INFINITY', 'NaN', 'POSITIVE_INFINITY', 'isFinite', 'isInteger', 'isNaN', 'isSafeInteger', 'length', 'name', 'parseFloat', 'parseInt', 'prototype']",

Modified: trunk/Source/_javascript_Core/ChangeLog (268164 => 268165)


--- trunk/Source/_javascript_Core/ChangeLog	2020-10-08 00:27:40 UTC (rev 268164)
+++ trunk/Source/_javascript_Core/ChangeLog	2020-10-08 00:59:36 UTC (rev 268165)
@@ -1,3 +1,19 @@
+2020-10-07  Ross Kirsling  <[email protected]>
+
+        [JSC] Revert String.prototype.item
+        https://bugs.webkit.org/show_bug.cgi?id=217449
+
+        Reviewed by Yusuke Suzuki.
+
+        This patch reverts the String part of r267814, as it has been shown to be web-incompatible:
+        https://github.com/tc39/proposal-item-method/issues/31
+
+        Thankfully, this was the inessential part of the proposal; the core parts (Array and %TypedArray%) remain for now.
+
+        * builtins/StringPrototype.js:
+        (item): Deleted.
+        * runtime/StringPrototype.cpp:
+
 2020-10-07  Keith Rollin  <[email protected]>
 
         Update post-processing rules for headers to not unnecessarily change timestamps

Modified: trunk/Source/_javascript_Core/builtins/StringPrototype.js (268164 => 268165)


--- trunk/Source/_javascript_Core/builtins/StringPrototype.js	2020-10-08 00:27:40 UTC (rev 268164)
+++ trunk/Source/_javascript_Core/builtins/StringPrototype.js	2020-10-08 00:59:36 UTC (rev 268165)
@@ -340,25 +340,6 @@
     return @tailCallForwardArguments(@stringConcatSlowPath, this);
 }
 
-// FIXME: This is extremely similar to charAt, so we should optimize it accordingly.
-//        https://bugs.webkit.org/show_bug.cgi?id=217139
-function item(index)
-{
-    "use strict";
-
-    if (@isUndefinedOrNull(this))
-        @throwTypeError("String.prototype.item requires that |this| not be null or undefined");
-
-    var string = @toString(this);
-    var length = string.length;
-
-    var k = @toInteger(index);
-    if (k < 0)
-        k += length;
-
-    return (k >= 0 && k < length) ? string[k] : @undefined;
-}
-
 @globalPrivate
 function createHTML(func, string, tag, attribute, value)
 {

Modified: trunk/Source/_javascript_Core/runtime/StringPrototype.cpp (268164 => 268165)


--- trunk/Source/_javascript_Core/runtime/StringPrototype.cpp	2020-10-08 00:27:40 UTC (rev 268164)
+++ trunk/Source/_javascript_Core/runtime/StringPrototype.cpp	2020-10-08 00:59:36 UTC (rev 268165)
@@ -90,7 +90,6 @@
 /* Source for StringConstructor.lut.h
 @begin stringPrototypeTable
     concat        JSBuiltin    DontEnum|Function 1
-    item          JSBuiltin    DontEnum|Function 1
     match         JSBuiltin    DontEnum|Function 1
     matchAll      JSBuiltin    DontEnum|Function 1
     padStart      JSBuiltin    DontEnum|Function 1
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to