Reviewers: Jakob,
Message:
PTAL.
Description:
Experimental profiler: split RegExp.test() for better optimization.
BUG=
TEST=
Please review this at http://codereview.chromium.org/9701064/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/regexp.js
Index: src/regexp.js
diff --git a/src/regexp.js b/src/regexp.js
index
ace0be1564572e5b48df5ccf287869f7b310dc3d..c3837a95d9855a8190f9bf2f5d9ad9abb1baaa8b
100644
--- a/src/regexp.js
+++ b/src/regexp.js
@@ -253,16 +253,7 @@ function RegExpTest(string) {
if (%_StringCharCodeAt(this.source, 0) == 46 && // '.'
%_StringCharCodeAt(this.source, 1) == 42 && // '*'
%_StringCharCodeAt(this.source, 2) != 63) { // '?'
- if (!%_ObjectEquals(regexp_key, this)) {
- regexp_key = this;
- regexp_val = new $RegExp(SubString(this.source, 2,
this.source.length),
- (!this.ignoreCase
- ? !this.multiline ? "" : "m"
- : !this.multiline ? "i" : "im"));
- }
- if (%_RegExpExec(regexp_val, string, 0, lastMatchInfo) === null) {
- return false;
- }
+ regexp = TrimRegExp(regexp);
}
%_Log('regexp', 'regexp-exec,%0r,%1S,%2i', [this, string, lastIndex]);
// matchIndices is either null or the lastMatchInfo array.
@@ -273,6 +264,17 @@ function RegExpTest(string) {
}
}
+function TrimRegExp() {
+ if (!%_ObjectEquals(regexp_key, regexp)) {
+ regexp_key = regexp;
+ regexp_val =
+ new $RegExp(SubString(regexp.source, 2, regexp.source.length),
+ (!regexp.ignoreCase ? !regexp.multiline ? "" : "m"
+ : !regexp.multiline ? "i" : "im"));
+ }
+ return regexp_val;
+}
+
function RegExpToString() {
// If this.source is an empty string, output /(?:)/.
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev