OLD | NEW |
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 Loading... |
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 for (size_t n = 0; n < buffer.pushed_nodes.size(); ++n) { |
| 1109 if (Node* node = buffer.pushed_nodes[n]) { |
| 1110 int const slot = static_cast<int>(n); |
| 1111 InstructionOperand value = g.UseRegister(node); |
| 1112 Emit(kArmPoke | MiscField::encode(slot), g.NoOutput(), value); |
| 1113 } |
| 1114 } |
| 1115 } else { |
| 1116 // Push any stack arguments. |
| 1117 for (Node* node : base::Reversed(buffer.pushed_nodes)) { |
| 1118 Emit(kArmPush, g.NoOutput(), g.UseRegister(node)); |
| 1119 } |
1104 } | 1120 } |
1105 | 1121 |
1106 // Pass label of exception handler block. | 1122 // Pass label of exception handler block. |
1107 CallDescriptor::Flags flags = descriptor->flags(); | 1123 CallDescriptor::Flags flags = descriptor->flags(); |
1108 if (handler) { | 1124 if (handler) { |
1109 DCHECK_EQ(IrOpcode::kIfException, handler->front()->opcode()); | 1125 DCHECK_EQ(IrOpcode::kIfException, handler->front()->opcode()); |
1110 IfExceptionHint hint = OpParameter<IfExceptionHint>(handler->front()); | 1126 IfExceptionHint hint = OpParameter<IfExceptionHint>(handler->front()); |
1111 if (hint == IfExceptionHint::kLocallyCaught) { | 1127 if (hint == IfExceptionHint::kLocallyCaught) { |
1112 flags |= CallDescriptor::kHasLocalCatchHandler; | 1128 flags |= CallDescriptor::kHasLocalCatchHandler; |
1113 } | 1129 } |
1114 flags |= CallDescriptor::kHasExceptionHandler; | 1130 flags |= CallDescriptor::kHasExceptionHandler; |
1115 buffer.instruction_args.push_back(g.Label(handler)); | 1131 buffer.instruction_args.push_back(g.Label(handler)); |
1116 } | 1132 } |
1117 | 1133 |
1118 // Select the appropriate opcode based on the call type. | 1134 // Select the appropriate opcode based on the call type. |
1119 InstructionCode opcode; | 1135 InstructionCode opcode; |
1120 switch (descriptor->kind()) { | 1136 switch (descriptor->kind()) { |
1121 case CallDescriptor::kCallCodeObject: { | 1137 case CallDescriptor::kCallAddress: |
1122 opcode = kArchCallCodeObject; | 1138 opcode = |
| 1139 kArchCallCFunction | |
| 1140 MiscField::encode(static_cast<int>(descriptor->CParameterCount())); |
1123 break; | 1141 break; |
1124 } | 1142 case CallDescriptor::kCallCodeObject: |
| 1143 opcode = kArchCallCodeObject | MiscField::encode(flags); |
| 1144 break; |
1125 case CallDescriptor::kCallJSFunction: | 1145 case CallDescriptor::kCallJSFunction: |
1126 opcode = kArchCallJSFunction; | 1146 opcode = kArchCallJSFunction | MiscField::encode(flags); |
1127 break; | 1147 break; |
1128 default: | 1148 default: |
1129 UNREACHABLE(); | 1149 UNREACHABLE(); |
1130 return; | 1150 return; |
1131 } | 1151 } |
1132 opcode |= MiscField::encode(flags); | |
1133 | 1152 |
1134 // Emit the call instruction. | 1153 // Emit the call instruction. |
1135 size_t const output_count = buffer.outputs.size(); | 1154 size_t const output_count = buffer.outputs.size(); |
1136 auto* outputs = output_count ? &buffer.outputs.front() : nullptr; | 1155 auto* outputs = output_count ? &buffer.outputs.front() : nullptr; |
1137 Emit(opcode, output_count, outputs, buffer.instruction_args.size(), | 1156 Emit(opcode, output_count, outputs, buffer.instruction_args.size(), |
1138 &buffer.instruction_args.front())->MarkAsCall(); | 1157 &buffer.instruction_args.front())->MarkAsCall(); |
1139 } | 1158 } |
1140 | 1159 |
1141 | 1160 |
1142 void InstructionSelector::VisitTailCall(Node* node) { | 1161 void InstructionSelector::VisitTailCall(Node* node) { |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1605 flags |= MachineOperatorBuilder::kFloat64RoundDown | | 1624 flags |= MachineOperatorBuilder::kFloat64RoundDown | |
1606 MachineOperatorBuilder::kFloat64RoundTruncate | | 1625 MachineOperatorBuilder::kFloat64RoundTruncate | |
1607 MachineOperatorBuilder::kFloat64RoundTiesAway; | 1626 MachineOperatorBuilder::kFloat64RoundTiesAway; |
1608 } | 1627 } |
1609 return flags; | 1628 return flags; |
1610 } | 1629 } |
1611 | 1630 |
1612 } // namespace compiler | 1631 } // namespace compiler |
1613 } // namespace internal | 1632 } // namespace internal |
1614 } // namespace v8 | 1633 } // namespace v8 |
OLD | NEW |