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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 | 105 |
106 void InstructionSelector::VisitStore(Node* node) { | 106 void InstructionSelector::VisitStore(Node* node) { |
107 X64OperandGenerator g(this); | 107 X64OperandGenerator g(this); |
108 Node* base = node->InputAt(0); | 108 Node* base = node->InputAt(0); |
109 Node* index = node->InputAt(1); | 109 Node* index = node->InputAt(1); |
110 Node* value = node->InputAt(2); | 110 Node* value = node->InputAt(2); |
111 | 111 |
112 StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); | 112 StoreRepresentation store_rep = OpParameter<StoreRepresentation>(node); |
113 MachineRepresentation rep = store_rep.rep; | 113 MachineRepresentation rep = store_rep.rep; |
114 if (store_rep.write_barrier_kind == kFullWriteBarrier) { | 114 if (store_rep.write_barrier_kind == kFullWriteBarrier) { |
115 ASSERT(rep == kMachineTagged); | 115 DCHECK(rep == kMachineTagged); |
116 // TODO(dcarney): refactor RecordWrite function to take temp registers | 116 // TODO(dcarney): refactor RecordWrite function to take temp registers |
117 // and pass them here instead of using fixed regs | 117 // and pass them here instead of using fixed regs |
118 // TODO(dcarney): handle immediate indices. | 118 // TODO(dcarney): handle immediate indices. |
119 InstructionOperand* temps[] = {g.TempRegister(rcx), g.TempRegister(rdx)}; | 119 InstructionOperand* temps[] = {g.TempRegister(rcx), g.TempRegister(rdx)}; |
120 Emit(kX64StoreWriteBarrier, NULL, g.UseFixed(base, rbx), | 120 Emit(kX64StoreWriteBarrier, NULL, g.UseFixed(base, rbx), |
121 g.UseFixed(index, rcx), g.UseFixed(value, rdx), ARRAY_SIZE(temps), | 121 g.UseFixed(index, rcx), g.UseFixed(value, rdx), ARRAY_SIZE(temps), |
122 temps); | 122 temps); |
123 return; | 123 return; |
124 } | 124 } |
125 ASSERT_EQ(kNoWriteBarrier, store_rep.write_barrier_kind); | 125 DCHECK_EQ(kNoWriteBarrier, store_rep.write_barrier_kind); |
126 bool is_immediate = false; | 126 bool is_immediate = false; |
127 InstructionOperand* val; | 127 InstructionOperand* val; |
128 if (rep == kMachineFloat64) { | 128 if (rep == kMachineFloat64) { |
129 val = g.UseDoubleRegister(value); | 129 val = g.UseDoubleRegister(value); |
130 } else { | 130 } else { |
131 is_immediate = g.CanBeImmediate(value); | 131 is_immediate = g.CanBeImmediate(value); |
132 if (is_immediate) { | 132 if (is_immediate) { |
133 val = g.UseImmediate(value); | 133 val = g.UseImmediate(value); |
134 } else if (rep == kMachineWord8) { | 134 } else if (rep == kMachineWord8) { |
135 val = g.UseByteRegister(value); | 135 val = g.UseByteRegister(value); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 if (cont->IsBranch()) { | 198 if (cont->IsBranch()) { |
199 inputs[input_count++] = g.Label(cont->true_block()); | 199 inputs[input_count++] = g.Label(cont->true_block()); |
200 inputs[input_count++] = g.Label(cont->false_block()); | 200 inputs[input_count++] = g.Label(cont->false_block()); |
201 } | 201 } |
202 | 202 |
203 outputs[output_count++] = g.DefineSameAsFirst(node); | 203 outputs[output_count++] = g.DefineSameAsFirst(node); |
204 if (cont->IsSet()) { | 204 if (cont->IsSet()) { |
205 outputs[output_count++] = g.DefineAsRegister(cont->result()); | 205 outputs[output_count++] = g.DefineAsRegister(cont->result()); |
206 } | 206 } |
207 | 207 |
208 ASSERT_NE(0, input_count); | 208 DCHECK_NE(0, input_count); |
209 ASSERT_NE(0, output_count); | 209 DCHECK_NE(0, output_count); |
210 ASSERT_GE(ARRAY_SIZE(inputs), input_count); | 210 DCHECK_GE(ARRAY_SIZE(inputs), input_count); |
211 ASSERT_GE(ARRAY_SIZE(outputs), output_count); | 211 DCHECK_GE(ARRAY_SIZE(outputs), output_count); |
212 | 212 |
213 Instruction* instr = selector->Emit(cont->Encode(opcode), output_count, | 213 Instruction* instr = selector->Emit(cont->Encode(opcode), output_count, |
214 outputs, input_count, inputs); | 214 outputs, input_count, inputs); |
215 if (cont->IsBranch()) instr->MarkAsControl(); | 215 if (cont->IsBranch()) instr->MarkAsControl(); |
216 } | 216 } |
217 | 217 |
218 | 218 |
219 // Shared routine for multiple binary operations. | 219 // Shared routine for multiple binary operations. |
220 static void VisitBinop(InstructionSelector* selector, Node* node, | 220 static void VisitBinop(InstructionSelector* selector, Node* node, |
221 InstructionCode opcode) { | 221 InstructionCode opcode) { |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 // Shared routine for multiple compare operations. | 574 // Shared routine for multiple compare operations. |
575 static void VisitCompare(InstructionSelector* selector, InstructionCode opcode, | 575 static void VisitCompare(InstructionSelector* selector, InstructionCode opcode, |
576 InstructionOperand* left, InstructionOperand* right, | 576 InstructionOperand* left, InstructionOperand* right, |
577 FlagsContinuation* cont) { | 577 FlagsContinuation* cont) { |
578 X64OperandGenerator g(selector); | 578 X64OperandGenerator g(selector); |
579 opcode = cont->Encode(opcode); | 579 opcode = cont->Encode(opcode); |
580 if (cont->IsBranch()) { | 580 if (cont->IsBranch()) { |
581 selector->Emit(opcode, NULL, left, right, g.Label(cont->true_block()), | 581 selector->Emit(opcode, NULL, left, right, g.Label(cont->true_block()), |
582 g.Label(cont->false_block()))->MarkAsControl(); | 582 g.Label(cont->false_block()))->MarkAsControl(); |
583 } else { | 583 } else { |
584 ASSERT(cont->IsSet()); | 584 DCHECK(cont->IsSet()); |
585 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); | 585 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); |
586 } | 586 } |
587 } | 587 } |
588 | 588 |
589 | 589 |
590 // Shared routine for multiple word compare operations. | 590 // Shared routine for multiple word compare operations. |
591 static void VisitWordCompare(InstructionSelector* selector, Node* node, | 591 static void VisitWordCompare(InstructionSelector* selector, Node* node, |
592 InstructionCode opcode, FlagsContinuation* cont, | 592 InstructionCode opcode, FlagsContinuation* cont, |
593 bool commutative) { | 593 bool commutative) { |
594 X64OperandGenerator g(selector); | 594 X64OperandGenerator g(selector); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 return; | 700 return; |
701 } | 701 } |
702 | 702 |
703 // Emit the call instruction. | 703 // Emit the call instruction. |
704 Instruction* call_instr = | 704 Instruction* call_instr = |
705 Emit(opcode, buffer.output_count, buffer.outputs, | 705 Emit(opcode, buffer.output_count, buffer.outputs, |
706 buffer.fixed_and_control_count(), buffer.fixed_and_control_args); | 706 buffer.fixed_and_control_count(), buffer.fixed_and_control_args); |
707 | 707 |
708 call_instr->MarkAsCall(); | 708 call_instr->MarkAsCall(); |
709 if (deoptimization != NULL) { | 709 if (deoptimization != NULL) { |
710 ASSERT(continuation != NULL); | 710 DCHECK(continuation != NULL); |
711 call_instr->MarkAsControl(); | 711 call_instr->MarkAsControl(); |
712 } | 712 } |
713 | 713 |
714 // Caller clean up of stack for C-style calls. | 714 // Caller clean up of stack for C-style calls. |
715 if (descriptor->kind() == CallDescriptor::kCallAddress && | 715 if (descriptor->kind() == CallDescriptor::kCallAddress && |
716 buffer.pushed_count > 0) { | 716 buffer.pushed_count > 0) { |
717 ASSERT(deoptimization == NULL && continuation == NULL); | 717 DCHECK(deoptimization == NULL && continuation == NULL); |
718 Emit(kPopStack | MiscField::encode(buffer.pushed_count), NULL); | 718 Emit(kPopStack | MiscField::encode(buffer.pushed_count), NULL); |
719 } | 719 } |
720 } | 720 } |
721 | 721 |
722 #endif | 722 #endif |
723 | 723 |
724 } // namespace compiler | 724 } // namespace compiler |
725 } // namespace internal | 725 } // namespace internal |
726 } // namespace v8 | 726 } // namespace v8 |
OLD | NEW |