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

Unified Diff: src/runtime.cc

Issue 567313003: RegExp: Add support for the ES6-proposed sticky flag (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add tests Created 6 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
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 20f311089b7c8ddc59e0276828b03fa3ea64454c..9af42094241864ee0e4be61493fac15bb4bb7b3f 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -1260,6 +1260,14 @@ RUNTIME_FUNCTION(Runtime_TypedArrayMaxSizeInHeap) {
}
+RUNTIME_FUNCTION(Runtime_HarmonyRegExps) {
+ DCHECK(args.length() == 0);
+ if (FLAG_harmony_regexps)
Yang 2014/09/15 09:23:16 You could also use isolate->heap()->ToBoolean(FLAG
Erik Corry 2014/09/16 17:49:40 This is gone now.
+ return isolate->heap()->true_value();
+ return isolate->heap()->false_value();
+}
+
+
RUNTIME_FUNCTION(Runtime_DataViewInitialize) {
HandleScope scope(isolate);
DCHECK(args.length() == 4);
@@ -2548,7 +2556,7 @@ RUNTIME_FUNCTION(Runtime_RegExpConstructResult) {
RUNTIME_FUNCTION(Runtime_RegExpInitializeObject) {
HandleScope scope(isolate);
- DCHECK(args.length() == 5);
+ DCHECK(args.length() == 6);
CONVERT_ARG_HANDLE_CHECKED(JSRegExp, regexp, 0);
CONVERT_ARG_HANDLE_CHECKED(String, source, 1);
// If source is the empty string we set it to "(?:)" instead as
@@ -2564,9 +2572,13 @@ RUNTIME_FUNCTION(Runtime_RegExpInitializeObject) {
CONVERT_ARG_HANDLE_CHECKED(Object, multiline, 4);
if (!multiline->IsTrue()) multiline = isolate->factory()->false_value();
+ CONVERT_ARG_HANDLE_CHECKED(Object, sticky, 5);
+ if (!sticky->IsTrue()) sticky = isolate->factory()->false_value();
+
Map* map = regexp->map();
Object* constructor = map->constructor();
- if (constructor->IsJSFunction() &&
+ if (!FLAG_harmony_regexps &&
+ constructor->IsJSFunction() &&
JSFunction::cast(constructor)->initial_map() == map) {
// If we still have the original map, set in-object properties directly.
regexp->InObjectPropertyAtPut(JSRegExp::kSourceFieldIndex, *source);
@@ -2583,7 +2595,11 @@ RUNTIME_FUNCTION(Runtime_RegExpInitializeObject) {
return *regexp;
}
- // Map has changed, so use generic, but slower, method.
+ // Map has changed, so use generic, but slower, method. We also end here if
+ // the --harmony-regexp flag is set, because the initial map does not have
+ // space for the 'sticky' flag, since is from the snapshot, but must work both
mathias 2014/09/15 15:19:10 Typo: “since is”
Erik Corry 2014/09/16 17:49:40 Done.
+ // with and without --harmony-regexp. When sticky comes out from under the
+ // flag, we will be able to use the fast initial map.
PropertyAttributes final =
static_cast<PropertyAttributes>(READ_ONLY | DONT_ENUM | DONT_DELETE);
PropertyAttributes writable =
@@ -2599,6 +2615,8 @@ RUNTIME_FUNCTION(Runtime_RegExpInitializeObject) {
JSObject::SetOwnPropertyIgnoreAttributes(
regexp, factory->multiline_string(), multiline, final).Check();
JSObject::SetOwnPropertyIgnoreAttributes(
+ regexp, factory->sticky_string(), sticky, final).Check();
+ JSObject::SetOwnPropertyIgnoreAttributes(
regexp, factory->last_index_string(), zero, writable).Check();
return *regexp;
}

Powered by Google App Engine
This is Rietveld 408576698