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 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 | 679 |
680 // Compute InstructionOperands for inputs and outputs. | 680 // Compute InstructionOperands for inputs and outputs. |
681 InitializeCallBuffer(call, &buffer, true, true, continuation, deoptimization); | 681 InitializeCallBuffer(call, &buffer, true, true, continuation, deoptimization); |
682 | 682 |
683 // TODO(dcarney): stack alignment for c calls. | 683 // TODO(dcarney): stack alignment for c calls. |
684 // TODO(dcarney): shadow space on window for c calls. | 684 // TODO(dcarney): shadow space on window for c calls. |
685 // Push any stack arguments. | 685 // Push any stack arguments. |
686 for (NodeVectorRIter input = buffer.pushed_nodes.rbegin(); | 686 for (NodeVectorRIter input = buffer.pushed_nodes.rbegin(); |
687 input != buffer.pushed_nodes.rend(); input++) { | 687 input != buffer.pushed_nodes.rend(); input++) { |
688 // TODO(titzer): handle pushing double parameters. | 688 // TODO(titzer): handle pushing double parameters. |
689 if (g.CanBeImmediate(*input)) { | 689 Emit(kX64Push, NULL, |
690 Emit(kX64PushI, NULL, g.UseImmediate(*input)); | 690 g.CanBeImmediate(*input) ? g.UseImmediate(*input) : g.Use(*input)); |
691 } else { | |
692 Emit(kX64Push, NULL, g.Use(*input)); | |
693 } | |
694 } | 691 } |
695 | 692 |
696 // Select the appropriate opcode based on the call type. | 693 // Select the appropriate opcode based on the call type. |
697 InstructionCode opcode; | 694 InstructionCode opcode; |
698 switch (descriptor->kind()) { | 695 switch (descriptor->kind()) { |
699 case CallDescriptor::kCallCodeObject: { | 696 case CallDescriptor::kCallCodeObject: { |
700 opcode = kX64CallCodeObject; | 697 opcode = kArchCallCodeObject; |
701 break; | 698 break; |
702 } | 699 } |
703 case CallDescriptor::kCallAddress: | 700 case CallDescriptor::kCallAddress: |
704 opcode = kX64CallAddress; | 701 opcode = kArchCallAddress; |
705 break; | 702 break; |
706 case CallDescriptor::kCallJSFunction: | 703 case CallDescriptor::kCallJSFunction: |
707 opcode = kX64CallJSFunction; | 704 opcode = kArchCallJSFunction; |
708 break; | 705 break; |
709 default: | 706 default: |
710 UNREACHABLE(); | 707 UNREACHABLE(); |
711 return; | 708 return; |
712 } | 709 } |
713 opcode |= MiscField::encode(descriptor->deoptimization_support()); | 710 opcode |= MiscField::encode(descriptor->deoptimization_support()); |
714 | 711 |
715 // Emit the call instruction. | 712 // Emit the call instruction. |
716 Instruction* call_instr = | 713 Instruction* call_instr = |
717 Emit(opcode, buffer.outputs.size(), &buffer.outputs.front(), | 714 Emit(opcode, buffer.outputs.size(), &buffer.outputs.front(), |
718 buffer.instruction_args.size(), &buffer.instruction_args.front()); | 715 buffer.instruction_args.size(), &buffer.instruction_args.front()); |
719 | 716 |
720 call_instr->MarkAsCall(); | 717 call_instr->MarkAsCall(); |
721 if (deoptimization != NULL) { | 718 if (deoptimization != NULL) { |
722 DCHECK(continuation != NULL); | 719 DCHECK(continuation != NULL); |
723 call_instr->MarkAsControl(); | 720 call_instr->MarkAsControl(); |
724 } | 721 } |
725 | 722 |
726 // Caller clean up of stack for C-style calls. | 723 // Caller clean up of stack for C-style calls. |
727 if (descriptor->kind() == CallDescriptor::kCallAddress && | 724 if (descriptor->kind() == CallDescriptor::kCallAddress && |
728 !buffer.pushed_nodes.empty()) { | 725 !buffer.pushed_nodes.empty()) { |
729 DCHECK(deoptimization == NULL && continuation == NULL); | 726 DCHECK(deoptimization == NULL && continuation == NULL); |
730 Emit(kPopStack | | 727 Emit(kArchDrop | |
731 MiscField::encode(static_cast<int>(buffer.pushed_nodes.size())), | 728 MiscField::encode(static_cast<int>(buffer.pushed_nodes.size())), |
732 NULL); | 729 NULL); |
733 } | 730 } |
734 } | 731 } |
735 | 732 |
736 } // namespace compiler | 733 } // namespace compiler |
737 } // namespace internal | 734 } // namespace internal |
738 } // namespace v8 | 735 } // namespace v8 |
OLD | NEW |