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

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

Issue 1894983002: [turbofan] Introduce CallDescriptorOf helper for safety. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_issue-4924
Patch Set: Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « src/compiler/simplified-lowering.cc ('k') | no next file » | 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-properties.h" 10 #include "src/compiler/node-properties.h"
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace internal { 13 namespace internal {
14 namespace compiler { 14 namespace compiler {
15 15
16 Reduction TailCallOptimization::Reduce(Node* node) { 16 Reduction TailCallOptimization::Reduce(Node* node) {
17 if (node->opcode() != IrOpcode::kReturn) return NoChange(); 17 if (node->opcode() != IrOpcode::kReturn) return NoChange();
18 // 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,
19 // 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
20 // other effect between the Call and the Return nodes. 20 // other effect between the Call and the Return nodes.
21 Node* const call = NodeProperties::GetValueInput(node, 0); 21 Node* const call = NodeProperties::GetValueInput(node, 0);
22 if (call->opcode() == IrOpcode::kCall && 22 if (call->opcode() == IrOpcode::kCall &&
23 OpParameter<CallDescriptor const*>(call)->SupportsTailCalls() && 23 CallDescriptorOf(call->op())->SupportsTailCalls() &&
24 NodeProperties::GetEffectInput(node) == call && 24 NodeProperties::GetEffectInput(node) == call &&
25 !NodeProperties::IsExceptionalCall(call)) { 25 !NodeProperties::IsExceptionalCall(call)) {
26 Node* const control = NodeProperties::GetControlInput(node); 26 Node* const control = NodeProperties::GetControlInput(node);
27 if (control->opcode() == IrOpcode::kIfSuccess && 27 if (control->opcode() == IrOpcode::kIfSuccess &&
28 call->OwnedBy(node, control) && control->OwnedBy(node)) { 28 call->OwnedBy(node, control) && control->OwnedBy(node)) {
29 // 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
30 // 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,
31 // and indirectly control depends on the Call via an IfSuccess. 31 // and indirectly control depends on the Call via an IfSuccess.
32 32
33 // Value1 ... ValueN Effect Control 33 // Value1 ... ValueN Effect Control
(...skipping 30 matching lines...) Expand all
64 DCHECK_EQ(call, NodeProperties::GetControlInput(control, 0)); 64 DCHECK_EQ(call, NodeProperties::GetControlInput(control, 0));
65 DCHECK_EQ(3, node->InputCount()); 65 DCHECK_EQ(3, node->InputCount());
66 node->ReplaceInput(0, NodeProperties::GetEffectInput(call)); 66 node->ReplaceInput(0, NodeProperties::GetEffectInput(call));
67 node->ReplaceInput(1, NodeProperties::GetControlInput(call)); 67 node->ReplaceInput(1, NodeProperties::GetControlInput(call));
68 node->RemoveInput(2); 68 node->RemoveInput(2);
69 for (int index = 0; index < call->op()->ValueInputCount(); ++index) { 69 for (int index = 0; index < call->op()->ValueInputCount(); ++index) {
70 node->InsertInput(graph()->zone(), index, 70 node->InsertInput(graph()->zone(), index,
71 NodeProperties::GetValueInput(call, index)); 71 NodeProperties::GetValueInput(call, index));
72 } 72 }
73 NodeProperties::ChangeOp( 73 NodeProperties::ChangeOp(
74 node, common()->TailCall(OpParameter<CallDescriptor const*>(call))); 74 node, common()->TailCall(CallDescriptorOf(call->op())));
75 return Changed(node); 75 return Changed(node);
76 } 76 }
77 } 77 }
78 return NoChange(); 78 return NoChange();
79 } 79 }
80 80
81 } // namespace compiler 81 } // namespace compiler
82 } // namespace internal 82 } // namespace internal
83 } // namespace v8 83 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/simplified-lowering.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698