Ignore:
Timestamp:
Apr 12, 2016, 3:40:25 PM (9 years ago)
Author:
[email protected]
Message:

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:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/builtins/GlobalObject.js

    r198981 r199393  
    11/*
    22 * Copyright (C) 2015 Yusuke Suzuki <[email protected]>.
     3 * Copyright (C) 2016 Apple Inc. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    6162    return this;
    6263}
     64
     65function speciesConstructor(obj, defaultConstructor)
     66{
     67    var constructor = obj.constructor;
     68    if (constructor === @undefined)
     69        return defaultConstructor;
     70    if (!@isObject(constructor))
     71        throw new @TypeError("|this|.constructor is not an Object or undefined");
     72    constructor = constructor[@symbolSpecies];
     73    if (constructor == null)
     74        return defaultConstructor;
     75    if (@isConstructor(constructor))
     76        return constructor;
     77    throw new @TypeError("|this|.constructor[Symbol.species] is not a constructor");
     78}
Note: See TracChangeset for help on using the changeset viewer.