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/bits.h" | 5 #include "src/base/bits.h" |
6 #include "src/compiler/instruction-selector-impl.h" | 6 #include "src/compiler/instruction-selector-impl.h" |
7 #include "src/compiler/node-matchers.h" | 7 #include "src/compiler/node-matchers.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 Emit(kArmVmodF64, g.DefineAsFixedDouble(node, d0), | 778 Emit(kArmVmodF64, g.DefineAsFixedDouble(node, d0), |
779 g.UseFixedDouble(node->InputAt(0), d0), | 779 g.UseFixedDouble(node->InputAt(0), d0), |
780 g.UseFixedDouble(node->InputAt(1), d1))->MarkAsCall(); | 780 g.UseFixedDouble(node->InputAt(1), d1))->MarkAsCall(); |
781 } | 781 } |
782 | 782 |
783 | 783 |
784 void InstructionSelector::VisitCall(Node* call, BasicBlock* continuation, | 784 void InstructionSelector::VisitCall(Node* call, BasicBlock* continuation, |
785 BasicBlock* deoptimization) { | 785 BasicBlock* deoptimization) { |
786 ArmOperandGenerator g(this); | 786 ArmOperandGenerator g(this); |
787 CallDescriptor* descriptor = OpParameter<CallDescriptor*>(call); | 787 CallDescriptor* descriptor = OpParameter<CallDescriptor*>(call); |
788 CallBuffer buffer(zone(), descriptor); // TODO(turbofan): temp zone here? | 788 |
| 789 FrameStateDescriptor* frame_state_descriptor = NULL; |
| 790 if (descriptor->NeedsFrameState()) { |
| 791 frame_state_descriptor = |
| 792 GetFrameStateDescriptor(call->InputAt(descriptor->InputCount())); |
| 793 } |
| 794 |
| 795 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); |
789 | 796 |
790 // Compute InstructionOperands for inputs and outputs. | 797 // Compute InstructionOperands for inputs and outputs. |
791 // TODO(turbofan): on ARM64 it's probably better to use the code object in a | 798 // TODO(turbofan): on ARM64 it's probably better to use the code object in a |
792 // register if there are multiple uses of it. Improve constant pool and the | 799 // register if there are multiple uses of it. Improve constant pool and the |
793 // heuristics in the register allocator for where to emit constants. | 800 // heuristics in the register allocator for where to emit constants. |
794 InitializeCallBuffer(call, &buffer, true, false, continuation, | 801 InitializeCallBuffer(call, &buffer, true, false, continuation, |
795 deoptimization); | 802 deoptimization); |
796 | 803 |
797 // TODO(dcarney): might be possible to use claim/poke instead | 804 // TODO(dcarney): might be possible to use claim/poke instead |
798 // Push any stack arguments. | 805 // Push any stack arguments. |
799 for (int i = buffer.pushed_count - 1; i >= 0; --i) { | 806 for (NodeVectorRIter input = buffer.pushed_nodes.rbegin(); |
800 Node* input = buffer.pushed_nodes[i]; | 807 input != buffer.pushed_nodes.rend(); input++) { |
801 Emit(kArmPush, NULL, g.UseRegister(input)); | 808 Emit(kArmPush, NULL, g.UseRegister(*input)); |
802 } | 809 } |
803 | 810 |
804 // Select the appropriate opcode based on the call type. | 811 // Select the appropriate opcode based on the call type. |
805 InstructionCode opcode; | 812 InstructionCode opcode; |
806 switch (descriptor->kind()) { | 813 switch (descriptor->kind()) { |
807 case CallDescriptor::kCallCodeObject: { | 814 case CallDescriptor::kCallCodeObject: { |
808 bool lazy_deopt = descriptor->CanLazilyDeoptimize(); | 815 opcode = kArmCallCodeObject; |
809 opcode = kArmCallCodeObject | MiscField::encode(lazy_deopt ? 1 : 0); | |
810 break; | 816 break; |
811 } | 817 } |
812 case CallDescriptor::kCallAddress: | 818 case CallDescriptor::kCallAddress: |
813 opcode = kArmCallAddress; | 819 opcode = kArmCallAddress; |
814 break; | 820 break; |
815 case CallDescriptor::kCallJSFunction: | 821 case CallDescriptor::kCallJSFunction: |
816 opcode = kArmCallJSFunction; | 822 opcode = kArmCallJSFunction; |
817 break; | 823 break; |
818 default: | 824 default: |
819 UNREACHABLE(); | 825 UNREACHABLE(); |
820 return; | 826 return; |
821 } | 827 } |
| 828 opcode |= MiscField::encode(descriptor->deoptimization_support()); |
822 | 829 |
823 // Emit the call instruction. | 830 // Emit the call instruction. |
824 Instruction* call_instr = | 831 Instruction* call_instr = |
825 Emit(opcode, buffer.output_count, buffer.outputs, | 832 Emit(opcode, buffer.outputs.size(), &buffer.outputs.front(), |
826 buffer.fixed_and_control_count(), buffer.fixed_and_control_args); | 833 buffer.instruction_args.size(), &buffer.instruction_args.front()); |
827 | 834 |
828 call_instr->MarkAsCall(); | 835 call_instr->MarkAsCall(); |
829 if (deoptimization != NULL) { | 836 if (deoptimization != NULL) { |
830 DCHECK(continuation != NULL); | 837 DCHECK(continuation != NULL); |
831 call_instr->MarkAsControl(); | 838 call_instr->MarkAsControl(); |
832 } | 839 } |
833 | 840 |
834 // Caller clean up of stack for C-style calls. | 841 // Caller clean up of stack for C-style calls. |
835 if (descriptor->kind() == CallDescriptor::kCallAddress && | 842 if (descriptor->kind() == CallDescriptor::kCallAddress && |
836 buffer.pushed_count > 0) { | 843 !buffer.pushed_nodes.empty()) { |
837 DCHECK(deoptimization == NULL && continuation == NULL); | 844 DCHECK(deoptimization == NULL && continuation == NULL); |
838 Emit(kArmDrop | MiscField::encode(buffer.pushed_count), NULL); | 845 Emit(kArmDrop | MiscField::encode(buffer.pushed_nodes.size()), NULL); |
839 } | 846 } |
840 } | 847 } |
841 | 848 |
842 | 849 |
843 void InstructionSelector::VisitInt32AddWithOverflow(Node* node, | 850 void InstructionSelector::VisitInt32AddWithOverflow(Node* node, |
844 FlagsContinuation* cont) { | 851 FlagsContinuation* cont) { |
845 VisitBinop(this, node, kArmAdd, kArmAdd, cont); | 852 VisitBinop(this, node, kArmAdd, kArmAdd, cont); |
846 } | 853 } |
847 | 854 |
848 | 855 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
952 DCHECK(cont->IsSet()); | 959 DCHECK(cont->IsSet()); |
953 Emit(cont->Encode(kArmVcmpF64), g.DefineAsRegister(cont->result()), | 960 Emit(cont->Encode(kArmVcmpF64), g.DefineAsRegister(cont->result()), |
954 g.UseDoubleRegister(m.left().node()), | 961 g.UseDoubleRegister(m.left().node()), |
955 g.UseDoubleRegister(m.right().node())); | 962 g.UseDoubleRegister(m.right().node())); |
956 } | 963 } |
957 } | 964 } |
958 | 965 |
959 } // namespace compiler | 966 } // namespace compiler |
960 } // namespace internal | 967 } // namespace internal |
961 } // namespace v8 | 968 } // namespace v8 |
OLD | NEW |