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

Unified Diff: src/regexp/regexp-utils.cc

Issue 2808023002: [regexp] Ensure there are no shape changes on the fast path (Closed)
Patch Set: Rebase and backmerge second part Created 3 years, 8 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/builtins/builtins-string.cc ('k') | test/mjsunit/regress/regress-6210.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/regexp/regexp-utils.cc
diff --git a/src/regexp/regexp-utils.cc b/src/regexp/regexp-utils.cc
index d40431866a391388b4e8ebfbbbe75e529e6bb2c5..570a348f74a42c1f9029596da676c9ad740ed479 100644
--- a/src/regexp/regexp-utils.cc
+++ b/src/regexp/regexp-utils.cc
@@ -145,7 +145,14 @@ bool RegExpUtils::IsUnmodifiedRegExp(Isolate* isolate, Handle<Object> obj) {
if (!proto->IsJSReceiver()) return false;
Handle<Map> initial_proto_initial_map = isolate->regexp_prototype_map();
- return (JSReceiver::cast(proto)->map() == *initial_proto_initial_map);
+ if (JSReceiver::cast(proto)->map() != *initial_proto_initial_map) {
+ return false;
+ }
+
+ // The smi check is required to omit ToLength(lastIndex) calls with possible
+ // user-code execution on the fast path.
+ Object* last_index = JSRegExp::cast(recv)->LastIndex();
+ return last_index->IsSmi() && Smi::cast(last_index)->value() >= 0;
}
int RegExpUtils::AdvanceStringIndex(Isolate* isolate, Handle<String> string,
« no previous file with comments | « src/builtins/builtins-string.cc ('k') | test/mjsunit/regress/regress-6210.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698