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

Side by Side Diff: src/compiler/linkage.cc

Issue 1455833004: [turbofan]: Implement tail calls with more callee than caller parameters (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Improve comment Created 5 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « src/compiler/linkage.h ('k') | src/compiler/mips/code-generator-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/code-stubs.h" 5 #include "src/code-stubs.h"
6 #include "src/compiler.h" 6 #include "src/compiler.h"
7 #include "src/compiler/common-operator.h" 7 #include "src/compiler/common-operator.h"
8 #include "src/compiler/frame.h" 8 #include "src/compiler/frame.h"
9 #include "src/compiler/linkage.h" 9 #include "src/compiler/linkage.h"
10 #include "src/compiler/node.h" 10 #include "src/compiler/node.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 if (ReturnCount() != other->ReturnCount()) return false; 84 if (ReturnCount() != other->ReturnCount()) return false;
85 for (size_t i = 0; i < ReturnCount(); ++i) { 85 for (size_t i = 0; i < ReturnCount(); ++i) {
86 if (GetReturnLocation(i) != other->GetReturnLocation(i)) return false; 86 if (GetReturnLocation(i) != other->GetReturnLocation(i)) return false;
87 } 87 }
88 return true; 88 return true;
89 } 89 }
90 90
91 91
92 bool CallDescriptor::CanTailCall(const Node* node, 92 bool CallDescriptor::CanTailCall(const Node* node,
93 int* stack_param_delta) const { 93 int* stack_param_delta) const {
94 // TODO(danno): TF only current supports tail calls where the number of stack
95 // parameters of the callee is the same or fewer of the caller.
96 CallDescriptor const* other = OpParameter<CallDescriptor const*>(node); 94 CallDescriptor const* other = OpParameter<CallDescriptor const*>(node);
97 if (!HasSameReturnLocationsAs(other)) return false;
98 size_t current_input = 0; 95 size_t current_input = 0;
99 size_t other_input = 0; 96 size_t other_input = 0;
100 *stack_param_delta = 0; 97 *stack_param_delta = 0;
101 bool more_other = true; 98 bool more_other = true;
102 bool more_this = true; 99 bool more_this = true;
103 while (more_other || more_this) { 100 while (more_other || more_this) {
104 if (other_input < other->InputCount()) { 101 if (other_input < other->InputCount()) {
105 if (!other->GetInputLocation(other_input).IsRegister()) { 102 if (!other->GetInputLocation(other_input).IsRegister()) {
106 (*stack_param_delta)++; 103 (*stack_param_delta)--;
107 } 104 }
108 } else { 105 } else {
109 more_other = false; 106 more_other = false;
110 } 107 }
111 if (current_input < InputCount()) { 108 if (current_input < InputCount()) {
112 if (!GetInputLocation(current_input).IsRegister()) { 109 if (!GetInputLocation(current_input).IsRegister()) {
113 (*stack_param_delta)--; 110 (*stack_param_delta)++;
114 } 111 }
115 } else { 112 } else {
116 more_this = false; 113 more_this = false;
117 } 114 }
118 ++current_input; 115 ++current_input;
119 ++other_input; 116 ++other_input;
120 } 117 }
121 return *stack_param_delta <= 0; 118 return HasSameReturnLocationsAs(OpParameter<CallDescriptor const*>(node));
122 } 119 }
123 120
124 121
125 CallDescriptor* Linkage::ComputeIncoming(Zone* zone, CompilationInfo* info) { 122 CallDescriptor* Linkage::ComputeIncoming(Zone* zone, CompilationInfo* info) {
126 if (info->code_stub() != NULL) { 123 if (info->code_stub() != NULL) {
127 // Use the code stub interface descriptor. 124 // Use the code stub interface descriptor.
128 CodeStub* stub = info->code_stub(); 125 CodeStub* stub = info->code_stub();
129 CallInterfaceDescriptor descriptor = stub->GetCallInterfaceDescriptor(); 126 CallInterfaceDescriptor descriptor = stub->GetCallInterfaceDescriptor();
130 return GetStubCallDescriptor( 127 return GetStubCallDescriptor(
131 info->isolate(), zone, descriptor, stub->GetStackParameterCount(), 128 info->isolate(), zone, descriptor, stub->GetStackParameterCount(),
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 } else { 537 } else {
541 DCHECK(loc == regloc(kContextRegister)); 538 DCHECK(loc == regloc(kContextRegister));
542 return LinkageLocation::ForCalleeFrameSlot(Frame::kContextSlot); 539 return LinkageLocation::ForCalleeFrameSlot(Frame::kContextSlot);
543 } 540 }
544 } 541 }
545 542
546 543
547 } // namespace compiler 544 } // namespace compiler
548 } // namespace internal 545 } // namespace internal
549 } // namespace v8 546 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/linkage.h ('k') | src/compiler/mips/code-generator-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698