Chromium Code Reviews| Index: src/runtime.cc |
| diff --git a/src/runtime.cc b/src/runtime.cc |
| index c77d518371c9401852f51be7a395ab442068e5a2..7d104fa3b4123eff2aedbed7af388e454f1458ac 100644 |
| --- a/src/runtime.cc |
| +++ b/src/runtime.cc |
| @@ -1228,6 +1228,62 @@ static Object* Runtime_RegExpExec(Arguments args) { |
| } |
| +static Object* Runtime_RegExpInitializeObject(Arguments args) { |
| + AssertNoAllocation no_alloc; |
| + ASSERT(args.length() == 5); |
| + CONVERT_CHECKED(JSRegExp, regexp, args[0]); |
| + CONVERT_CHECKED(String, source, args[1]); |
| + |
| + Object* global = args[2]; |
| + if (!global->IsTrue()) global = Heap::false_value(); |
| + |
| + Object* ignoreCase = args[3]; |
| + if (!ignoreCase->IsTrue()) ignoreCase = Heap::false_value(); |
| + |
| + Object* multiline = args[4]; |
| + if (!multiline->IsTrue()) multiline = Heap::false_value(); |
| + |
| + Map* map = regexp->map(); |
| + Object* constructor = map->constructor(); |
| + if (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); |
| + // TODO(lrn): Consider skipping write barrier on booleans as well. |
| + // Both true and false should be in oldspace at all times. |
| + regexp->InObjectPropertyAtPut(JSRegExp::kGlobalFieldIndex, global); |
| + regexp->InObjectPropertyAtPut(JSRegExp::kIgnoreCaseFieldIndex, ignoreCase); |
| + regexp->InObjectPropertyAtPut(JSRegExp::kMultilineFieldIndex, multiline); |
| + regexp->InObjectPropertyAtPut(JSRegExp::kLastIndexFieldIndex, |
| + Smi::FromInt(0), |
| + SKIP_WRITE_BARRIER); |
| + return regexp; |
| + } |
| + |
| + // Map has changed, so use generic, but slower, method. |
|
Erik Corry
2010/03/26 13:51:34
This is a strange situation. Do we have a test of
Lasse Reichstein
2010/03/26 14:19:09
I guess the only way this can happen is when using
|
| + PropertyAttributes final = |
| + static_cast<PropertyAttributes>(READ_ONLY | DONT_ENUM | DONT_DELETE); |
| + PropertyAttributes writable = |
| + static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE); |
| + regexp->IgnoreAttributesAndSetLocalProperty(Heap::source_symbol(), |
| + source, |
| + final); |
| + regexp->IgnoreAttributesAndSetLocalProperty(Heap::global_symbol(), |
| + global, |
| + final); |
| + regexp->IgnoreAttributesAndSetLocalProperty(Heap::ignore_case_symbol(), |
| + ignoreCase, |
| + final); |
| + regexp->IgnoreAttributesAndSetLocalProperty(Heap::multiline_symbol(), |
| + multiline, |
| + final); |
| + regexp->IgnoreAttributesAndSetLocalProperty(Heap::last_index_symbol(), |
| + Smi::FromInt(0), |
| + writable); |
| + return regexp; |
| +} |
| + |
| + |
| static Object* Runtime_FinishArrayPrototypeSetup(Arguments args) { |
| HandleScope scope; |
| ASSERT(args.length() == 1); |