Merge V8 5.3.332.45. DO NOT MERGE
Test: Manual
FPIIM-449
Change-Id: Id3254828b068abdea3cb10442e0172a8c9a98e03
(cherry picked from commit 13e2dadd00298019ed862f2b2fc5068bba730bcf)
diff --git a/src/js/regexp.js b/src/js/regexp.js
index 719a081..6b7cf48 100644
--- a/src/js/regexp.js
+++ b/src/js/regexp.js
@@ -22,6 +22,7 @@
var matchSymbol = utils.ImportNow("match_symbol");
var replaceSymbol = utils.ImportNow("replace_symbol");
var searchSymbol = utils.ImportNow("search_symbol");
+var speciesSymbol = utils.ImportNow("species_symbol");
var splitSymbol = utils.ImportNow("split_symbol");
var SpeciesConstructor;
@@ -323,10 +324,10 @@
// not a '?'. But see https://code.google.com/p/v8/issues/detail?id=3560
var regexp = this;
var source = REGEXP_SOURCE(regexp);
- if (regexp.length >= 3 &&
- %_StringCharCodeAt(regexp, 0) == 46 && // '.'
- %_StringCharCodeAt(regexp, 1) == 42 && // '*'
- %_StringCharCodeAt(regexp, 2) != 63) { // '?'
+ if (source.length >= 3 &&
+ %_StringCharCodeAt(source, 0) == 46 && // '.'
+ %_StringCharCodeAt(source, 1) == 42 && // '*'
+ %_StringCharCodeAt(source, 2) != 63) { // '?'
regexp = TrimRegExp(regexp);
}
// matchIndices is either null or the RegExpLastMatchInfo array.
@@ -537,22 +538,6 @@
%FunctionRemovePrototype(RegExpSubclassSplit);
-// Legacy implementation of RegExp.prototype[Symbol.match] which
-// doesn't properly call the underlying exec method
-function RegExpMatch(string) {
- if (!IS_REGEXP(this)) {
- throw MakeTypeError(kIncompatibleMethodReceiver,
- "RegExp.prototype.@@match", this);
- }
- var subject = TO_STRING(string);
-
- if (!REGEXP_GLOBAL(this)) return RegExpExecNoTests(this, subject, 0);
- this.lastIndex = 0;
- var result = %StringMatch(subject, this, RegExpLastMatchInfo);
- return result;
-}
-
-
// ES#sec-regexp.prototype-@@match
// RegExp.prototype [ @@match ] ( string )
function RegExpSubclassMatch(string) {
@@ -952,19 +937,6 @@
%FunctionRemovePrototype(RegExpSubclassReplace);
-// Legacy implementation of RegExp.prototype[Symbol.search] which
-// doesn't properly use the overridden exec method
-function RegExpSearch(string) {
- if (!IS_REGEXP(this)) {
- throw MakeTypeError(kIncompatibleMethodReceiver,
- "RegExp.prototype.@@search", this);
- }
- var match = DoRegExpExec(this, TO_STRING(string), 0);
- if (match) return match[CAPTURE0];
- return -1;
-}
-
-
// ES#sec-regexp.prototype-@@search
// RegExp.prototype [ @@search ] ( string )
function RegExpSubclassSearch(string) {
@@ -1132,6 +1104,27 @@
}
%SetForceInlineFlag(RegExpGetSticky);
+
+// ES6 21.2.5.15.
+function RegExpGetUnicode() {
+ if (!IS_REGEXP(this)) {
+ // TODO(littledan): Remove this RegExp compat workaround
+ if (this === GlobalRegExpPrototype) {
+ %IncrementUseCounter(kRegExpPrototypeUnicodeGetter);
+ return UNDEFINED;
+ }
+ throw MakeTypeError(kRegExpNonRegExp, "RegExp.prototype.unicode");
+ }
+ return TO_BOOLEAN(REGEXP_UNICODE(this));
+}
+%SetForceInlineFlag(RegExpGetUnicode);
+
+
+function RegExpSpecies() {
+ return this;
+}
+
+
// -------------------------------------------------------------------
%FunctionSetInstanceClassName(GlobalRegExp, 'RegExp');
@@ -1141,15 +1134,17 @@
GlobalRegExp.prototype, 'constructor', GlobalRegExp, DONT_ENUM);
%SetCode(GlobalRegExp, RegExpConstructor);
+utils.InstallGetter(GlobalRegExp, speciesSymbol, RegExpSpecies);
+
utils.InstallFunctions(GlobalRegExp.prototype, DONT_ENUM, [
- "exec", RegExpExecJS,
- "test", RegExpTest,
+ "exec", RegExpSubclassExecJS,
+ "test", RegExpSubclassTest,
"toString", RegExpToString,
"compile", RegExpCompileJS,
- matchSymbol, RegExpMatch,
- replaceSymbol, RegExpReplace,
- searchSymbol, RegExpSearch,
- splitSymbol, RegExpSplit,
+ matchSymbol, RegExpSubclassMatch,
+ replaceSymbol, RegExpSubclassReplace,
+ searchSymbol, RegExpSubclassSearch,
+ splitSymbol, RegExpSubclassSplit,
]);
utils.InstallGetter(GlobalRegExp.prototype, 'flags', RegExpGetFlags);
@@ -1158,6 +1153,7 @@
utils.InstallGetter(GlobalRegExp.prototype, 'multiline', RegExpGetMultiline);
utils.InstallGetter(GlobalRegExp.prototype, 'source', RegExpGetSource);
utils.InstallGetter(GlobalRegExp.prototype, 'sticky', RegExpGetSticky);
+utils.InstallGetter(GlobalRegExp.prototype, 'unicode', RegExpGetUnicode);
// The properties `input` and `$_` are aliases for each other. When this
// value is set the value it is set to is coerced to a string.
@@ -1232,12 +1228,6 @@
to.RegExpExec = DoRegExpExec;
to.RegExpInitialize = RegExpInitialize;
to.RegExpLastMatchInfo = RegExpLastMatchInfo;
- to.RegExpSubclassExecJS = RegExpSubclassExecJS;
- to.RegExpSubclassMatch = RegExpSubclassMatch;
- to.RegExpSubclassReplace = RegExpSubclassReplace;
- to.RegExpSubclassSearch = RegExpSubclassSearch;
- to.RegExpSubclassSplit = RegExpSubclassSplit;
- to.RegExpSubclassTest = RegExpSubclassTest;
to.RegExpTest = RegExpTest;
});