| Index: src/hydrogen.cc
|
| diff --git a/src/hydrogen.cc b/src/hydrogen.cc
|
| index a6843115bb27104727e5a926999433b295e0be01..5c927371db00e113b7517713cfbff486076b4da6 100644
|
| --- a/src/hydrogen.cc
|
| +++ b/src/hydrogen.cc
|
| @@ -8698,7 +8698,7 @@ bool HOptimizedGraphBuilder::TryInlineApiCall(Handle<JSFunction> function,
|
| PrintF("\n");
|
| }
|
|
|
| - bool drop_extra = false;
|
| + bool is_function = false;
|
| bool is_store = false;
|
| switch (call_type) {
|
| case kCallApiFunction:
|
| @@ -8713,8 +8713,7 @@ bool HOptimizedGraphBuilder::TryInlineApiCall(Handle<JSFunction> function,
|
| }
|
| // Includes receiver.
|
| PushArgumentsFromEnvironment(argc + 1);
|
| - // Drop function after call.
|
| - drop_extra = true;
|
| + is_function = true;
|
| break;
|
| case kCallApiGetter:
|
| // Receiver and prototype chain cannot have changed.
|
| @@ -8752,34 +8751,40 @@ bool HOptimizedGraphBuilder::TryInlineApiCall(Handle<JSFunction> function,
|
| }
|
| Handle<CallHandlerInfo> api_call_info = optimization.api_call_info();
|
| Handle<Object> call_data_obj(api_call_info->data(), isolate());
|
| - bool call_data_is_undefined = call_data_obj->IsUndefined();
|
| HValue* call_data = Add<HConstant>(call_data_obj);
|
| + bool call_data_undefined = call_data_obj->IsUndefined();
|
| ApiFunction fun(v8::ToCData<Address>(api_call_info->callback()));
|
| ExternalReference ref = ExternalReference(&fun,
|
| ExternalReference::DIRECT_API_CALL,
|
| isolate());
|
| HValue* api_function_address = Add<HConstant>(ExternalReference(ref));
|
|
|
| - HValue* op_vals[] = {
|
| - context(),
|
| - Add<HConstant>(function),
|
| - call_data,
|
| - holder,
|
| - api_function_address
|
| - };
|
| -
|
| - ApiFunctionDescriptor descriptor(isolate());
|
| - CallApiFunctionStub stub(isolate(), is_store, call_data_is_undefined, argc);
|
| - Handle<Code> code = stub.GetCode();
|
| - HConstant* code_value = Add<HConstant>(code);
|
| -
|
| - DCHECK((sizeof(op_vals) / kPointerSize) == descriptor.GetEnvironmentLength());
|
| -
|
| - HInstruction* call = New<HCallWithDescriptor>(
|
| - code_value, argc + 1, descriptor,
|
| - Vector<HValue*>(op_vals, descriptor.GetEnvironmentLength()));
|
| + HValue* op_vals[] = {context(), Add<HConstant>(function), call_data, holder,
|
| + api_function_address, nullptr};
|
| +
|
| + HInstruction* call = nullptr;
|
| + if (!is_function) {
|
| + CallApiAccessorStub stub(isolate(), is_store, call_data_undefined);
|
| + Handle<Code> code = stub.GetCode();
|
| + HConstant* code_value = Add<HConstant>(code);
|
| + ApiAccessorDescriptor descriptor(isolate());
|
| + DCHECK(arraysize(op_vals) - 1 == descriptor.GetEnvironmentLength());
|
| + call = New<HCallWithDescriptor>(
|
| + code_value, argc + 1, descriptor,
|
| + Vector<HValue*>(op_vals, descriptor.GetEnvironmentLength()));
|
| + } else {
|
| + op_vals[arraysize(op_vals) - 1] = Add<HConstant>(argc);
|
| + CallApiFunctionStub stub(isolate(), call_data_undefined);
|
| + Handle<Code> code = stub.GetCode();
|
| + HConstant* code_value = Add<HConstant>(code);
|
| + ApiFunctionDescriptor descriptor(isolate());
|
| + DCHECK(arraysize(op_vals) == descriptor.GetEnvironmentLength());
|
| + call = New<HCallWithDescriptor>(
|
| + code_value, argc + 1, descriptor,
|
| + Vector<HValue*>(op_vals, descriptor.GetEnvironmentLength()));
|
| + Drop(1); // Drop function.
|
| + }
|
|
|
| - if (drop_extra) Drop(1); // Drop function.
|
| ast_context()->ReturnInstruction(call, ast_id);
|
| return true;
|
| }
|
|
|