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

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

Issue 788043005: ES6 unicode escapes, part 2: Regexps. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: mirror regexp test Created 5 years, 11 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/runtime-regexp.cc
diff --git a/src/runtime/runtime-regexp.cc b/src/runtime/runtime-regexp.cc
index be9adfff41e5ac6794a7f704ede272ba88506f58..e2cf2028d9da87fc66af6efb856e83fc865fef85 100644
--- a/src/runtime/runtime-regexp.cc
+++ b/src/runtime/runtime-regexp.cc
@@ -805,7 +805,7 @@ static JSRegExp::Flags RegExpFlagsFromString(Handle<String> flags,
uint32_t value = JSRegExp::NONE;
int length = flags->length();
// A longer flags string cannot be valid.
- if (length > 4) return JSRegExp::Flags(0);
+ if (length > 5) return JSRegExp::Flags(0);
for (int i = 0; i < length; i++) {
uint32_t flag = JSRegExp::NONE;
switch (flags->Get(i)) {
@@ -818,6 +818,10 @@ static JSRegExp::Flags RegExpFlagsFromString(Handle<String> flags,
case 'm':
flag = JSRegExp::MULTILINE;
break;
+ case 'u':
+ if (!FLAG_harmony_unicode) return JSRegExp::Flags(0);
+ flag = JSRegExp::UNICODE_ESCAPES;
+ break;
case 'y':
if (!FLAG_harmony_regexps) return JSRegExp::Flags(0);
flag = JSRegExp::STICKY;
@@ -859,10 +863,12 @@ RUNTIME_FUNCTION(Runtime_RegExpInitializeAndCompile) {
Handle<Object> ignore_case = factory->ToBoolean(flags.is_ignore_case());
Handle<Object> multiline = factory->ToBoolean(flags.is_multiline());
Handle<Object> sticky = factory->ToBoolean(flags.is_sticky());
+ Handle<Object> unicode = factory->ToBoolean(flags.is_unicode());
Map* map = regexp->map();
Object* constructor = map->constructor();
- if (!FLAG_harmony_regexps && constructor->IsJSFunction() &&
+ if (!FLAG_harmony_regexps && !FLAG_harmony_unicode &&
+ constructor->IsJSFunction() &&
JSFunction::cast(constructor)->initial_map() == map) {
// If we still have the original map, set in-object properties directly.
// Both true and false are immovable immortal objects so no need for write
@@ -896,6 +902,10 @@ RUNTIME_FUNCTION(Runtime_RegExpInitializeAndCompile) {
JSObject::SetOwnPropertyIgnoreAttributes(regexp, factory->sticky_string(),
sticky, final).Check();
}
+ if (FLAG_harmony_unicode) {
+ JSObject::SetOwnPropertyIgnoreAttributes(
+ regexp, factory->unicode_string(), unicode, final).Check();
+ }
JSObject::SetOwnPropertyIgnoreAttributes(
regexp, factory->last_index_string(), zero, writable).Check();
}

Powered by Google App Engine
This is Rietveld 408576698