Chromium Code Reviews| Index: src/runtime.cc |
| diff --git a/src/runtime.cc b/src/runtime.cc |
| index 4994378cd3a770e55a199a4582a2eeb35e81b470..97a5fc3cd7574e77c4493cdae5c43e0226418980 100644 |
| --- a/src/runtime.cc |
| +++ b/src/runtime.cc |
| @@ -6685,21 +6685,37 @@ static MaybeObject* Runtime_NewObjectFromBound(Arguments args) { |
| HandleScope scope; |
| ASSERT(args.length() == 2); |
| CONVERT_ARG_CHECKED(JSFunction, function, 0); |
| - CONVERT_ARG_CHECKED(JSArray, params, 1); |
| - RUNTIME_ASSERT(params->HasFastElements()); |
| - FixedArray* fixed = FixedArray::cast(params->elements()); |
| + FixedArray* bound_args = NULL; |
| + int bound_argc = 0; |
| + if (!args[1]->IsNull()) { |
| + CONVERT_ARG_CHECKED(JSArray, params, 1); |
| + RUNTIME_ASSERT(params->HasFastElements()); |
| + bound_args = FixedArray::cast(params->elements()); |
| + bound_argc = Smi::cast(params->length())->value(); |
| + } |
| + |
| + JavaScriptFrameIterator it; |
| + JavaScriptFrame* frame = it.frame(); |
| + ASSERT(!frame->is_optimized()); |
| + it.AdvanceToArgumentsFrame(); |
| + frame = it.frame(); |
| + int argc = frame->GetProvidedParametersCount(); |
| - int fixed_length = Smi::cast(params->length())->value(); |
| - SmartPointer<Object**> param_data(NewArray<Object**>(fixed_length)); |
| - for (int i = 0; i < fixed_length; i++) { |
| - Handle<Object> val = Handle<Object>(fixed->get(i)); |
| + int total_argc = bound_argc + argc; |
| + SmartPointer<Object**> param_data(NewArray<Object**>(total_argc)); |
| + for (int i = 0; i < bound_argc; i++) { |
| + Handle<Object> val = Handle<Object>(bound_args->get(i)); |
| param_data[i] = val.location(); |
| } |
| + for (int i = 0; i < argc; i++) { |
| + Handle<Object> val = Handle<Object>(frame->GetParameter(i)); |
| + param_data[bound_argc + i] = val.location(); |
| + } |
| bool exception = false; |
| Handle<Object> result = Execution::New( |
|
Mads Ager (chromium)
2011/02/08 07:09:44
Move "Execution::New(" to the next line as well?
|
| - function, fixed_length, *param_data, &exception); |
| + function, total_argc, *param_data, &exception); |
| if (exception) { |
| return Failure::Exception(); |
| } |