| 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/ast/scopes.h" | 5 #include "src/ast/scopes.h" |
| 6 #include "src/code-stubs.h" | 6 #include "src/code-stubs.h" |
| 7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
| 8 #include "src/compiler/common-operator.h" | 8 #include "src/compiler/common-operator.h" |
| 9 #include "src/compiler/frame.h" | 9 #include "src/compiler/frame.h" |
| 10 #include "src/compiler/linkage.h" | 10 #include "src/compiler/linkage.h" |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 93 |
| 94 bool CallDescriptor::HasSameReturnLocationsAs( | 94 bool CallDescriptor::HasSameReturnLocationsAs( |
| 95 const CallDescriptor* other) const { | 95 const CallDescriptor* other) const { |
| 96 if (ReturnCount() != other->ReturnCount()) return false; | 96 if (ReturnCount() != other->ReturnCount()) return false; |
| 97 for (size_t i = 0; i < ReturnCount(); ++i) { | 97 for (size_t i = 0; i < ReturnCount(); ++i) { |
| 98 if (GetReturnLocation(i) != other->GetReturnLocation(i)) return false; | 98 if (GetReturnLocation(i) != other->GetReturnLocation(i)) return false; |
| 99 } | 99 } |
| 100 return true; | 100 return true; |
| 101 } | 101 } |
| 102 | 102 |
| 103 int CallDescriptor::GetStackParameterDelta( |
| 104 CallDescriptor const* tail_caller) const { |
| 105 int callee_slots_above_sp = 0; |
| 106 for (size_t i = 0; i < InputCount(); ++i) { |
| 107 LinkageLocation operand = GetInputLocation(i); |
| 108 if (!operand.IsRegister()) { |
| 109 int new_candidate = |
| 110 -operand.GetLocation() + operand.GetSizeInPointers() - 1; |
| 111 if (new_candidate > callee_slots_above_sp) { |
| 112 callee_slots_above_sp = new_candidate; |
| 113 } |
| 114 } |
| 115 } |
| 116 int tail_caller_slots_above_sp = 0; |
| 117 if (tail_caller != nullptr) { |
| 118 for (size_t i = 0; i < tail_caller->InputCount(); ++i) { |
| 119 LinkageLocation operand = tail_caller->GetInputLocation(i); |
| 120 if (!operand.IsRegister()) { |
| 121 int new_candidate = |
| 122 -operand.GetLocation() + operand.GetSizeInPointers() - 1; |
| 123 if (new_candidate > tail_caller_slots_above_sp) { |
| 124 tail_caller_slots_above_sp = new_candidate; |
| 125 } |
| 126 } |
| 127 } |
| 128 } |
| 129 return callee_slots_above_sp - tail_caller_slots_above_sp; |
| 130 } |
| 103 | 131 |
| 104 bool CallDescriptor::CanTailCall(const Node* node, | 132 bool CallDescriptor::CanTailCall(const Node* node) const { |
| 105 int* stack_param_delta) const { | |
| 106 CallDescriptor const* other = CallDescriptorOf(node->op()); | |
| 107 size_t current_input = 0; | |
| 108 size_t other_input = 0; | |
| 109 *stack_param_delta = 0; | |
| 110 bool more_other = true; | |
| 111 bool more_this = true; | |
| 112 while (more_other || more_this) { | |
| 113 if (other_input < other->InputCount()) { | |
| 114 if (!other->GetInputLocation(other_input).IsRegister()) { | |
| 115 (*stack_param_delta)++; | |
| 116 } | |
| 117 } else { | |
| 118 more_other = false; | |
| 119 } | |
| 120 if (current_input < InputCount()) { | |
| 121 if (!GetInputLocation(current_input).IsRegister()) { | |
| 122 (*stack_param_delta)--; | |
| 123 } | |
| 124 } else { | |
| 125 more_this = false; | |
| 126 } | |
| 127 ++current_input; | |
| 128 ++other_input; | |
| 129 } | |
| 130 return HasSameReturnLocationsAs(CallDescriptorOf(node->op())); | 133 return HasSameReturnLocationsAs(CallDescriptorOf(node->op())); |
| 131 } | 134 } |
| 132 | 135 |
| 133 | 136 |
| 134 CallDescriptor* Linkage::ComputeIncoming(Zone* zone, CompilationInfo* info) { | 137 CallDescriptor* Linkage::ComputeIncoming(Zone* zone, CompilationInfo* info) { |
| 135 DCHECK(!info->IsStub()); | 138 DCHECK(!info->IsStub()); |
| 136 if (!info->closure().is_null()) { | 139 if (!info->closure().is_null()) { |
| 137 // If we are compiling a JS function, use a JS call descriptor, | 140 // If we are compiling a JS function, use a JS call descriptor, |
| 138 // plus the receiver. | 141 // plus the receiver. |
| 139 SharedFunctionInfo* shared = info->closure()->shared(); | 142 SharedFunctionInfo* shared = info->closure()->shared(); |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 DCHECK(loc == regloc(kContextRegister, MachineType::AnyTagged())); | 516 DCHECK(loc == regloc(kContextRegister, MachineType::AnyTagged())); |
| 514 return LinkageLocation::ForCalleeFrameSlot(Frame::kContextSlot, | 517 return LinkageLocation::ForCalleeFrameSlot(Frame::kContextSlot, |
| 515 MachineType::AnyTagged()); | 518 MachineType::AnyTagged()); |
| 516 } | 519 } |
| 517 } | 520 } |
| 518 | 521 |
| 519 | 522 |
| 520 } // namespace compiler | 523 } // namespace compiler |
| 521 } // namespace internal | 524 } // namespace internal |
| 522 } // namespace v8 | 525 } // namespace v8 |
| OLD | NEW |