Commit e521757f authored by epertoso's avatar epertoso Committed by Commit bot

[turbofan] Cleaning up InlineApiCall in JSNativeContextReducer.

R=jarin@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2578563002
Cr-Commit-Position: refs/heads/master@{#41697}
parent d40195e4
...@@ -1023,10 +1023,9 @@ JSNativeContextSpecialization::BuildPropertyAccess( ...@@ -1023,10 +1023,9 @@ JSNativeContextSpecialization::BuildPropertyAccess(
Handle<FunctionTemplateInfo> function_template_info( Handle<FunctionTemplateInfo> function_template_info(
Handle<FunctionTemplateInfo>::cast(access_info.constant())); Handle<FunctionTemplateInfo>::cast(access_info.constant()));
DCHECK(!function_template_info->call_code()->IsUndefined(isolate())); DCHECK(!function_template_info->call_code()->IsUndefined(isolate()));
ZoneVector<Node*> stack_parameters(graph()->zone());
ValueEffectControl value_effect_control = InlineApiCall( ValueEffectControl value_effect_control = InlineApiCall(
receiver, context, target, frame_state0, &stack_parameters, receiver, context, target, frame_state0, nullptr, effect, control,
effect, control, shared_info, function_template_info); shared_info, function_template_info);
value = value_effect_control.value(); value = value_effect_control.value();
effect = value_effect_control.effect(); effect = value_effect_control.effect();
control = value_effect_control.control(); control = value_effect_control.control();
...@@ -1060,11 +1059,9 @@ JSNativeContextSpecialization::BuildPropertyAccess( ...@@ -1060,11 +1059,9 @@ JSNativeContextSpecialization::BuildPropertyAccess(
Handle<FunctionTemplateInfo> function_template_info( Handle<FunctionTemplateInfo> function_template_info(
Handle<FunctionTemplateInfo>::cast(access_info.constant())); Handle<FunctionTemplateInfo>::cast(access_info.constant()));
DCHECK(!function_template_info->call_code()->IsUndefined(isolate())); DCHECK(!function_template_info->call_code()->IsUndefined(isolate()));
ZoneVector<Node*> stack_parameters(graph()->zone());
stack_parameters.push_back(value);
ValueEffectControl value_effect_control = InlineApiCall( ValueEffectControl value_effect_control = InlineApiCall(
receiver, context, target, frame_state0, &stack_parameters, receiver, context, target, frame_state0, value, effect, control,
effect, control, shared_info, function_template_info); shared_info, function_template_info);
value = value_effect_control.value(); value = value_effect_control.value();
effect = value_effect_control.effect(); effect = value_effect_control.effect();
control = value_effect_control.control(); control = value_effect_control.control();
...@@ -1563,25 +1560,25 @@ JSNativeContextSpecialization::BuildElementAccess( ...@@ -1563,25 +1560,25 @@ JSNativeContextSpecialization::BuildElementAccess(
JSNativeContextSpecialization::ValueEffectControl JSNativeContextSpecialization::ValueEffectControl
JSNativeContextSpecialization::InlineApiCall( JSNativeContextSpecialization::InlineApiCall(
Node* receiver, Node* context, Node* target, Node* frame_state, Node* receiver, Node* context, Node* target, Node* frame_state, Node* value,
ZoneVector<Node*>* stack_parameters, Node* effect, Node* control, Node* effect, Node* control, Handle<SharedFunctionInfo> shared_info,
Handle<SharedFunctionInfo> shared_info,
Handle<FunctionTemplateInfo> function_template_info) { Handle<FunctionTemplateInfo> function_template_info) {
Handle<CallHandlerInfo> call_handler_info = handle( Handle<CallHandlerInfo> call_handler_info = handle(
CallHandlerInfo::cast(function_template_info->call_code()), isolate()); CallHandlerInfo::cast(function_template_info->call_code()), isolate());
Handle<Object> call_data_object(call_handler_info->data(), isolate()); Handle<Object> call_data_object(call_handler_info->data(), isolate());
// Only setters have a value.
int const argc = value == nullptr ? 0 : 1;
// The stub always expects the receiver as the first param on the stack. // The stub always expects the receiver as the first param on the stack.
CallApiCallbackStub stub( CallApiCallbackStub stub(
isolate(), static_cast<int>(stack_parameters->size()), isolate(), argc, call_data_object->IsUndefined(isolate()),
call_data_object->IsUndefined(isolate()), true /* FunctionTemplateInfo doesn't have an associated context. */);
true /* TODO(epertoso): similar to CallOptimization */);
CallInterfaceDescriptor call_interface_descriptor = CallInterfaceDescriptor call_interface_descriptor =
stub.GetCallInterfaceDescriptor(); stub.GetCallInterfaceDescriptor();
CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor( CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
isolate(), graph()->zone(), call_interface_descriptor, isolate(), graph()->zone(), call_interface_descriptor,
call_interface_descriptor.GetStackParameterCount() + call_interface_descriptor.GetStackParameterCount() + argc +
static_cast<int>(stack_parameters->size()) + 1, 1 /* implicit receiver */,
CallDescriptor::kNeedsFrameState, Operator::kNoProperties, CallDescriptor::kNeedsFrameState, Operator::kNoProperties,
MachineType::AnyTagged(), 1); MachineType::AnyTagged(), 1);
...@@ -1592,30 +1589,21 @@ JSNativeContextSpecialization::InlineApiCall( ...@@ -1592,30 +1589,21 @@ JSNativeContextSpecialization::InlineApiCall(
&function, ExternalReference::DIRECT_API_CALL, isolate()))); &function, ExternalReference::DIRECT_API_CALL, isolate())));
Node* code = jsgraph()->HeapConstant(stub.GetCode()); Node* code = jsgraph()->HeapConstant(stub.GetCode());
ZoneVector<Node*> inputs(zone()); // Add CallApiCallbackStub's register argument as well.
inputs.push_back(code); Node* inputs[11] = {
code, target, data, receiver /* holder */, function_reference, receiver};
// CallApiCallbackStub's register arguments. if (value != nullptr) {
inputs.push_back(target); inputs[6] = value;
inputs.push_back(data);
inputs.push_back(receiver);
inputs.push_back(function_reference);
// Stack parameters: CallApiCallbackStub expects the first one to be the
// receiver.
inputs.push_back(receiver);
for (Node* node : *stack_parameters) {
inputs.push_back(node);
} }
inputs.push_back(context); int index = 6 + argc;
inputs.push_back(frame_state); inputs[index++] = context;
inputs.push_back(effect); inputs[index++] = frame_state;
inputs.push_back(control); inputs[index++] = effect;
inputs[index++] = control;
Node* effect0; Node* effect0;
Node* value0 = effect0 = Node* value0 = effect0 =
graph()->NewNode(common()->Call(call_descriptor), graph()->NewNode(common()->Call(call_descriptor), index, inputs);
static_cast<int>(inputs.size()), inputs.data());
Node* control0 = graph()->NewNode(common()->IfSuccess(), value0); Node* control0 = graph()->NewNode(common()->IfSuccess(), value0);
return ValueEffectControl(value0, effect0, control0); return ValueEffectControl(value0, effect0, control0);
} }
......
...@@ -150,7 +150,7 @@ class JSNativeContextSpecialization final : public AdvancedReducer { ...@@ -150,7 +150,7 @@ class JSNativeContextSpecialization final : public AdvancedReducer {
ValueEffectControl InlineApiCall( ValueEffectControl InlineApiCall(
Node* receiver, Node* context, Node* target, Node* frame_state, Node* receiver, Node* context, Node* target, Node* frame_state,
ZoneVector<Node*>* stack_parameters, Node* effect, Node* control, Node* parameter, Node* effect, Node* control,
Handle<SharedFunctionInfo> shared_info, Handle<SharedFunctionInfo> shared_info,
Handle<FunctionTemplateInfo> function_template_info); Handle<FunctionTemplateInfo> function_template_info);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment