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

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

Issue 1205023002: [turbofan] Add basic support for calling to (a subset of) C functions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 months 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
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/base/adapters.h" 5 #include "src/base/adapters.h"
6 #include "src/base/bits.h" 6 #include "src/base/bits.h"
7 #include "src/compiler/instruction-selector-impl.h" 7 #include "src/compiler/instruction-selector-impl.h"
8 #include "src/compiler/node-matchers.h" 8 #include "src/compiler/node-matchers.h"
9 #include "src/compiler/node-properties.h" 9 #include "src/compiler/node-properties.h"
10 10
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 frame_state_descriptor = 1089 frame_state_descriptor =
1090 GetFrameStateDescriptor(node->InputAt(descriptor->InputCount())); 1090 GetFrameStateDescriptor(node->InputAt(descriptor->InputCount()));
1091 } 1091 }
1092 1092
1093 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); 1093 CallBuffer buffer(zone(), descriptor, frame_state_descriptor);
1094 1094
1095 // Compute InstructionOperands for inputs and outputs. 1095 // Compute InstructionOperands for inputs and outputs.
1096 // TODO(turbofan): on ARM it's probably better to use the code object in a 1096 // TODO(turbofan): on ARM it's probably better to use the code object in a
1097 // register if there are multiple uses of it. Improve constant pool and the 1097 // register if there are multiple uses of it. Improve constant pool and the
1098 // heuristics in the register allocator for where to emit constants. 1098 // heuristics in the register allocator for where to emit constants.
1099 InitializeCallBuffer(node, &buffer, true, false); 1099 InitializeCallBuffer(node, &buffer, true, true);
1100 1100
1101 // Push any stack arguments. 1101 // Prepare for C function call.
1102 for (Node* node : base::Reversed(buffer.pushed_nodes)) { 1102 if (descriptor->IsCFunctionCall()) {
1103 Emit(kArmPush, g.NoOutput(), g.UseRegister(node)); 1103 Emit(kArchPrepareCallCFunction |
1104 MiscField::encode(static_cast<int>(descriptor->CParameterCount())),
1105 0, nullptr, 0, nullptr);
1106
1107 // Poke any stack arguments.
1108 int slot = 0;
1109 for (Node* node : buffer.pushed_nodes) {
1110 Emit(kArmPoke | MiscField::encode(slot), g.NoOutput(),
1111 g.UseRegister(node));
1112 ++slot;
1113 }
1114 } else {
1115 // Push any stack arguments.
1116 for (Node* node : base::Reversed(buffer.pushed_nodes)) {
1117 Emit(kArmPush, g.NoOutput(), g.UseRegister(node));
1118 }
1104 } 1119 }
1105 1120
1106 // Pass label of exception handler block. 1121 // Pass label of exception handler block.
1107 CallDescriptor::Flags flags = descriptor->flags(); 1122 CallDescriptor::Flags flags = descriptor->flags();
1108 if (handler) { 1123 if (handler) {
1109 DCHECK_EQ(IrOpcode::kIfException, handler->front()->opcode()); 1124 DCHECK_EQ(IrOpcode::kIfException, handler->front()->opcode());
1110 IfExceptionHint hint = OpParameter<IfExceptionHint>(handler->front()); 1125 IfExceptionHint hint = OpParameter<IfExceptionHint>(handler->front());
1111 if (hint == IfExceptionHint::kLocallyCaught) { 1126 if (hint == IfExceptionHint::kLocallyCaught) {
1112 flags |= CallDescriptor::kHasLocalCatchHandler; 1127 flags |= CallDescriptor::kHasLocalCatchHandler;
1113 } 1128 }
1114 flags |= CallDescriptor::kHasExceptionHandler; 1129 flags |= CallDescriptor::kHasExceptionHandler;
1115 buffer.instruction_args.push_back(g.Label(handler)); 1130 buffer.instruction_args.push_back(g.Label(handler));
1116 } 1131 }
1117 1132
1118 // Select the appropriate opcode based on the call type. 1133 // Select the appropriate opcode based on the call type.
1119 InstructionCode opcode; 1134 InstructionCode opcode;
1120 switch (descriptor->kind()) { 1135 switch (descriptor->kind()) {
1121 case CallDescriptor::kCallCodeObject: { 1136 case CallDescriptor::kCallAddress:
1122 opcode = kArchCallCodeObject; 1137 opcode =
1138 kArchCallCFunction |
1139 MiscField::encode(static_cast<int>(descriptor->CParameterCount()));
1123 break; 1140 break;
1124 } 1141 case CallDescriptor::kCallCodeObject:
1142 opcode = kArchCallCodeObject | MiscField::encode(flags);
1143 break;
1125 case CallDescriptor::kCallJSFunction: 1144 case CallDescriptor::kCallJSFunction:
1126 opcode = kArchCallJSFunction; 1145 opcode = kArchCallJSFunction | MiscField::encode(flags);
1127 break; 1146 break;
1128 default: 1147 default:
1129 UNREACHABLE(); 1148 UNREACHABLE();
1130 return; 1149 return;
1131 } 1150 }
1132 opcode |= MiscField::encode(flags);
1133 1151
1134 // Emit the call instruction. 1152 // Emit the call instruction.
1135 size_t const output_count = buffer.outputs.size(); 1153 size_t const output_count = buffer.outputs.size();
1136 auto* outputs = output_count ? &buffer.outputs.front() : nullptr; 1154 auto* outputs = output_count ? &buffer.outputs.front() : nullptr;
1137 Emit(opcode, output_count, outputs, buffer.instruction_args.size(), 1155 Emit(opcode, output_count, outputs, buffer.instruction_args.size(),
1138 &buffer.instruction_args.front())->MarkAsCall(); 1156 &buffer.instruction_args.front())->MarkAsCall();
1139 } 1157 }
1140 1158
1141 1159
1142 void InstructionSelector::VisitTailCall(Node* node) { 1160 void InstructionSelector::VisitTailCall(Node* node) {
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
1605 flags |= MachineOperatorBuilder::kFloat64RoundDown | 1623 flags |= MachineOperatorBuilder::kFloat64RoundDown |
1606 MachineOperatorBuilder::kFloat64RoundTruncate | 1624 MachineOperatorBuilder::kFloat64RoundTruncate |
1607 MachineOperatorBuilder::kFloat64RoundTiesAway; 1625 MachineOperatorBuilder::kFloat64RoundTiesAway;
1608 } 1626 }
1609 return flags; 1627 return flags;
1610 } 1628 }
1611 1629
1612 } // namespace compiler 1630 } // namespace compiler
1613 } // namespace internal 1631 } // namespace internal
1614 } // namespace v8 1632 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698