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

Side by Side Diff: src/compiler/tail-call-optimization.cc

Issue 2473643002: Revert of [turbofan] Support variable size argument popping in TF-generated functions (Closed)
Patch Set: Created 4 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/simplified-lowering.cc ('k') | src/compiler/wasm-compiler.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/compiler/tail-call-optimization.h" 5 #include "src/compiler/tail-call-optimization.h"
6 6
7 #include "src/compiler/common-operator.h" 7 #include "src/compiler/common-operator.h"
8 #include "src/compiler/graph.h" 8 #include "src/compiler/graph.h"
9 #include "src/compiler/linkage.h" 9 #include "src/compiler/linkage.h"
10 #include "src/compiler/node-matchers.h"
11 #include "src/compiler/node-properties.h" 10 #include "src/compiler/node-properties.h"
12 11
13 namespace v8 { 12 namespace v8 {
14 namespace internal { 13 namespace internal {
15 namespace compiler { 14 namespace compiler {
16 15
17 Reduction TailCallOptimization::Reduce(Node* node) { 16 Reduction TailCallOptimization::Reduce(Node* node) {
18 if (node->opcode() != IrOpcode::kReturn) return NoChange(); 17 if (node->opcode() != IrOpcode::kReturn) return NoChange();
19 // The value which is returned must be the result of a potential tail call, 18 // The value which is returned must be the result of a potential tail call,
20 // there must be no try/catch/finally around the Call, and there must be no 19 // there must be no try/catch/finally around the Call, and there must be no
21 // other effect between the Call and the Return nodes. 20 // other effect between the Call and the Return nodes.
22 Node* const call = NodeProperties::GetValueInput(node, 1); 21 Node* const call = NodeProperties::GetValueInput(node, 0);
23 if (call->opcode() == IrOpcode::kCall && 22 if (call->opcode() == IrOpcode::kCall &&
24 CallDescriptorOf(call->op())->SupportsTailCalls() && 23 CallDescriptorOf(call->op())->SupportsTailCalls() &&
25 NodeProperties::GetEffectInput(node) == call && 24 NodeProperties::GetEffectInput(node) == call &&
26 !NodeProperties::IsExceptionalCall(call)) { 25 !NodeProperties::IsExceptionalCall(call)) {
27 Node* const control = NodeProperties::GetControlInput(node); 26 Node* const control = NodeProperties::GetControlInput(node);
28 // Ensure that no additional arguments are being popped other than those in
29 // the CallDescriptor, otherwise the tail call transformation is invalid.
30 DCHECK_EQ(0, Int32Matcher(NodeProperties::GetValueInput(node, 0)).Value());
31 if (control->opcode() == IrOpcode::kIfSuccess && 27 if (control->opcode() == IrOpcode::kIfSuccess &&
32 call->OwnedBy(node, control) && control->OwnedBy(node)) { 28 call->OwnedBy(node, control) && control->OwnedBy(node)) {
33 // Furthermore, control has to flow via an IfSuccess from the Call, so 29 // Furthermore, control has to flow via an IfSuccess from the Call, so
34 // the Return node value and effect depends directly on the Call node, 30 // the Return node value and effect depends directly on the Call node,
35 // and indirectly control depends on the Call via an IfSuccess. 31 // and indirectly control depends on the Call via an IfSuccess.
36 32
37 // Value1 ... ValueN Effect Control 33 // Value1 ... ValueN Effect Control
38 // ^ ^ ^ ^ 34 // ^ ^ ^ ^
39 // | | | | 35 // | | | |
40 // | +--+ +-+ | 36 // | +--+ +-+ |
(...skipping 18 matching lines...) Expand all
59 // ^ ^ ^ ^ 55 // ^ ^ ^ ^
60 // | | | | 56 // | | | |
61 // | +--+ +-+ | 57 // | +--+ +-+ |
62 // +----------+ | | +------+ 58 // +----------+ | | +------+
63 // \ | | / 59 // \ | | /
64 // TailCall[Descriptor] 60 // TailCall[Descriptor]
65 // ^ 61 // ^
66 // | 62 // |
67 63
68 DCHECK_EQ(call, NodeProperties::GetControlInput(control, 0)); 64 DCHECK_EQ(call, NodeProperties::GetControlInput(control, 0));
69 DCHECK_EQ(4, node->InputCount()); 65 DCHECK_EQ(3, node->InputCount());
70 node->ReplaceInput(0, NodeProperties::GetEffectInput(call)); 66 node->ReplaceInput(0, NodeProperties::GetEffectInput(call));
71 node->ReplaceInput(1, NodeProperties::GetControlInput(call)); 67 node->ReplaceInput(1, NodeProperties::GetControlInput(call));
72 node->RemoveInput(3);
73 node->RemoveInput(2); 68 node->RemoveInput(2);
74 for (int index = 0; index < call->op()->ValueInputCount(); ++index) { 69 for (int index = 0; index < call->op()->ValueInputCount(); ++index) {
75 node->InsertInput(graph()->zone(), index, 70 node->InsertInput(graph()->zone(), index,
76 NodeProperties::GetValueInput(call, index)); 71 NodeProperties::GetValueInput(call, index));
77 } 72 }
78 NodeProperties::ChangeOp( 73 NodeProperties::ChangeOp(
79 node, common()->TailCall(CallDescriptorOf(call->op()))); 74 node, common()->TailCall(CallDescriptorOf(call->op())));
80 return Changed(node); 75 return Changed(node);
81 } 76 }
82 } 77 }
83 return NoChange(); 78 return NoChange();
84 } 79 }
85 80
86 } // namespace compiler 81 } // namespace compiler
87 } // namespace internal 82 } // namespace internal
88 } // namespace v8 83 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/simplified-lowering.cc ('k') | src/compiler/wasm-compiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698