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

Side by Side Diff: test/unittests/compiler/tail-call-optimization-unittest.cc

Issue 2446543002: [turbofan] Support variable size argument popping in TF-generated functions (Closed)
Patch Set: Fix tests and arm64 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 | « test/unittests/compiler/scheduler-unittest.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/linkage.h" 5 #include "src/compiler/linkage.h"
6 #include "src/compiler/tail-call-optimization.h" 6 #include "src/compiler/tail-call-optimization.h"
7 #include "test/unittests/compiler/graph-unittest.h" 7 #include "test/unittests/compiler/graph-unittest.h"
8 #include "test/unittests/compiler/node-test-utils.h" 8 #include "test/unittests/compiler/node-test-utils.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 21 matching lines...) Expand all
32 const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor( 32 const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor(
33 CallDescriptor::kCallCodeObject, MachineType::AnyTagged(), 33 CallDescriptor::kCallCodeObject, MachineType::AnyTagged(),
34 LinkageLocation::ForRegister(0, MachineType::Pointer()), 34 LinkageLocation::ForRegister(0, MachineType::Pointer()),
35 new (zone()) LocationSignature(1, 1, kLocationSignature), 0, 35 new (zone()) LocationSignature(1, 1, kLocationSignature), 0,
36 Operator::kNoProperties, 0, 0, CallDescriptor::kNoFlags); 36 Operator::kNoProperties, 0, 0, CallDescriptor::kNoFlags);
37 Node* p0 = Parameter(0); 37 Node* p0 = Parameter(0);
38 Node* p1 = Parameter(1); 38 Node* p1 = Parameter(1);
39 Node* call = graph()->NewNode(common()->Call(kCallDescriptor), p0, p1, 39 Node* call = graph()->NewNode(common()->Call(kCallDescriptor), p0, p1,
40 graph()->start(), graph()->start()); 40 graph()->start(), graph()->start());
41 Node* if_success = graph()->NewNode(common()->IfSuccess(), call); 41 Node* if_success = graph()->NewNode(common()->IfSuccess(), call);
42 Node* ret = graph()->NewNode(common()->Return(), call, call, if_success); 42 Node* zero = graph()->NewNode(common()->Int32Constant(0));
43 Node* ret =
44 graph()->NewNode(common()->Return(), zero, call, call, if_success);
43 Reduction r = Reduce(ret); 45 Reduction r = Reduce(ret);
44 ASSERT_FALSE(r.Changed()); 46 ASSERT_FALSE(r.Changed());
45 } 47 }
46 48
47 49
48 TEST_F(TailCallOptimizationTest, CallCodeObject1) { 50 TEST_F(TailCallOptimizationTest, CallCodeObject1) {
49 LinkageLocation kLocationSignature[] = { 51 LinkageLocation kLocationSignature[] = {
50 LinkageLocation::ForRegister(0, MachineType::Pointer()), 52 LinkageLocation::ForRegister(0, MachineType::Pointer()),
51 LinkageLocation::ForRegister(1, MachineType::Pointer())}; 53 LinkageLocation::ForRegister(1, MachineType::Pointer())};
52 const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor( 54 const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor(
53 CallDescriptor::kCallCodeObject, MachineType::AnyTagged(), 55 CallDescriptor::kCallCodeObject, MachineType::AnyTagged(),
54 LinkageLocation::ForRegister(0, MachineType::Pointer()), 56 LinkageLocation::ForRegister(0, MachineType::Pointer()),
55 new (zone()) LocationSignature(1, 1, kLocationSignature), 0, 57 new (zone()) LocationSignature(1, 1, kLocationSignature), 0,
56 Operator::kNoProperties, 0, 0, CallDescriptor::kSupportsTailCalls); 58 Operator::kNoProperties, 0, 0, CallDescriptor::kSupportsTailCalls);
57 Node* p0 = Parameter(0); 59 Node* p0 = Parameter(0);
58 Node* p1 = Parameter(1); 60 Node* p1 = Parameter(1);
59 Node* call = graph()->NewNode(common()->Call(kCallDescriptor), p0, p1, 61 Node* call = graph()->NewNode(common()->Call(kCallDescriptor), p0, p1,
60 graph()->start(), graph()->start()); 62 graph()->start(), graph()->start());
61 Node* if_success = graph()->NewNode(common()->IfSuccess(), call); 63 Node* if_success = graph()->NewNode(common()->IfSuccess(), call);
62 Node* if_exception = graph()->NewNode(common()->IfException(), call, call); 64 Node* if_exception = graph()->NewNode(common()->IfException(), call, call);
63 Node* ret = graph()->NewNode(common()->Return(), call, call, if_success); 65 Node* zero = graph()->NewNode(common()->Int32Constant(0));
66 Node* ret =
67 graph()->NewNode(common()->Return(), zero, call, call, if_success);
64 Node* end = graph()->NewNode(common()->End(1), if_exception); 68 Node* end = graph()->NewNode(common()->End(1), if_exception);
65 graph()->SetEnd(end); 69 graph()->SetEnd(end);
66 Reduction r = Reduce(ret); 70 Reduction r = Reduce(ret);
67 ASSERT_FALSE(r.Changed()); 71 ASSERT_FALSE(r.Changed());
68 } 72 }
69 73
70 74
71 TEST_F(TailCallOptimizationTest, CallCodeObject2) { 75 TEST_F(TailCallOptimizationTest, CallCodeObject2) {
72 LinkageLocation kLocationSignature[] = { 76 LinkageLocation kLocationSignature[] = {
73 LinkageLocation::ForRegister(0, MachineType::Pointer()), 77 LinkageLocation::ForRegister(0, MachineType::Pointer()),
74 LinkageLocation::ForRegister(1, MachineType::Pointer())}; 78 LinkageLocation::ForRegister(1, MachineType::Pointer())};
75 const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor( 79 const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor(
76 CallDescriptor::kCallCodeObject, MachineType::AnyTagged(), 80 CallDescriptor::kCallCodeObject, MachineType::AnyTagged(),
77 LinkageLocation::ForRegister(0, MachineType::Pointer()), 81 LinkageLocation::ForRegister(0, MachineType::Pointer()),
78 new (zone()) LocationSignature(1, 1, kLocationSignature), 0, 82 new (zone()) LocationSignature(1, 1, kLocationSignature), 0,
79 Operator::kNoProperties, 0, 0, CallDescriptor::kSupportsTailCalls); 83 Operator::kNoProperties, 0, 0, CallDescriptor::kSupportsTailCalls);
80 Node* p0 = Parameter(0); 84 Node* p0 = Parameter(0);
81 Node* p1 = Parameter(1); 85 Node* p1 = Parameter(1);
82 Node* call = graph()->NewNode(common()->Call(kCallDescriptor), p0, p1, 86 Node* call = graph()->NewNode(common()->Call(kCallDescriptor), p0, p1,
83 graph()->start(), graph()->start()); 87 graph()->start(), graph()->start());
84 Node* if_success = graph()->NewNode(common()->IfSuccess(), call); 88 Node* if_success = graph()->NewNode(common()->IfSuccess(), call);
85 Node* ret = graph()->NewNode(common()->Return(), call, call, if_success); 89 Node* zero = graph()->NewNode(common()->Int32Constant(0));
90 Node* ret =
91 graph()->NewNode(common()->Return(), zero, call, call, if_success);
86 Reduction r = Reduce(ret); 92 Reduction r = Reduce(ret);
87 ASSERT_TRUE(r.Changed()); 93 ASSERT_TRUE(r.Changed());
88 EXPECT_THAT(r.replacement(), IsTailCall(kCallDescriptor, p0, p1, 94 EXPECT_THAT(r.replacement(), IsTailCall(kCallDescriptor, p0, p1,
89 graph()->start(), graph()->start())); 95 graph()->start(), graph()->start()));
90 } 96 }
91 97
92 98
93 TEST_F(TailCallOptimizationTest, CallJSFunction0) { 99 TEST_F(TailCallOptimizationTest, CallJSFunction0) {
94 LinkageLocation kLocationSignature[] = { 100 LinkageLocation kLocationSignature[] = {
95 LinkageLocation::ForRegister(0, MachineType::Pointer()), 101 LinkageLocation::ForRegister(0, MachineType::Pointer()),
96 LinkageLocation::ForRegister(1, MachineType::Pointer())}; 102 LinkageLocation::ForRegister(1, MachineType::Pointer())};
97 const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor( 103 const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor(
98 CallDescriptor::kCallJSFunction, MachineType::AnyTagged(), 104 CallDescriptor::kCallJSFunction, MachineType::AnyTagged(),
99 LinkageLocation::ForRegister(0, MachineType::Pointer()), 105 LinkageLocation::ForRegister(0, MachineType::Pointer()),
100 new (zone()) LocationSignature(1, 1, kLocationSignature), 0, 106 new (zone()) LocationSignature(1, 1, kLocationSignature), 0,
101 Operator::kNoProperties, 0, 0, CallDescriptor::kNoFlags); 107 Operator::kNoProperties, 0, 0, CallDescriptor::kNoFlags);
102 Node* p0 = Parameter(0); 108 Node* p0 = Parameter(0);
103 Node* p1 = Parameter(1); 109 Node* p1 = Parameter(1);
104 Node* call = graph()->NewNode(common()->Call(kCallDescriptor), p0, p1, 110 Node* call = graph()->NewNode(common()->Call(kCallDescriptor), p0, p1,
105 graph()->start(), graph()->start()); 111 graph()->start(), graph()->start());
106 Node* if_success = graph()->NewNode(common()->IfSuccess(), call); 112 Node* if_success = graph()->NewNode(common()->IfSuccess(), call);
107 Node* ret = graph()->NewNode(common()->Return(), call, call, if_success); 113 Node* zero = graph()->NewNode(common()->Int32Constant(0));
114 Node* ret =
115 graph()->NewNode(common()->Return(), zero, call, call, if_success);
108 Reduction r = Reduce(ret); 116 Reduction r = Reduce(ret);
109 ASSERT_FALSE(r.Changed()); 117 ASSERT_FALSE(r.Changed());
110 } 118 }
111 119
112 120
113 TEST_F(TailCallOptimizationTest, CallJSFunction1) { 121 TEST_F(TailCallOptimizationTest, CallJSFunction1) {
114 LinkageLocation kLocationSignature[] = { 122 LinkageLocation kLocationSignature[] = {
115 LinkageLocation::ForRegister(0, MachineType::Pointer()), 123 LinkageLocation::ForRegister(0, MachineType::Pointer()),
116 LinkageLocation::ForRegister(1, MachineType::Pointer())}; 124 LinkageLocation::ForRegister(1, MachineType::Pointer())};
117 const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor( 125 const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor(
118 CallDescriptor::kCallJSFunction, MachineType::AnyTagged(), 126 CallDescriptor::kCallJSFunction, MachineType::AnyTagged(),
119 LinkageLocation::ForRegister(0), 127 LinkageLocation::ForRegister(0),
120 new (zone()) LocationSignature(1, 1, kLocationSignature), 0, 128 new (zone()) LocationSignature(1, 1, kLocationSignature), 0,
121 Operator::kNoProperties, 0, 0, CallDescriptor::kSupportsTailCalls); 129 Operator::kNoProperties, 0, 0, CallDescriptor::kSupportsTailCalls);
122 Node* p0 = Parameter(0); 130 Node* p0 = Parameter(0);
123 Node* p1 = Parameter(1); 131 Node* p1 = Parameter(1);
124 Node* call = graph()->NewNode(common()->Call(kCallDescriptor), p0, p1, 132 Node* call = graph()->NewNode(common()->Call(kCallDescriptor), p0, p1,
125 graph()->start(), graph()->start()); 133 graph()->start(), graph()->start());
126 Node* if_success = graph()->NewNode(common()->IfSuccess(), call); 134 Node* if_success = graph()->NewNode(common()->IfSuccess(), call);
127 Node* if_exception = graph()->NewNode(common()->IfException(), call, call); 135 Node* if_exception = graph()->NewNode(common()->IfException(), call, call);
128 Node* ret = graph()->NewNode(common()->Return(), call, call, if_success); 136 Node* zero = graph()->NewNode(common()->Int32Constant(0));
137 Node* ret =
138 graph()->NewNode(common()->Return(), zero, call, call, if_success);
129 Node* end = graph()->NewNode(common()->End(1), if_exception); 139 Node* end = graph()->NewNode(common()->End(1), if_exception);
130 graph()->SetEnd(end); 140 graph()->SetEnd(end);
131 Reduction r = Reduce(ret); 141 Reduction r = Reduce(ret);
132 ASSERT_FALSE(r.Changed()); 142 ASSERT_FALSE(r.Changed());
133 } 143 }
134 144
135 145
136 TEST_F(TailCallOptimizationTest, CallJSFunction2) { 146 TEST_F(TailCallOptimizationTest, CallJSFunction2) {
137 LinkageLocation kLocationSignature[] = {LinkageLocation::ForRegister(0), 147 LinkageLocation kLocationSignature[] = {LinkageLocation::ForRegister(0),
138 LinkageLocation::ForRegister(1)}; 148 LinkageLocation::ForRegister(1)};
139 const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor( 149 const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor(
140 CallDescriptor::kCallJSFunction, MachineType::AnyTagged(), 150 CallDescriptor::kCallJSFunction, MachineType::AnyTagged(),
141 LinkageLocation::ForRegister(0), 151 LinkageLocation::ForRegister(0),
142 new (zone()) LocationSignature(1, 1, kLocationSignature), 0, 152 new (zone()) LocationSignature(1, 1, kLocationSignature), 0,
143 Operator::kNoProperties, 0, 0, CallDescriptor::kSupportsTailCalls); 153 Operator::kNoProperties, 0, 0, CallDescriptor::kSupportsTailCalls);
144 Node* p0 = Parameter(0); 154 Node* p0 = Parameter(0);
145 Node* p1 = Parameter(1); 155 Node* p1 = Parameter(1);
146 Node* call = graph()->NewNode(common()->Call(kCallDescriptor), p0, p1, 156 Node* call = graph()->NewNode(common()->Call(kCallDescriptor), p0, p1,
147 graph()->start(), graph()->start()); 157 graph()->start(), graph()->start());
148 Node* if_success = graph()->NewNode(common()->IfSuccess(), call); 158 Node* if_success = graph()->NewNode(common()->IfSuccess(), call);
149 Node* ret = graph()->NewNode(common()->Return(), call, call, if_success); 159 Node* zero = graph()->NewNode(common()->Int32Constant(0));
160 Node* ret =
161 graph()->NewNode(common()->Return(), zero, call, call, if_success);
150 Reduction r = Reduce(ret); 162 Reduction r = Reduce(ret);
151 ASSERT_TRUE(r.Changed()); 163 ASSERT_TRUE(r.Changed());
152 EXPECT_THAT(r.replacement(), IsTailCall(kCallDescriptor, p0, p1, 164 EXPECT_THAT(r.replacement(), IsTailCall(kCallDescriptor, p0, p1,
153 graph()->start(), graph()->start())); 165 graph()->start(), graph()->start()));
154 } 166 }
155 167
156 168
157 } // namespace compiler 169 } // namespace compiler
158 } // namespace internal 170 } // namespace internal
159 } // namespace v8 171 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/scheduler-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698