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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "src/base/adapters.h" | 7 #include "src/base/adapters.h" |
8 #include "src/compiler/instruction-selector-impl.h" | 8 #include "src/compiler/instruction-selector-impl.h" |
9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 VisitRRFloat64(this, kSSEFloat64Round | MiscField::encode(kRoundToZero), | 1012 VisitRRFloat64(this, kSSEFloat64Round | MiscField::encode(kRoundToZero), |
1013 node); | 1013 node); |
1014 } | 1014 } |
1015 | 1015 |
1016 | 1016 |
1017 void InstructionSelector::VisitFloat64RoundTiesAway(Node* node) { | 1017 void InstructionSelector::VisitFloat64RoundTiesAway(Node* node) { |
1018 UNREACHABLE(); | 1018 UNREACHABLE(); |
1019 } | 1019 } |
1020 | 1020 |
1021 | 1021 |
1022 void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) { | 1022 void InstructionSelector::VisitCall(Node* node, BasicBlock* handler, |
| 1023 CallMode call_mode) { |
1023 X64OperandGenerator g(this); | 1024 X64OperandGenerator g(this); |
1024 const CallDescriptor* descriptor = OpParameter<const CallDescriptor*>(node); | 1025 const CallDescriptor* descriptor = OpParameter<const CallDescriptor*>(node); |
1025 | 1026 |
1026 FrameStateDescriptor* frame_state_descriptor = NULL; | 1027 FrameStateDescriptor* frame_state_descriptor = NULL; |
1027 if (descriptor->NeedsFrameState()) { | 1028 if (descriptor->NeedsFrameState()) { |
1028 frame_state_descriptor = GetFrameStateDescriptor( | 1029 frame_state_descriptor = GetFrameStateDescriptor( |
1029 node->InputAt(static_cast<int>(descriptor->InputCount()))); | 1030 node->InputAt(static_cast<int>(descriptor->InputCount()))); |
1030 } | 1031 } |
1031 | 1032 |
1032 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); | 1033 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); |
(...skipping 12 matching lines...) Expand all Loading... |
1045 } | 1046 } |
1046 | 1047 |
1047 // Pass label of exception handler block. | 1048 // Pass label of exception handler block. |
1048 CallDescriptor::Flags flags = descriptor->flags(); | 1049 CallDescriptor::Flags flags = descriptor->flags(); |
1049 if (handler != nullptr) { | 1050 if (handler != nullptr) { |
1050 flags |= CallDescriptor::kHasExceptionHandler; | 1051 flags |= CallDescriptor::kHasExceptionHandler; |
1051 buffer.instruction_args.push_back(g.Label(handler)); | 1052 buffer.instruction_args.push_back(g.Label(handler)); |
1052 } | 1053 } |
1053 | 1054 |
1054 // Select the appropriate opcode based on the call type. | 1055 // Select the appropriate opcode based on the call type. |
| 1056 bool is_tail_call = call_mode == TAIL_CALL; |
1055 InstructionCode opcode; | 1057 InstructionCode opcode; |
1056 switch (descriptor->kind()) { | 1058 switch (descriptor->kind()) { |
1057 case CallDescriptor::kCallCodeObject: { | 1059 case CallDescriptor::kCallCodeObject: { |
1058 opcode = kArchCallCodeObject; | 1060 opcode = is_tail_call ? kArchTailCallCodeObject : kArchCallCodeObject; |
1059 break; | 1061 break; |
1060 } | 1062 } |
1061 case CallDescriptor::kCallJSFunction: | 1063 case CallDescriptor::kCallJSFunction: |
1062 opcode = kArchCallJSFunction; | 1064 opcode = is_tail_call ? kArchTailCallJSFunction : kArchCallJSFunction; |
1063 break; | 1065 break; |
1064 default: | 1066 default: |
1065 UNREACHABLE(); | 1067 UNREACHABLE(); |
1066 return; | 1068 return; |
1067 } | 1069 } |
1068 opcode |= MiscField::encode(flags); | 1070 opcode |= MiscField::encode(flags); |
1069 | 1071 |
1070 // Emit the call instruction. | 1072 // Emit the call instruction. |
| 1073 size_t size = is_tail_call ? 0 : buffer.outputs.size(); |
1071 InstructionOperand* first_output = | 1074 InstructionOperand* first_output = |
1072 buffer.outputs.size() > 0 ? &buffer.outputs.front() : NULL; | 1075 size > 0 ? &buffer.outputs.front() : nullptr; |
1073 Instruction* call_instr = | 1076 Instruction* call_instr = |
1074 Emit(opcode, buffer.outputs.size(), first_output, | 1077 Emit(opcode, size, first_output, buffer.instruction_args.size(), |
1075 buffer.instruction_args.size(), &buffer.instruction_args.front()); | 1078 &buffer.instruction_args.front()); |
1076 call_instr->MarkAsCall(); | 1079 call_instr->MarkAsCall(); |
1077 } | 1080 } |
1078 | 1081 |
1079 | 1082 |
1080 namespace { | 1083 namespace { |
1081 | 1084 |
1082 // Shared routine for multiple compare operations. | 1085 // Shared routine for multiple compare operations. |
1083 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, | 1086 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, |
1084 InstructionOperand left, InstructionOperand right, | 1087 InstructionOperand left, InstructionOperand right, |
1085 FlagsContinuation* cont) { | 1088 FlagsContinuation* cont) { |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1549 if (CpuFeatures::IsSupported(SSE4_1)) { | 1552 if (CpuFeatures::IsSupported(SSE4_1)) { |
1550 flags |= MachineOperatorBuilder::kFloat64RoundDown | | 1553 flags |= MachineOperatorBuilder::kFloat64RoundDown | |
1551 MachineOperatorBuilder::kFloat64RoundTruncate; | 1554 MachineOperatorBuilder::kFloat64RoundTruncate; |
1552 } | 1555 } |
1553 return flags; | 1556 return flags; |
1554 } | 1557 } |
1555 | 1558 |
1556 } // namespace compiler | 1559 } // namespace compiler |
1557 } // namespace internal | 1560 } // namespace internal |
1558 } // namespace v8 | 1561 } // namespace v8 |
OLD | NEW |