Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(426)

Unified Diff: src/regexp.js

Issue 10996065: Improves performance for calls from Crankshaft code to certain string and... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/hydrogen.cc ('k') | src/string.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/regexp.js
===================================================================
--- src/regexp.js (revision 12582)
+++ src/regexp.js (working copy)
@@ -206,6 +206,47 @@
}
+function RegExpExecNoResult(string) {
+ if (!IS_REGEXP(this)) {
+ throw MakeTypeError('incompatible_method_receiver',
+ ['RegExp.prototype.exec', this]);
+ }
+
+ if (%_ArgumentsLength() === 0) {
+ var regExpInput = LAST_INPUT(lastMatchInfo);
+ if (IS_UNDEFINED(regExpInput)) {
+ throw MakeError('no_input_to_regexp', [this]);
+ }
+ string = regExpInput;
+ }
+ string = TO_STRING_INLINE(string);
+ var lastIndex = this.lastIndex;
+
+ // Conversion is required by the ES5 specification (RegExp.prototype.exec
+ // algorithm, step 5) even if the value is discarded for non-global RegExps.
+ var i = TO_INTEGER(lastIndex);
+
+ var global = this.global;
+ if (global) {
+ if (i < 0 || i > string.length) {
+ this.lastIndex = 0;
+ return null;
+ }
+ } else {
+ i = 0;
+ }
+
+ %_Log('regexp', 'regexp-exec,%0r,%1S,%2i', [this, string, lastIndex]);
+ // matchIndices is either null or the lastMatchInfo array.
+ var matchIndices = %_RegExpExec(this, string, i, lastMatchInfo);
+
+ if (matchIndices === null) {
+ if (global) this.lastIndex = 0;
+ return null;
+ }
+}
+
+
// One-element cache for the simplified test regexp.
var regexp_key;
var regexp_val;
« no previous file with comments | « src/hydrogen.cc ('k') | src/string.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698