| 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/compiler/instruction-selector-impl.h" | 5 #include "src/compiler/instruction-selector-impl.h" |
| 6 #include "src/compiler/node-matchers.h" | 6 #include "src/compiler/node-matchers.h" |
| 7 | 7 |
| 8 namespace v8 { | 8 namespace v8 { |
| 9 namespace internal { | 9 namespace internal { |
| 10 namespace compiler { | 10 namespace compiler { |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 if (cont->IsBranch()) { | 125 if (cont->IsBranch()) { |
| 126 inputs[input_count++] = g.Label(cont->true_block()); | 126 inputs[input_count++] = g.Label(cont->true_block()); |
| 127 inputs[input_count++] = g.Label(cont->false_block()); | 127 inputs[input_count++] = g.Label(cont->false_block()); |
| 128 } | 128 } |
| 129 | 129 |
| 130 outputs[output_count++] = g.DefineAsRegister(node); | 130 outputs[output_count++] = g.DefineAsRegister(node); |
| 131 if (cont->IsSet()) { | 131 if (cont->IsSet()) { |
| 132 outputs[output_count++] = g.DefineAsRegister(cont->result()); | 132 outputs[output_count++] = g.DefineAsRegister(cont->result()); |
| 133 } | 133 } |
| 134 | 134 |
| 135 ASSERT_NE(0, input_count); | 135 DCHECK_NE(0, input_count); |
| 136 ASSERT_NE(0, output_count); | 136 DCHECK_NE(0, output_count); |
| 137 ASSERT_GE(ARRAY_SIZE(inputs), input_count); | 137 DCHECK_GE(ARRAY_SIZE(inputs), input_count); |
| 138 ASSERT_GE(ARRAY_SIZE(outputs), output_count); | 138 DCHECK_GE(ARRAY_SIZE(outputs), output_count); |
| 139 | 139 |
| 140 Instruction* instr = selector->Emit(cont->Encode(opcode), output_count, | 140 Instruction* instr = selector->Emit(cont->Encode(opcode), output_count, |
| 141 outputs, input_count, inputs); | 141 outputs, input_count, inputs); |
| 142 if (cont->IsBranch()) instr->MarkAsControl(); | 142 if (cont->IsBranch()) instr->MarkAsControl(); |
| 143 } | 143 } |
| 144 | 144 |
| 145 | 145 |
| 146 // Shared routine for multiple binary operations. | 146 // Shared routine for multiple binary operations. |
| 147 static void VisitBinop(InstructionSelector* selector, Node* node, | 147 static void VisitBinop(InstructionSelector* selector, Node* node, |
| 148 ArchOpcode opcode, ImmediateMode operand_mode) { | 148 ArchOpcode opcode, ImmediateMode operand_mode) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 198 |
| 199 void InstructionSelector::VisitStore(Node* node) { | 199 void InstructionSelector::VisitStore(Node* node) { |
| 200 Arm64OperandGenerator g(this); | 200 Arm64OperandGenerator g(this); |
| 201 Node* base = node->InputAt(0); | 201 Node* base = node->InputAt(0); |
| 202 Node* index = node->InputAt(1); | 202 Node* index = node->InputAt(1); |
| 203 Node* value = node->InputAt(2); | 203 Node* value = node->InputAt(2); |
| 204 | 204 |
| 205 StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); | 205 StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); |
| 206 MachineRepresentation rep = store_rep.rep; | 206 MachineRepresentation rep = store_rep.rep; |
| 207 if (store_rep.write_barrier_kind == kFullWriteBarrier) { | 207 if (store_rep.write_barrier_kind == kFullWriteBarrier) { |
| 208 ASSERT(rep == kMachineTagged); | 208 DCHECK(rep == kMachineTagged); |
| 209 // TODO(dcarney): refactor RecordWrite function to take temp registers | 209 // TODO(dcarney): refactor RecordWrite function to take temp registers |
| 210 // and pass them here instead of using fixed regs | 210 // and pass them here instead of using fixed regs |
| 211 // TODO(dcarney): handle immediate indices. | 211 // TODO(dcarney): handle immediate indices. |
| 212 InstructionOperand* temps[] = {g.TempRegister(x11), g.TempRegister(x12)}; | 212 InstructionOperand* temps[] = {g.TempRegister(x11), g.TempRegister(x12)}; |
| 213 Emit(kArm64StoreWriteBarrier, NULL, g.UseFixed(base, x10), | 213 Emit(kArm64StoreWriteBarrier, NULL, g.UseFixed(base, x10), |
| 214 g.UseFixed(index, x11), g.UseFixed(value, x12), ARRAY_SIZE(temps), | 214 g.UseFixed(index, x11), g.UseFixed(value, x12), ARRAY_SIZE(temps), |
| 215 temps); | 215 temps); |
| 216 return; | 216 return; |
| 217 } | 217 } |
| 218 ASSERT_EQ(kNoWriteBarrier, store_rep.write_barrier_kind); | 218 DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind); |
| 219 InstructionOperand* val; | 219 InstructionOperand* val; |
| 220 if (rep == kMachineFloat64) { | 220 if (rep == kMachineFloat64) { |
| 221 val = g.UseDoubleRegister(value); | 221 val = g.UseDoubleRegister(value); |
| 222 } else { | 222 } else { |
| 223 val = g.UseRegister(value); | 223 val = g.UseRegister(value); |
| 224 } | 224 } |
| 225 ArchOpcode opcode; | 225 ArchOpcode opcode; |
| 226 switch (rep) { | 226 switch (rep) { |
| 227 case kMachineFloat64: | 227 case kMachineFloat64: |
| 228 opcode = kArm64Float64Store; | 228 opcode = kArm64Float64Store; |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 // Shared routine for multiple compare operations. | 496 // Shared routine for multiple compare operations. |
| 497 static void VisitCompare(InstructionSelector* selector, InstructionCode opcode, | 497 static void VisitCompare(InstructionSelector* selector, InstructionCode opcode, |
| 498 InstructionOperand* left, InstructionOperand* right, | 498 InstructionOperand* left, InstructionOperand* right, |
| 499 FlagsContinuation* cont) { | 499 FlagsContinuation* cont) { |
| 500 Arm64OperandGenerator g(selector); | 500 Arm64OperandGenerator g(selector); |
| 501 opcode = cont->Encode(opcode); | 501 opcode = cont->Encode(opcode); |
| 502 if (cont->IsBranch()) { | 502 if (cont->IsBranch()) { |
| 503 selector->Emit(opcode, NULL, left, right, g.Label(cont->true_block()), | 503 selector->Emit(opcode, NULL, left, right, g.Label(cont->true_block()), |
| 504 g.Label(cont->false_block()))->MarkAsControl(); | 504 g.Label(cont->false_block()))->MarkAsControl(); |
| 505 } else { | 505 } else { |
| 506 ASSERT(cont->IsSet()); | 506 DCHECK(cont->IsSet()); |
| 507 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); | 507 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); |
| 508 } | 508 } |
| 509 } | 509 } |
| 510 | 510 |
| 511 | 511 |
| 512 // Shared routine for multiple word compare operations. | 512 // Shared routine for multiple word compare operations. |
| 513 static void VisitWordCompare(InstructionSelector* selector, Node* node, | 513 static void VisitWordCompare(InstructionSelector* selector, Node* node, |
| 514 InstructionCode opcode, FlagsContinuation* cont, | 514 InstructionCode opcode, FlagsContinuation* cont, |
| 515 bool commutative) { | 515 bool commutative) { |
| 516 Arm64OperandGenerator g(selector); | 516 Arm64OperandGenerator g(selector); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 646 return; | 646 return; |
| 647 } | 647 } |
| 648 | 648 |
| 649 // Emit the call instruction. | 649 // Emit the call instruction. |
| 650 Instruction* call_instr = | 650 Instruction* call_instr = |
| 651 Emit(opcode, buffer.output_count, buffer.outputs, | 651 Emit(opcode, buffer.output_count, buffer.outputs, |
| 652 buffer.fixed_and_control_count(), buffer.fixed_and_control_args); | 652 buffer.fixed_and_control_count(), buffer.fixed_and_control_args); |
| 653 | 653 |
| 654 call_instr->MarkAsCall(); | 654 call_instr->MarkAsCall(); |
| 655 if (deoptimization != NULL) { | 655 if (deoptimization != NULL) { |
| 656 ASSERT(continuation != NULL); | 656 DCHECK(continuation != NULL); |
| 657 call_instr->MarkAsControl(); | 657 call_instr->MarkAsControl(); |
| 658 } | 658 } |
| 659 | 659 |
| 660 // Caller clean up of stack for C-style calls. | 660 // Caller clean up of stack for C-style calls. |
| 661 if (is_c_frame && aligned_push_count > 0) { | 661 if (is_c_frame && aligned_push_count > 0) { |
| 662 ASSERT(deoptimization == NULL && continuation == NULL); | 662 DCHECK(deoptimization == NULL && continuation == NULL); |
| 663 Emit(kArm64Drop | MiscField::encode(aligned_push_count), NULL); | 663 Emit(kArm64Drop | MiscField::encode(aligned_push_count), NULL); |
| 664 } | 664 } |
| 665 } | 665 } |
| 666 | 666 |
| 667 #endif // V8_TURBOFAN_TARGET | 667 #endif // V8_TURBOFAN_TARGET |
| 668 | 668 |
| 669 } // namespace compiler | 669 } // namespace compiler |
| 670 } // namespace internal | 670 } // namespace internal |
| 671 } // namespace v8 | 671 } // namespace v8 |
| OLD | NEW |