diff options
Diffstat (limited to 'deps/v8/src/compiler/linkage.cc')
-rw-r--r-- | deps/v8/src/compiler/linkage.cc | 41 |
1 files changed, 25 insertions, 16 deletions
diff --git a/deps/v8/src/compiler/linkage.cc b/deps/v8/src/compiler/linkage.cc index 03b8074f0f..5df50e64f5 100644 --- a/deps/v8/src/compiler/linkage.cc +++ b/deps/v8/src/compiler/linkage.cc @@ -75,33 +75,42 @@ bool CallDescriptor::HasSameReturnLocationsAs( return true; } -int CallDescriptor::GetStackParameterDelta( - CallDescriptor const* tail_caller) const { - int callee_slots_above_sp = 0; +int CallDescriptor::GetFirstUnusedStackSlot() const { + int slots_above_sp = 0; for (size_t i = 0; i < InputCount(); ++i) { LinkageLocation operand = GetInputLocation(i); if (!operand.IsRegister()) { int new_candidate = -operand.GetLocation() + operand.GetSizeInPointers() - 1; - if (new_candidate > callee_slots_above_sp) { - callee_slots_above_sp = new_candidate; + if (new_candidate > slots_above_sp) { + slots_above_sp = new_candidate; } } } - int tail_caller_slots_above_sp = 0; - if (tail_caller != nullptr) { - for (size_t i = 0; i < tail_caller->InputCount(); ++i) { - LinkageLocation operand = tail_caller->GetInputLocation(i); - if (!operand.IsRegister()) { - int new_candidate = - -operand.GetLocation() + operand.GetSizeInPointers() - 1; - if (new_candidate > tail_caller_slots_above_sp) { - tail_caller_slots_above_sp = new_candidate; - } + return slots_above_sp; +} + +int CallDescriptor::GetStackParameterDelta( + CallDescriptor const* tail_caller) const { + int callee_slots_above_sp = GetFirstUnusedStackSlot(); + int tail_caller_slots_above_sp = tail_caller->GetFirstUnusedStackSlot(); + int stack_param_delta = callee_slots_above_sp - tail_caller_slots_above_sp; + if (kPadArguments) { + // Adjust stack delta when it is odd. + if (stack_param_delta % 2 != 0) { + if (callee_slots_above_sp % 2 != 0) { + // The delta is odd due to the callee - we will need to add one slot + // of padding. + ++stack_param_delta; + } else { + // The delta is odd because of the caller. We already have one slot of + // padding that we can reuse for arguments, so we will need one fewer + // slot. + --stack_param_delta; } } } - return callee_slots_above_sp - tail_caller_slots_above_sp; + return stack_param_delta; } bool CallDescriptor::CanTailCall(const Node* node) const { |