ES6: Implement String.prototype.split and RegExp.prototype[@@split].
authormark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Apr 2016 22:40:25 +0000 (22:40 +0000)
committermark.lam@apple.com <mark.lam@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Apr 2016 22:40:25 +0000 (22:40 +0000)
commita721795ebe6ee8849476042fc31e1126b29e4234
tree3709faeee3e4bc7a2d0968999844f38ed12680c2
parent64c71e6ac0944a44f9a1612f6e28ef068f657b7a
ES6: Implement String.prototype.split and RegExp.prototype[@@split].
https://bugs.webkit.org/show_bug.cgi?id=156013

Reviewed by Keith Miller.

Source/JavaScriptCore:

* CMakeLists.txt:
* JavaScriptCore.xcodeproj/project.pbxproj:
* builtins/GlobalObject.js:
(speciesConstructor):
* builtins/PromisePrototype.js:
- refactored to use the @speciesConstructor internal function.

* builtins/RegExpPrototype.js:
(advanceStringIndex):
- refactored from @advanceStringIndexUnicode() to be match the spec.
  Benchmarks show that there's no advantage in doing the unicode check outside
  of the advanceStringIndexUnicode part.  So, I simplified the code to match the
  spec (especially since @@split needs to call advanceStringIndex from more than
  1 location).
(match):
- Removed an unnecessary call to @Object because it was already proven above.
- Changed to use advanceStringIndex instead of advanceStringIndexUnicode.
  Again, there's no perf regression for this.
(regExpExec):
(hasObservableSideEffectsForRegExpSplit):
(split):
(advanceStringIndexUnicode): Deleted.

* builtins/StringPrototype.js:
(split):
- Modified to use RegExp.prototype[@@split].

* bytecode/BytecodeIntrinsicRegistry.cpp:
(JSC::BytecodeIntrinsicRegistry::BytecodeIntrinsicRegistry):
(JSC::BytecodeIntrinsicRegistry::lookup):
* bytecode/BytecodeIntrinsicRegistry.h:
- Added the @@split symbol.

* runtime/CommonIdentifiers.h:
* runtime/ECMAScriptSpecInternalFunctions.cpp: Added.
(JSC::esSpecIsConstructor):
(JSC::esSpecIsRegExp):
* runtime/ECMAScriptSpecInternalFunctions.h: Added.

* runtime/JSGlobalObject.cpp:
(JSC::getGetterById):
(JSC::JSGlobalObject::init):

* runtime/PropertyDescriptor.cpp:
(JSC::PropertyDescriptor::setDescriptor):
- Removed an assert that is no longer valid.

* runtime/RegExpObject.h:
- Made advanceStringUnicode() public so that it can be re-used by the regexp split
  fast path.

* runtime/RegExpPrototype.cpp:
(JSC::RegExpPrototype::finishCreation):
(JSC::regExpProtoFuncExec):
(JSC::regExpProtoFuncSearch):
(JSC::advanceStringIndex):
(JSC::regExpProtoFuncSplitFast):
* runtime/RegExpPrototype.h:

* runtime/StringObject.h:
(JSC::jsStringWithReuse):
(JSC::jsSubstring):
- Hoisted some utility functions from StringPrototype.cpp so that they can be
  reused by the regexp split fast path.

* runtime/StringPrototype.cpp:
(JSC::StringPrototype::finishCreation):
(JSC::stringProtoFuncSplitFast):
(JSC::stringProtoFuncSubstr):
(JSC::builtinStringSubstrInternal):
(JSC::stringProtoFuncSubstring):
(JSC::stringIncludesImpl):
(JSC::stringProtoFuncIncludes):
(JSC::builtinStringIncludesInternal):
(JSC::jsStringWithReuse): Deleted.
(JSC::jsSubstring): Deleted.
(JSC::stringProtoFuncSplit): Deleted.
* runtime/StringPrototype.h:

* tests/es6.yaml:

LayoutTests:

* js/Object-getOwnPropertyNames-expected.txt:
* js/dom/string-prototype-properties-expected.txt:

* js/regress/regexp-prototype-split-observable-side-effects-expected.txt: Added.
* js/regress/regexp-prototype-split-observable-side-effects.html: Added.
* js/regress/regexp-prototype-split-observable-side-effects2-expected.txt: Added.
* js/regress/regexp-prototype-split-observable-side-effects2.html: Added.
* js/regress/regexp-prototype-split-observable-side-effects3-flags-expected.txt: Added.
* js/regress/regexp-prototype-split-observable-side-effects3-flags.html: Added.
* js/regress/regexp-prototype-split-observable-side-effects3-global-expected.txt: Added.
* js/regress/regexp-prototype-split-observable-side-effects3-global.html: Added.
* js/regress/regexp-prototype-split-observable-side-effects3-ignoreCase-expected.txt: Added.
* js/regress/regexp-prototype-split-observable-side-effects3-ignoreCase.html: Added.
* js/regress/regexp-prototype-split-observable-side-effects3-multiline-expected.txt: Added.
* js/regress/regexp-prototype-split-observable-side-effects3-multiline.html: Added.
* js/regress/regexp-prototype-split-observable-side-effects3-sticky-expected.txt: Added.
* js/regress/regexp-prototype-split-observable-side-effects3-sticky.html: Added.
* js/regress/regexp-prototype-split-observable-side-effects3-unicode-expected.txt: Added.
* js/regress/regexp-prototype-split-observable-side-effects3-unicode.html: Added.
* js/regress/regexp-prototype-split-observable-side-effects4-expected.txt: Added.
* js/regress/regexp-prototype-split-observable-side-effects4.html: Added.

* js/regress/script-tests/regexp-prototype-split-observable-side-effects.js: Added.
* js/regress/script-tests/regexp-prototype-split-observable-side-effects2.js: Added.
* js/regress/script-tests/regexp-prototype-split-observable-side-effects3-flags.js: Added.
* js/regress/script-tests/regexp-prototype-split-observable-side-effects3-global.js: Added.
* js/regress/script-tests/regexp-prototype-split-observable-side-effects3-ignoreCase.js: Added.
* js/regress/script-tests/regexp-prototype-split-observable-side-effects3-multiline.js: Added.
* js/regress/script-tests/regexp-prototype-split-observable-side-effects3-sticky.js: Added.
* js/regress/script-tests/regexp-prototype-split-observable-side-effects3-unicode.js: Added.
* js/regress/script-tests/regexp-prototype-split-observable-side-effects4.js: Added.

* js/regress/script-tests/string-prototype-split-observable-side-effects.js: Added.
* js/regress/script-tests/string-prototype-split-observable-side-effects2.js: Added.
* js/regress/script-tests/string-prototype-split-observable-side-effects3-flags.js: Added.
* js/regress/script-tests/string-prototype-split-observable-side-effects3-global.js: Added.
* js/regress/script-tests/string-prototype-split-observable-side-effects3-ignoreCase.js: Added.
* js/regress/script-tests/string-prototype-split-observable-side-effects3-multiline.js: Added.
* js/regress/script-tests/string-prototype-split-observable-side-effects3-sticky.js: Added.
* js/regress/script-tests/string-prototype-split-observable-side-effects3-unicode.js: Added.
* js/regress/script-tests/string-prototype-split-observable-side-effects4.js: Added.

* js/regress/string-prototype-split-observable-side-effects-expected.txt: Added.
* js/regress/string-prototype-split-observable-side-effects.html: Added.
* js/regress/string-prototype-split-observable-side-effects2-expected.txt: Added.
* js/regress/string-prototype-split-observable-side-effects2.html: Added.
* js/regress/string-prototype-split-observable-side-effects3-flags-expected.txt: Added.
* js/regress/string-prototype-split-observable-side-effects3-flags.html: Added.
* js/regress/string-prototype-split-observable-side-effects3-global-expected.txt: Added.
* js/regress/string-prototype-split-observable-side-effects3-global.html: Added.
* js/regress/string-prototype-split-observable-side-effects3-ignoreCase-expected.txt: Added.
* js/regress/string-prototype-split-observable-side-effects3-ignoreCase.html: Added.
* js/regress/string-prototype-split-observable-side-effects3-multiline-expected.txt: Added.
* js/regress/string-prototype-split-observable-side-effects3-multiline.html: Added.
* js/regress/string-prototype-split-observable-side-effects3-sticky-expected.txt: Added.
* js/regress/string-prototype-split-observable-side-effects3-sticky.html: Added.
* js/regress/string-prototype-split-observable-side-effects3-unicode-expected.txt: Added.
* js/regress/string-prototype-split-observable-side-effects3-unicode.html: Added.
* js/regress/string-prototype-split-observable-side-effects4-expected.txt: Added.
* js/regress/string-prototype-split-observable-side-effects4.html: Added.

* js/script-tests/Object-getOwnPropertyNames.js:
* sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.14_String.prototype.split/S15.5.4.14_A1_T3-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@199393 268f45cc-cd09-0410-ab3c-d52691b4dbfc
80 files changed:
LayoutTests/ChangeLog
LayoutTests/js/Object-getOwnPropertyNames-expected.txt
LayoutTests/js/dom/string-prototype-properties-expected.txt
LayoutTests/js/regress/regexp-prototype-split-observable-side-effects-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/regexp-prototype-split-observable-side-effects.html [new file with mode: 0644]
LayoutTests/js/regress/regexp-prototype-split-observable-side-effects2-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/regexp-prototype-split-observable-side-effects2.html [new file with mode: 0644]
LayoutTests/js/regress/regexp-prototype-split-observable-side-effects3-flags-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/regexp-prototype-split-observable-side-effects3-flags.html [new file with mode: 0644]
LayoutTests/js/regress/regexp-prototype-split-observable-side-effects3-global-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/regexp-prototype-split-observable-side-effects3-global.html [new file with mode: 0644]
LayoutTests/js/regress/regexp-prototype-split-observable-side-effects3-ignoreCase-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/regexp-prototype-split-observable-side-effects3-ignoreCase.html [new file with mode: 0644]
LayoutTests/js/regress/regexp-prototype-split-observable-side-effects3-multiline-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/regexp-prototype-split-observable-side-effects3-multiline.html [new file with mode: 0644]
LayoutTests/js/regress/regexp-prototype-split-observable-side-effects3-sticky-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/regexp-prototype-split-observable-side-effects3-sticky.html [new file with mode: 0644]
LayoutTests/js/regress/regexp-prototype-split-observable-side-effects3-unicode-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/regexp-prototype-split-observable-side-effects3-unicode.html [new file with mode: 0644]
LayoutTests/js/regress/regexp-prototype-split-observable-side-effects4-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/regexp-prototype-split-observable-side-effects4.html [new file with mode: 0644]
LayoutTests/js/regress/script-tests/regexp-prototype-split-observable-side-effects.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/regexp-prototype-split-observable-side-effects2.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/regexp-prototype-split-observable-side-effects3-flags.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/regexp-prototype-split-observable-side-effects3-global.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/regexp-prototype-split-observable-side-effects3-ignoreCase.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/regexp-prototype-split-observable-side-effects3-multiline.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/regexp-prototype-split-observable-side-effects3-sticky.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/regexp-prototype-split-observable-side-effects3-unicode.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/regexp-prototype-split-observable-side-effects4.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/string-prototype-split-observable-side-effects.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/string-prototype-split-observable-side-effects2.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/string-prototype-split-observable-side-effects3-flags.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/string-prototype-split-observable-side-effects3-global.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/string-prototype-split-observable-side-effects3-ignoreCase.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/string-prototype-split-observable-side-effects3-multiline.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/string-prototype-split-observable-side-effects3-sticky.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/string-prototype-split-observable-side-effects3-unicode.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/string-prototype-split-observable-side-effects4.js [new file with mode: 0644]
LayoutTests/js/regress/string-prototype-split-observable-side-effects-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/string-prototype-split-observable-side-effects.html [new file with mode: 0644]
LayoutTests/js/regress/string-prototype-split-observable-side-effects2-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/string-prototype-split-observable-side-effects2.html [new file with mode: 0644]
LayoutTests/js/regress/string-prototype-split-observable-side-effects3-flags-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/string-prototype-split-observable-side-effects3-flags.html [new file with mode: 0644]
LayoutTests/js/regress/string-prototype-split-observable-side-effects3-global-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/string-prototype-split-observable-side-effects3-global.html [new file with mode: 0644]
LayoutTests/js/regress/string-prototype-split-observable-side-effects3-ignoreCase-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/string-prototype-split-observable-side-effects3-ignoreCase.html [new file with mode: 0644]
LayoutTests/js/regress/string-prototype-split-observable-side-effects3-multiline-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/string-prototype-split-observable-side-effects3-multiline.html [new file with mode: 0644]
LayoutTests/js/regress/string-prototype-split-observable-side-effects3-sticky-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/string-prototype-split-observable-side-effects3-sticky.html [new file with mode: 0644]
LayoutTests/js/regress/string-prototype-split-observable-side-effects3-unicode-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/string-prototype-split-observable-side-effects3-unicode.html [new file with mode: 0644]
LayoutTests/js/regress/string-prototype-split-observable-side-effects4-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/string-prototype-split-observable-side-effects4.html [new file with mode: 0644]
LayoutTests/js/script-tests/Object-getOwnPropertyNames.js
LayoutTests/sputnik/Conformance/15_Native_Objects/15.5_String/15.5.4/15.5.4.14_String.prototype.split/S15.5.4.14_A1_T3-expected.txt
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/builtins/GlobalObject.js
Source/JavaScriptCore/builtins/PromisePrototype.js
Source/JavaScriptCore/builtins/RegExpPrototype.js
Source/JavaScriptCore/builtins/StringPrototype.js
Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.cpp
Source/JavaScriptCore/bytecode/BytecodeIntrinsicRegistry.h
Source/JavaScriptCore/runtime/CommonIdentifiers.h
Source/JavaScriptCore/runtime/ECMAScriptSpecInternalFunctions.cpp [new file with mode: 0644]
Source/JavaScriptCore/runtime/ECMAScriptSpecInternalFunctions.h [new file with mode: 0644]
Source/JavaScriptCore/runtime/JSGlobalObject.cpp
Source/JavaScriptCore/runtime/PropertyDescriptor.cpp
Source/JavaScriptCore/runtime/RegExpObject.h
Source/JavaScriptCore/runtime/RegExpPrototype.cpp
Source/JavaScriptCore/runtime/RegExpPrototype.h
Source/JavaScriptCore/runtime/StringObject.h
Source/JavaScriptCore/runtime/StringPrototype.cpp
Source/JavaScriptCore/runtime/StringPrototype.h
Source/JavaScriptCore/tests/es6.yaml