Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Unified Diff: src/compiler/linkage.cc

Issue 2121753002: [turbofan] Robustify tail parameter stack size computations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix windows build Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/linkage.h ('k') | test/unittests/compiler/linkage-tail-call-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/linkage.cc
diff --git a/src/compiler/linkage.cc b/src/compiler/linkage.cc
index 1fe62f2ccffe595f0809db771a1644244cd47dc2..f0f12f7395121df69d04820b3fbd04e87d771686 100644
--- a/src/compiler/linkage.cc
+++ b/src/compiler/linkage.cc
@@ -100,33 +100,36 @@ bool CallDescriptor::HasSameReturnLocationsAs(
return true;
}
-
-bool CallDescriptor::CanTailCall(const Node* node,
- int* stack_param_delta) const {
- CallDescriptor const* other = CallDescriptorOf(node->op());
- size_t current_input = 0;
- size_t other_input = 0;
- *stack_param_delta = 0;
- bool more_other = true;
- bool more_this = true;
- while (more_other || more_this) {
- if (other_input < other->InputCount()) {
- if (!other->GetInputLocation(other_input).IsRegister()) {
- (*stack_param_delta)++;
+int CallDescriptor::GetStackParameterDelta(
+ CallDescriptor const* tail_caller) const {
+ int callee_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;
}
- } else {
- more_other = false;
}
- if (current_input < InputCount()) {
- if (!GetInputLocation(current_input).IsRegister()) {
- (*stack_param_delta)--;
+ }
+ 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;
+ }
}
- } else {
- more_this = false;
}
- ++current_input;
- ++other_input;
}
+ return callee_slots_above_sp - tail_caller_slots_above_sp;
+}
+
+bool CallDescriptor::CanTailCall(const Node* node) const {
return HasSameReturnLocationsAs(CallDescriptorOf(node->op()));
}
« no previous file with comments | « src/compiler/linkage.h ('k') | test/unittests/compiler/linkage-tail-call-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698