Revision: 21348
Author: [email protected]
Date: Fri May 16 15:42:00 2014 UTC
Log: Fix performance regression in regular expressions after
Array.push() optimizations
[email protected]
LOG=N
Review URL: https://codereview.chromium.org/281953002
http://code.google.com/p/v8/source/detail?r=21348
Modified:
/branches/bleeding_edge/src/code-stubs-hydrogen.cc
/branches/bleeding_edge/src/regexp.js
/branches/bleeding_edge/src/string.js
=======================================
--- /branches/bleeding_edge/src/code-stubs-hydrogen.cc Mon May 12 07:49:11
2014 UTC
+++ /branches/bleeding_edge/src/code-stubs-hydrogen.cc Fri May 16 15:42:00
2014 UTC
@@ -1483,6 +1483,8 @@
HValue* index = GetParameter(RegExpConstructResultStub::kIndex);
HValue* input = GetParameter(RegExpConstructResultStub::kInput);
+ info()->MarkMustNotHaveEagerFrame();
+
return BuildRegExpConstructResult(length, index, input);
}
=======================================
--- /branches/bleeding_edge/src/regexp.js Fri May 16 13:43:19 2014 UTC
+++ /branches/bleeding_edge/src/regexp.js Fri May 16 15:42:00 2014 UTC
@@ -115,8 +115,12 @@
var numResults = NUMBER_OF_CAPTURES(MATCHINFO) >> 1;
var start = MATCHINFO[CAPTURE0];
var end = MATCHINFO[CAPTURE1];
+ // Calculate the substring of the first match before creating the result
array
+ // to avoid an unnecessary write barrier storing the first result.
+ var first = %_SubString(STRING, start, end);
var result = %_RegExpConstructResult(numResults, start, STRING);
- result[0] = %_SubString(STRING, start, end);
+ result[0] = first;
+ if (numResults == 1) return result;
var j = REGEXP_FIRST_CAPTURE + 2;
for (var i = 1; i < numResults; i++) {
start = MATCHINFO[j++];
=======================================
--- /branches/bleeding_edge/src/string.js Wed May 14 08:51:10 2014 UTC
+++ /branches/bleeding_edge/src/string.js Fri May 16 15:42:00 2014 UTC
@@ -618,8 +618,6 @@
}
-var ArrayPushBuiltin = $Array.prototype.push;
-
function StringSplitOnRegExp(subject, separator, limit, length) {
if (length === 0) {
if (DoRegExpExec(separator, subject, 0, 0) != null) {
@@ -637,15 +635,13 @@
while (true) {
if (startIndex === length) {
- %_CallFunction(result, %_SubString(subject, currentIndex, length),
- ArrayPushBuiltin);
+ result[result.length] = %_SubString(subject, currentIndex, length);
break;
}
var matchInfo = DoRegExpExec(separator, subject, startIndex);
if (matchInfo == null || length === (startMatch =
matchInfo[CAPTURE0])) {
- %_CallFunction(result, %_SubString(subject, currentIndex, length),
- ArrayPushBuiltin);
+ result[result.length] = %_SubString(subject, currentIndex, length);
break;
}
var endIndex = matchInfo[CAPTURE1];
@@ -656,8 +652,7 @@
continue;
}
- %_CallFunction(result, %_SubString(subject, currentIndex, startMatch),
- ArrayPushBuiltin);
+ result[result.length] = %_SubString(subject, currentIndex, startMatch);
if (result.length === limit) break;
@@ -666,10 +661,9 @@
var start = matchInfo[i++];
var end = matchInfo[i++];
if (end != -1) {
- %_CallFunction(result, %_SubString(subject, start, end),
- ArrayPushBuiltin);
+ result[result.length] = %_SubString(subject, start, end);
} else {
- %_CallFunction(result, UNDEFINED, ArrayPushBuiltin);
+ result[result.length] = UNDEFINED;
}
if (result.length === limit) break outer_loop;
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.