Chromium Code Reviews| Index: src/runtime.cc |
| diff --git a/src/runtime.cc b/src/runtime.cc |
| index e176951a7da6ab0d326120340ea1472361938696..2b9731227f5f7479fa889ea41b371758bf7843a9 100644 |
| --- a/src/runtime.cc |
| +++ b/src/runtime.cc |
| @@ -2601,38 +2601,23 @@ RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_RegExpExec) { |
| RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_RegExpConstructResult) { |
| - SealHandleScope shs(isolate); |
| + HandleScope handle_scope(isolate); |
| ASSERT(args.length() == 3); |
| - CONVERT_SMI_ARG_CHECKED(elements_count, 0); |
| - if (elements_count < 0 || |
| - elements_count > FixedArray::kMaxLength || |
| - !Smi::IsValid(elements_count)) { |
| - return isolate->ThrowIllegalOperation(); |
| - } |
| - Object* new_object; |
| - { MaybeObject* maybe_new_object = |
| - isolate->heap()->AllocateFixedArray(elements_count); |
| - if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; |
| - } |
| - FixedArray* elements = FixedArray::cast(new_object); |
| - { MaybeObject* maybe_new_object = isolate->heap()->AllocateRaw( |
| - JSRegExpResult::kSize, NEW_SPACE, OLD_POINTER_SPACE); |
| - if (!maybe_new_object->ToObject(&new_object)) return maybe_new_object; |
| - } |
| - { |
| - DisallowHeapAllocation no_gc; |
| - HandleScope scope(isolate); |
| - reinterpret_cast<HeapObject*>(new_object)-> |
| - set_map(isolate->native_context()->regexp_result_map()); |
| - } |
| - JSArray* array = JSArray::cast(new_object); |
| - array->set_properties(isolate->heap()->empty_fixed_array()); |
| - array->set_elements(elements); |
| - array->set_length(Smi::FromInt(elements_count)); |
| + CONVERT_SMI_ARG_CHECKED(size, 0); |
| + RUNTIME_ASSERT(size >= 0 && size <= FixedArray::kMaxLength); |
|
mvstanton
2014/04/07 14:28:49
So you don't bother with !Smi::IsValid(size) becau
Yang
2014/04/07 14:47:01
Yes.
|
| + RUNTIME_ASSERT(args[1]->IsSmi()); |
| + RUNTIME_ASSERT(args[2]->IsSmi()); |
|
mvstanton
2014/04/07 14:28:49
Do args[1] and args[2] actually need to be smis?
Yang
2014/04/07 14:47:01
You are right. They actually are not necessarily s
|
| + Handle<FixedArray> elements = isolate->factory()->NewFixedArray(size); |
| + Handle<Map> regexp_map(isolate->native_context()->regexp_result_map()); |
| + Handle<JSObject> object = |
| + isolate->factory()->NewJSObjectFromMap(regexp_map, NOT_TENURED, false); |
| + Handle<JSArray> array = Handle<JSArray>::cast(object); |
| + array->set_elements(*elements); |
| + array->set_length(Smi::FromInt(size)); |
| // Write in-object properties after the length of the array. |
| array->InObjectPropertyAtPut(JSRegExpResult::kIndexIndex, args[1]); |
| array->InObjectPropertyAtPut(JSRegExpResult::kInputIndex, args[2]); |
| - return array; |
| + return *array; |
| } |