Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: src/compiler/js-native-context-specialization.cc

Issue 2578563002: [turbofan] Cleaning up InlineApiCall in JSNativeContextReducer. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/compiler/js-native-context-specialization.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/js-native-context-specialization.h" 5 #include "src/compiler/js-native-context-specialization.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/compilation-dependencies.h" 9 #include "src/compilation-dependencies.h"
10 #include "src/compiler/access-builder.h" 10 #include "src/compiler/access-builder.h"
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after
1016 javascript()->CallFunction( 1016 javascript()->CallFunction(
1017 2, 0.0f, VectorSlotPair(), 1017 2, 0.0f, VectorSlotPair(),
1018 ConvertReceiverMode::kNotNullOrUndefined), 1018 ConvertReceiverMode::kNotNullOrUndefined),
1019 target, receiver, context, frame_state0, effect, control); 1019 target, receiver, context, frame_state0, effect, control);
1020 control = graph()->NewNode(common()->IfSuccess(), value); 1020 control = graph()->NewNode(common()->IfSuccess(), value);
1021 } else { 1021 } else {
1022 DCHECK(access_info.constant()->IsFunctionTemplateInfo()); 1022 DCHECK(access_info.constant()->IsFunctionTemplateInfo());
1023 Handle<FunctionTemplateInfo> function_template_info( 1023 Handle<FunctionTemplateInfo> function_template_info(
1024 Handle<FunctionTemplateInfo>::cast(access_info.constant())); 1024 Handle<FunctionTemplateInfo>::cast(access_info.constant()));
1025 DCHECK(!function_template_info->call_code()->IsUndefined(isolate())); 1025 DCHECK(!function_template_info->call_code()->IsUndefined(isolate()));
1026 ZoneVector<Node*> stack_parameters(graph()->zone());
1027 ValueEffectControl value_effect_control = InlineApiCall( 1026 ValueEffectControl value_effect_control = InlineApiCall(
1028 receiver, context, target, frame_state0, &stack_parameters, 1027 receiver, context, target, frame_state0, nullptr, effect, control,
1029 effect, control, shared_info, function_template_info); 1028 shared_info, function_template_info);
1030 value = value_effect_control.value(); 1029 value = value_effect_control.value();
1031 effect = value_effect_control.effect(); 1030 effect = value_effect_control.effect();
1032 control = value_effect_control.control(); 1031 control = value_effect_control.control();
1033 } 1032 }
1034 break; 1033 break;
1035 } 1034 }
1036 case AccessMode::kStore: { 1035 case AccessMode::kStore: {
1037 // We need a FrameState for the setter stub to restore the correct 1036 // We need a FrameState for the setter stub to restore the correct
1038 // context and return the appropriate value to fullcodegen. 1037 // context and return the appropriate value to fullcodegen.
1039 FrameStateFunctionInfo const* frame_info0 = 1038 FrameStateFunctionInfo const* frame_info0 =
(...skipping 13 matching lines...) Expand all
1053 javascript()->CallFunction( 1052 javascript()->CallFunction(
1054 3, 0.0f, VectorSlotPair(), 1053 3, 0.0f, VectorSlotPair(),
1055 ConvertReceiverMode::kNotNullOrUndefined), 1054 ConvertReceiverMode::kNotNullOrUndefined),
1056 target, receiver, value, context, frame_state0, effect, control); 1055 target, receiver, value, context, frame_state0, effect, control);
1057 control = graph()->NewNode(common()->IfSuccess(), effect); 1056 control = graph()->NewNode(common()->IfSuccess(), effect);
1058 } else { 1057 } else {
1059 DCHECK(access_info.constant()->IsFunctionTemplateInfo()); 1058 DCHECK(access_info.constant()->IsFunctionTemplateInfo());
1060 Handle<FunctionTemplateInfo> function_template_info( 1059 Handle<FunctionTemplateInfo> function_template_info(
1061 Handle<FunctionTemplateInfo>::cast(access_info.constant())); 1060 Handle<FunctionTemplateInfo>::cast(access_info.constant()));
1062 DCHECK(!function_template_info->call_code()->IsUndefined(isolate())); 1061 DCHECK(!function_template_info->call_code()->IsUndefined(isolate()));
1063 ZoneVector<Node*> stack_parameters(graph()->zone());
1064 stack_parameters.push_back(value);
1065 ValueEffectControl value_effect_control = InlineApiCall( 1062 ValueEffectControl value_effect_control = InlineApiCall(
1066 receiver, context, target, frame_state0, &stack_parameters, 1063 receiver, context, target, frame_state0, value, effect, control,
1067 effect, control, shared_info, function_template_info); 1064 shared_info, function_template_info);
1068 value = value_effect_control.value(); 1065 value = value_effect_control.value();
1069 effect = value_effect_control.effect(); 1066 effect = value_effect_control.effect();
1070 control = value_effect_control.control(); 1067 control = value_effect_control.control();
1071 } 1068 }
1072 break; 1069 break;
1073 } 1070 }
1074 } 1071 }
1075 } else if (access_info.IsDataField()) { 1072 } else if (access_info.IsDataField()) {
1076 FieldIndex const field_index = access_info.field_index(); 1073 FieldIndex const field_index = access_info.field_index();
1077 Type* const field_type = access_info.field_type(); 1074 Type* const field_type = access_info.field_type();
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
1556 effect = graph()->NewNode(simplified()->StoreElement(element_access), 1553 effect = graph()->NewNode(simplified()->StoreElement(element_access),
1557 elements, index, value, effect, control); 1554 elements, index, value, effect, control);
1558 } 1555 }
1559 } 1556 }
1560 1557
1561 return ValueEffectControl(value, effect, control); 1558 return ValueEffectControl(value, effect, control);
1562 } 1559 }
1563 1560
1564 JSNativeContextSpecialization::ValueEffectControl 1561 JSNativeContextSpecialization::ValueEffectControl
1565 JSNativeContextSpecialization::InlineApiCall( 1562 JSNativeContextSpecialization::InlineApiCall(
1566 Node* receiver, Node* context, Node* target, Node* frame_state, 1563 Node* receiver, Node* context, Node* target, Node* frame_state, Node* value,
1567 ZoneVector<Node*>* stack_parameters, Node* effect, Node* control, 1564 Node* effect, Node* control, Handle<SharedFunctionInfo> shared_info,
1568 Handle<SharedFunctionInfo> shared_info,
1569 Handle<FunctionTemplateInfo> function_template_info) { 1565 Handle<FunctionTemplateInfo> function_template_info) {
1570 Handle<CallHandlerInfo> call_handler_info = handle( 1566 Handle<CallHandlerInfo> call_handler_info = handle(
1571 CallHandlerInfo::cast(function_template_info->call_code()), isolate()); 1567 CallHandlerInfo::cast(function_template_info->call_code()), isolate());
1572 Handle<Object> call_data_object(call_handler_info->data(), isolate()); 1568 Handle<Object> call_data_object(call_handler_info->data(), isolate());
1573 1569
1570 // Only setters have a value.
1571 int const argc = value == nullptr ? 0 : 1;
1574 // The stub always expects the receiver as the first param on the stack. 1572 // The stub always expects the receiver as the first param on the stack.
1575 CallApiCallbackStub stub( 1573 CallApiCallbackStub stub(
1576 isolate(), static_cast<int>(stack_parameters->size()), 1574 isolate(), argc, call_data_object->IsUndefined(isolate()),
1577 call_data_object->IsUndefined(isolate()), 1575 true /* FunctionTemplateInfo doesn't have an associated context. */);
1578 true /* TODO(epertoso): similar to CallOptimization */);
1579 CallInterfaceDescriptor call_interface_descriptor = 1576 CallInterfaceDescriptor call_interface_descriptor =
1580 stub.GetCallInterfaceDescriptor(); 1577 stub.GetCallInterfaceDescriptor();
1581 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor( 1578 CallDescriptor* call_descriptor = Linkage::GetStubCallDescriptor(
1582 isolate(), graph()->zone(), call_interface_descriptor, 1579 isolate(), graph()->zone(), call_interface_descriptor,
1583 call_interface_descriptor.GetStackParameterCount() + 1580 call_interface_descriptor.GetStackParameterCount() + argc +
1584 static_cast<int>(stack_parameters->size()) + 1, 1581 1 /* implicit receiver */,
1585 CallDescriptor::kNeedsFrameState, Operator::kNoProperties, 1582 CallDescriptor::kNeedsFrameState, Operator::kNoProperties,
1586 MachineType::AnyTagged(), 1); 1583 MachineType::AnyTagged(), 1);
1587 1584
1588 Node* data = jsgraph()->Constant(call_data_object); 1585 Node* data = jsgraph()->Constant(call_data_object);
1589 ApiFunction function(v8::ToCData<Address>(call_handler_info->callback())); 1586 ApiFunction function(v8::ToCData<Address>(call_handler_info->callback()));
1590 Node* function_reference = 1587 Node* function_reference =
1591 graph()->NewNode(common()->ExternalConstant(ExternalReference( 1588 graph()->NewNode(common()->ExternalConstant(ExternalReference(
1592 &function, ExternalReference::DIRECT_API_CALL, isolate()))); 1589 &function, ExternalReference::DIRECT_API_CALL, isolate())));
1593 Node* code = jsgraph()->HeapConstant(stub.GetCode()); 1590 Node* code = jsgraph()->HeapConstant(stub.GetCode());
1594 1591
1595 ZoneVector<Node*> inputs(zone()); 1592 // Add CallApiCallbackStub's register argument as well.
1596 inputs.push_back(code); 1593 Node* inputs[11] = {
1597 1594 code, target, data, receiver /* holder */, function_reference, receiver};
1598 // CallApiCallbackStub's register arguments. 1595 if (value != nullptr) {
1599 inputs.push_back(target); 1596 inputs[6] = value;
1600 inputs.push_back(data);
1601 inputs.push_back(receiver);
1602 inputs.push_back(function_reference);
1603
1604 // Stack parameters: CallApiCallbackStub expects the first one to be the
1605 // receiver.
1606 inputs.push_back(receiver);
1607 for (Node* node : *stack_parameters) {
1608 inputs.push_back(node);
1609 } 1597 }
1610 inputs.push_back(context); 1598 int index = 6 + argc;
1611 inputs.push_back(frame_state); 1599 inputs[index++] = context;
1612 inputs.push_back(effect); 1600 inputs[index++] = frame_state;
1613 inputs.push_back(control); 1601 inputs[index++] = effect;
1602 inputs[index++] = control;
1614 1603
1615 Node* effect0; 1604 Node* effect0;
1616 Node* value0 = effect0 = 1605 Node* value0 = effect0 =
1617 graph()->NewNode(common()->Call(call_descriptor), 1606 graph()->NewNode(common()->Call(call_descriptor), index, inputs);
1618 static_cast<int>(inputs.size()), inputs.data());
1619 Node* control0 = graph()->NewNode(common()->IfSuccess(), value0); 1607 Node* control0 = graph()->NewNode(common()->IfSuccess(), value0);
1620 return ValueEffectControl(value0, effect0, control0); 1608 return ValueEffectControl(value0, effect0, control0);
1621 } 1609 }
1622 1610
1623 Node* JSNativeContextSpecialization::BuildCheckHeapObject(Node* receiver, 1611 Node* JSNativeContextSpecialization::BuildCheckHeapObject(Node* receiver,
1624 Node** effect, 1612 Node** effect,
1625 Node* control) { 1613 Node* control) {
1626 switch (receiver->opcode()) { 1614 switch (receiver->opcode()) {
1627 case IrOpcode::kHeapConstant: 1615 case IrOpcode::kHeapConstant:
1628 case IrOpcode::kJSCreate: 1616 case IrOpcode::kJSCreate:
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1832 return jsgraph()->javascript(); 1820 return jsgraph()->javascript();
1833 } 1821 }
1834 1822
1835 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { 1823 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const {
1836 return jsgraph()->simplified(); 1824 return jsgraph()->simplified();
1837 } 1825 }
1838 1826
1839 } // namespace compiler 1827 } // namespace compiler
1840 } // namespace internal 1828 } // namespace internal
1841 } // namespace v8 1829 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-native-context-specialization.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698