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

Side by Side Diff: src/compiler/instruction-selector.cc

Issue 1411093006: [turbofan] Factor out platform-independent part of InstructionSelector::VisitCall. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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/instruction-selector.h ('k') | src/compiler/mips/instruction-selector-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/instruction-selector.h" 5 #include "src/compiler/instruction-selector.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/adapters.h" 9 #include "src/base/adapters.h"
10 #include "src/compiler/instruction-selector-impl.h" 10 #include "src/compiler/instruction-selector-impl.h"
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after
1004 1004
1005 1005
1006 void InstructionSelector::VisitConstant(Node* node) { 1006 void InstructionSelector::VisitConstant(Node* node) {
1007 // We must emit a NOP here because every live range needs a defining 1007 // We must emit a NOP here because every live range needs a defining
1008 // instruction in the register allocator. 1008 // instruction in the register allocator.
1009 OperandGenerator g(this); 1009 OperandGenerator g(this);
1010 Emit(kArchNop, g.DefineAsConstant(node)); 1010 Emit(kArchNop, g.DefineAsConstant(node));
1011 } 1011 }
1012 1012
1013 1013
1014 void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) {
1015 OperandGenerator g(this);
1016 const CallDescriptor* descriptor = OpParameter<const CallDescriptor*>(node);
1017
1018 FrameStateDescriptor* frame_state_descriptor = nullptr;
1019 if (descriptor->NeedsFrameState()) {
1020 frame_state_descriptor = GetFrameStateDescriptor(
1021 node->InputAt(static_cast<int>(descriptor->InputCount())));
1022 }
1023
1024 CallBuffer buffer(zone(), descriptor, frame_state_descriptor);
1025
1026 // Compute InstructionOperands for inputs and outputs.
1027 // TODO(turbofan): on some architectures it's probably better to use
1028 // the code object in a register if there are multiple uses of it.
1029 // Improve constant pool and the heuristics in the register allocator
1030 // for where to emit constants.
1031 InitializeCallBuffer(node, &buffer, true, true);
1032
1033 EmitPrepareArguments(&(buffer.pushed_nodes), descriptor, node);
1034
1035 // Pass label of exception handler block.
1036 CallDescriptor::Flags flags = descriptor->flags();
1037 if (handler) {
1038 DCHECK_EQ(IrOpcode::kIfException, handler->front()->opcode());
1039 IfExceptionHint hint = OpParameter<IfExceptionHint>(handler->front());
1040 if (hint == IfExceptionHint::kLocallyCaught) {
1041 flags |= CallDescriptor::kHasLocalCatchHandler;
1042 }
1043 flags |= CallDescriptor::kHasExceptionHandler;
1044 buffer.instruction_args.push_back(g.Label(handler));
1045 }
1046
1047 // Select the appropriate opcode based on the call type.
1048 InstructionCode opcode = kArchNop;
1049 switch (descriptor->kind()) {
1050 case CallDescriptor::kCallAddress:
1051 opcode =
1052 kArchCallCFunction |
1053 MiscField::encode(static_cast<int>(descriptor->CParameterCount()));
1054 break;
1055 case CallDescriptor::kCallCodeObject:
1056 opcode = kArchCallCodeObject | MiscField::encode(flags);
1057 break;
1058 case CallDescriptor::kCallJSFunction:
1059 opcode = kArchCallJSFunction | MiscField::encode(flags);
1060 break;
1061 case CallDescriptor::kLazyBailout:
1062 opcode = kArchLazyBailout | MiscField::encode(flags);
1063 break;
1064 }
1065
1066 // Emit the call instruction.
1067 size_t const output_count = buffer.outputs.size();
1068 auto* outputs = output_count ? &buffer.outputs.front() : nullptr;
1069 Emit(opcode, output_count, outputs, buffer.instruction_args.size(),
1070 &buffer.instruction_args.front())
1071 ->MarkAsCall();
1072 }
1073
1074
1014 void InstructionSelector::VisitGoto(BasicBlock* target) { 1075 void InstructionSelector::VisitGoto(BasicBlock* target) {
1015 // jump to the next block. 1076 // jump to the next block.
1016 OperandGenerator g(this); 1077 OperandGenerator g(this);
1017 Emit(kArchJmp, g.NoOutput(), g.Label(target)); 1078 Emit(kArchJmp, g.NoOutput(), g.Label(target));
1018 } 1079 }
1019 1080
1020 1081
1021 void InstructionSelector::VisitReturn(Node* ret) { 1082 void InstructionSelector::VisitReturn(Node* ret) {
1022 OperandGenerator g(this); 1083 OperandGenerator g(this);
1023 if (linkage()->GetIncomingDescriptor()->ReturnCount() == 0) { 1084 if (linkage()->GetIncomingDescriptor()->ReturnCount() == 0) {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 for (StateValuesAccess::TypedNode input_node : StateValuesAccess(stack)) { 1219 for (StateValuesAccess::TypedNode input_node : StateValuesAccess(stack)) {
1159 inputs->push_back(OperandForDeopt(&g, input_node.node, kind)); 1220 inputs->push_back(OperandForDeopt(&g, input_node.node, kind));
1160 descriptor->SetType(value_index++, input_node.type); 1221 descriptor->SetType(value_index++, input_node.type);
1161 } 1222 }
1162 DCHECK(value_index == descriptor->GetSize()); 1223 DCHECK(value_index == descriptor->GetSize());
1163 } 1224 }
1164 1225
1165 } // namespace compiler 1226 } // namespace compiler
1166 } // namespace internal 1227 } // namespace internal
1167 } // namespace v8 1228 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/instruction-selector.h ('k') | src/compiler/mips/instruction-selector-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698