Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index dc0e9c86065d3631f864371a08927d17ca377ac3..9166b6785beb61c389f222dd1352628bae0f553b 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -1228,6 +1228,36 @@ static Object* Runtime_RegExpExec(Arguments args) { |
} |
+static Object* Runtime_RegExpConstructResult(Arguments args) { |
+ ASSERT(args.length() == 3); |
+ CONVERT_SMI_CHECKED(elements_count, args[0]); |
+ if (elements_count > JSArray::kMaxFastElementsLength) { |
+ return Top::ThrowIllegalOperation(); |
+ } |
+ Object* new_object = Heap::AllocateFixedArrayWithHoles(elements_count); |
+ if (new_object->IsFailure()) return new_object; |
+ FixedArray* elements = FixedArray::cast(new_object); |
+ new_object = Heap::AllocateRaw(JSArray::kRegExpResultSize, |
+ NEW_SPACE, |
+ OLD_POINTER_SPACE); |
+ if (new_object->IsFailure()) return new_object; |
+ { |
+ AssertNoAllocation no_gc; |
+ HandleScope scope; |
+ reinterpret_cast<HeapObject*>(new_object)-> |
+ set_map(Top::global_context()->regexp_result_map()); |
+ } |
+ JSArray* array = JSArray::cast(new_object); |
+ array->set_properties(Heap::empty_fixed_array()); |
+ array->set_elements(elements); |
+ array->set_length(Smi::FromInt(elements_count)); |
+ // Write in-object properties after the length of the array. |
Søren Thygesen Gjesse
2010/04/13 07:22:29
Move the constants to JSRegExpResult (see comment
Lasse Reichstein
2010/04/13 09:50:56
Done.
|
+ array->InObjectPropertyAtPut(JSArray::kIndexIndex, args[1]); |
+ array->InObjectPropertyAtPut(JSArray::kInputIndex, args[2]); |
+ return array; |
+} |
+ |
+ |
static Object* Runtime_RegExpInitializeObject(Arguments args) { |
AssertNoAllocation no_alloc; |
ASSERT(args.length() == 5); |