Index: src/runtime/runtime-regexp.cc |
diff --git a/src/runtime/runtime-regexp.cc b/src/runtime/runtime-regexp.cc |
index 826e1d5864949f4af6b4ebbbd53989e9cbe1c062..58c14bc182f7ddbe60cc0ab7b3e117401c251c3b 100644 |
--- a/src/runtime/runtime-regexp.cc |
+++ b/src/runtime/runtime-regexp.cc |
@@ -924,14 +924,26 @@ |
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, escaped_source, |
EscapeRegExpSource(isolate, source)); |
+ Handle<Object> global = factory->ToBoolean(flags.is_global()); |
+ 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->GetConstructor(); |
- if (constructor->IsJSFunction() && |
+ if (!FLAG_harmony_regexps && !FLAG_harmony_unicode_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, *escaped_source); |
- regexp->InObjectPropertyAtPut(JSRegExp::kFlagsFieldIndex, |
- Smi::FromInt(flags.value()), |
+ // Both true and false are immovable immortal objects so no need for write |
+ // barrier. |
+ regexp->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex, *global, |
+ SKIP_WRITE_BARRIER); |
+ regexp->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex, *ignore_case, |
+ SKIP_WRITE_BARRIER); |
+ regexp->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex, *multiline, |
SKIP_WRITE_BARRIER); |
regexp->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex, |
Smi::FromInt(0), SKIP_WRITE_BARRIER); |
@@ -946,13 +958,22 @@ |
PropertyAttributes writable = |
static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); |
Handle<Object> zero(Smi::FromInt(0), isolate); |
+ JSObject::SetOwnPropertyIgnoreAttributes(regexp, factory->source_string(), |
+ escaped_source, final).Check(); |
+ JSObject::SetOwnPropertyIgnoreAttributes(regexp, factory->global_string(), |
+ global, final).Check(); |
JSObject::SetOwnPropertyIgnoreAttributes( |
- regexp, factory->regexp_source_symbol(), escaped_source, final) |
- .Check(); |
+ regexp, factory->ignore_case_string(), ignore_case, final).Check(); |
JSObject::SetOwnPropertyIgnoreAttributes( |
- regexp, factory->regexp_flags_symbol(), |
- Handle<Smi>(Smi::FromInt(flags.value()), isolate), final) |
- .Check(); |
+ regexp, factory->multiline_string(), multiline, final).Check(); |
+ if (FLAG_harmony_regexps) { |
+ JSObject::SetOwnPropertyIgnoreAttributes(regexp, factory->sticky_string(), |
+ sticky, final).Check(); |
+ } |
+ if (FLAG_harmony_unicode_regexps) { |
+ JSObject::SetOwnPropertyIgnoreAttributes( |
+ regexp, factory->unicode_string(), unicode, final).Check(); |
+ } |
JSObject::SetOwnPropertyIgnoreAttributes( |
regexp, factory->last_index_string(), zero, writable).Check(); |
} |