Changeset 270005 in webkit
- Timestamp:
- Nov 18, 2020, 6:32:56 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JSTests/ChangeLog
r269998 r270005 1 2020-11-18 Ross Kirsling <ross.kirsling@sony.com> 2 3 [JSC] Reinstate String#at 4 https://bugs.webkit.org/show_bug.cgi?id=219124 5 6 Reviewed by Yusuke Suzuki. 7 8 * stress/at-method.js: Re-add tests. 9 * test262/config.yaml: Re-enable feature. 10 * test262/expectations.yaml: 11 "at/prop-desc.js" failures are due to a typo; will be fixed in https://github.com/tc39/test262/pull/2908. 12 1 13 2020-11-17 Yusuke Suzuki <ysuzuki@apple.com> 2 14 -
trunk/JSTests/stress/at-method.js
r268760 r270005 50 50 shouldBe(ta.at({ valueOf: () => -1 }), ta[ta.length - 1]); 51 51 } 52 53 shouldBe(String.prototype.at.length, 1); 54 shouldThrowTypeError(() => String.prototype.at.call(undefined)); 55 shouldThrowTypeError(() => String.prototype.at.call(null)); 56 57 const string = 'abc'; 58 // intentionally go one too far to ensure that we get undefined instead of wrapping 59 for (let i = 0; i <= string.length; i++) { 60 shouldBe(string.at(i), string[i]); 61 shouldBe(string.at(-i - 1), string[string.length - i - 1]); 62 } 63 shouldBe(string.at(), string[0]); 64 shouldBe(string.at(null), string[0]); 65 shouldBe(string.at({ valueOf: () => -1 }), string[string.length - 1]); 66 67 const emojiPseudoString = { toString: () => '😅' }; 68 shouldBe(String.prototype.at.call(emojiPseudoString, 0), '\u{d83d}'); 69 shouldBe(String.prototype.at.call(emojiPseudoString, -1), '\u{de05}'); -
trunk/JSTests/test262/config.yaml
r269986 r270005 11 11 Array.prototype.at: useAtMethod 12 12 TypedArray.prototype.at: useAtMethod 13 String.prototype.at: useAtMethod 13 14 skip: 14 15 features: … … 28 29 - top-level-await 29 30 - Intl.ListFormat 30 31 - String.prototype.at32 31 paths: 33 32 - test/built-ins/DataView/prototype/getBigInt64 -
trunk/JSTests/test262/expectations.yaml
r269986 r270005 824 824 default: 'SyntaxError: Invalid regular expression: number too large in {} quantifier' 825 825 strict mode: 'SyntaxError: Invalid regular expression: number too large in {} quantifier' 826 test/built-ins/String/prototype/at/prop-desc.js: 827 default: 'Test262Error: descriptor should be writable' 828 strict mode: 'Test262Error: descriptor should be writable' 826 829 test/built-ins/TypedArray/prototype/at/prop-desc.js: 827 830 default: 'Test262Error: descriptor should be writable' -
trunk/Source/JavaScriptCore/ChangeLog
r269998 r270005 1 2020-11-18 Ross Kirsling <ross.kirsling@sony.com> 2 3 [JSC] Reinstate String#at 4 https://bugs.webkit.org/show_bug.cgi?id=219124 5 6 Reviewed by Yusuke Suzuki. 7 8 At this week's TC39 meeting, consensus was achieved on renaming item() *and* keeping it for strings too. 9 Accordingly, this patch reinstates String.prototype.at behind the existing useAtMethod runtime option. 10 11 * builtins/StringPrototype.js: 12 (at): 13 * runtime/StringPrototype.cpp: 14 (JSC::StringPrototype::finishCreation): 15 1 16 2020-11-17 Yusuke Suzuki <ysuzuki@apple.com> 2 17 -
trunk/Source/JavaScriptCore/builtins/StringPrototype.js
r268165 r270005 341 341 } 342 342 343 // FIXME: This is extremely similar to charAt, so we should optimize it accordingly. 344 // https://bugs.webkit.org/show_bug.cgi?id=217139 345 function at(index) 346 { 347 "use strict"; 348 349 if (@isUndefinedOrNull(this)) 350 @throwTypeError("String.prototype.at requires that |this| not be null or undefined"); 351 352 var string = @toString(this); 353 var length = string.length; 354 355 var k = @toInteger(index); 356 if (k < 0) 357 k += length; 358 359 return (k >= 0 && k < length) ? string[k] : @undefined; 360 } 361 343 362 @globalPrivate 344 363 function createHTML(func, string, tag, attribute, value) -
trunk/Source/JavaScriptCore/runtime/StringPrototype.cpp
r268990 r270005 151 151 JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("normalize", stringProtoFuncNormalize, static_cast<unsigned>(PropertyAttribute::DontEnum), 0); 152 152 JSC_NATIVE_INTRINSIC_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().charCodeAtPrivateName(), stringProtoFuncCharCodeAt, static_cast<unsigned>(PropertyAttribute::DontEnum), 1, CharCodeAtIntrinsic); 153 154 if (Options::useAtMethod()) 155 JSC_BUILTIN_FUNCTION_WITHOUT_TRANSITION(vm.propertyNames->builtinNames().atPublicName(), stringPrototypeAtCodeGenerator, static_cast<unsigned>(PropertyAttribute::DontEnum)); 153 156 154 157 JSFunction* trimStartFunction = JSFunction::create(vm, globalObject, 0, "trimStart"_s, stringProtoFuncTrimStart, NoIntrinsic);
Note:
See TracChangeset
for help on using the changeset viewer.