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

Unified Diff: src/compiler/linkage.cc

Issue 1245523002: [turbofan]: Fix tail calls edge cases and add tests (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@1220823004
Patch Set: Fix ASAN again Created 5 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 | « no previous file | 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 691a3b38614fce0d045bc86af0584ae8d5b876c0..a460f4a980bd19db7dd688b9677bc2916077ed58 100644
--- a/src/compiler/linkage.cc
+++ b/src/compiler/linkage.cc
@@ -53,6 +53,25 @@ bool CallDescriptor::HasSameReturnLocationsAs(
bool CallDescriptor::CanTailCall(const Node* node) const {
+ // Determine the number of stack parameters passed in
+ size_t stack_params = 0;
+ for (size_t i = 0; i < InputCount(); ++i) {
+ if (!GetInputLocation(i).is_register()) {
+ ++stack_params;
+ }
+ }
+ // Ensure the input linkage contains the stack parameters in the right order
+ size_t current_stack_param = 0;
+ for (size_t i = 0; i < InputCount(); ++i) {
+ if (!GetInputLocation(i).is_register()) {
+ if (GetInputLocation(i) !=
+ LinkageLocation(static_cast<int>(current_stack_param) -
+ static_cast<int>(stack_params))) {
+ return false;
+ }
+ ++current_stack_param;
+ }
+ }
// Tail calling is currently allowed if return locations match and all
// parameters are either in registers or on the stack but match exactly in
// number and content.
@@ -60,10 +79,9 @@ bool CallDescriptor::CanTailCall(const Node* node) const {
if (!HasSameReturnLocationsAs(other)) return false;
size_t current_input = 0;
size_t other_input = 0;
- size_t stack_parameter = 0;
while (true) {
if (other_input >= other->InputCount()) {
- while (current_input <= InputCount()) {
+ while (current_input < InputCount()) {
if (!GetInputLocation(current_input).is_register()) {
return false;
}
@@ -96,11 +114,12 @@ bool CallDescriptor::CanTailCall(const Node* node) const {
if (input->opcode() != IrOpcode::kParameter) {
return false;
}
+ // Make sure that the parameter input passed through to the tail call
+ // corresponds to the correct stack slot.
size_t param_index = ParameterIndexOf(input->op());
- if (param_index != stack_parameter) {
+ if (param_index != current_input - 1) {
return false;
}
- ++stack_parameter;
++current_input;
++other_input;
}
« no previous file with comments | « no previous file | test/unittests/compiler/linkage-tail-call-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698