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: test/cctest/compiler/codegen-tester.h

Issue 1423133005: Implemented the BufferedRawMachineAssemblerTester. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed the test case parameter values. 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 | « test/cctest/compiler/call-tester.h ('k') | test/cctest/compiler/codegen-tester.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 #ifndef V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ 5 #ifndef V8_CCTEST_COMPILER_CODEGEN_TESTER_H_
6 #define V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ 6 #define V8_CCTEST_COMPILER_CODEGEN_TESTER_H_
7 7
8 #include "src/compiler/instruction-selector.h" 8 #include "src/compiler/instruction-selector.h"
9 #include "src/compiler/pipeline.h" 9 #include "src/compiler/pipeline.h"
10 #include "src/compiler/raw-machine-assembler.h" 10 #include "src/compiler/raw-machine-assembler.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 schedule); 66 schedule);
67 } 67 }
68 return this->code_.ToHandleChecked()->entry(); 68 return this->code_.ToHandleChecked()->entry();
69 } 69 }
70 70
71 private: 71 private:
72 MaybeHandle<Code> code_; 72 MaybeHandle<Code> code_;
73 }; 73 };
74 74
75 75
76 template <typename ReturnType>
77 class BufferedRawMachineAssemblerTester
78 : public RawMachineAssemblerTester<int32_t> {
79 public:
80 BufferedRawMachineAssemblerTester()
81 : BufferedRawMachineAssemblerTester(0, kMachNone, kMachNone, kMachNone,
82 kMachNone) {}
83
84
85 explicit BufferedRawMachineAssemblerTester(MachineType p0)
86 : BufferedRawMachineAssemblerTester(1, p0, kMachNone, kMachNone,
87 kMachNone) {}
88
89
90 BufferedRawMachineAssemblerTester(MachineType p0, MachineType p1)
91 : BufferedRawMachineAssemblerTester(2, p0, p1, kMachNone, kMachNone) {}
92
93
94 BufferedRawMachineAssemblerTester(MachineType p0, MachineType p1,
95 MachineType p2)
96 : BufferedRawMachineAssemblerTester(3, p0, p1, p2, kMachNone) {}
97
98
99 BufferedRawMachineAssemblerTester(MachineType p0, MachineType p1,
100 MachineType p2, MachineType p3)
101 : BufferedRawMachineAssemblerTester(4, p0, p1, p2, p3) {}
102
103
104 // The BufferedRawMachineAssemblerTester does not pass parameters directly
105 // to the constructed IR graph. Instead it passes a pointer to the parameter
106 // to the IR graph, and adds Load nodes to the IR graph to load the
107 // parameters from memory. Thereby it is possible to pass 64 bit parameters
108 // to the IR graph.
109 Node* Parameter(size_t index) {
110 CHECK(index >= 0 && index < 4);
111 return parameter_nodes_[index];
112 }
113
114
115 // The BufferedRawMachineAssemblerTester adds a Store node to the IR graph
116 // to store the graph's return value in memory. The memory address for the
117 // Store node is provided as a parameter. By storing the return value in
118 // memory it is possible to return 64 bit values.
119 void Return(Node* input) {
120 Store(MachineTypeForC<ReturnType>(),
121 RawMachineAssembler::Parameter(return_parameter_index_), input,
122 kNoWriteBarrier);
123 RawMachineAssembler::Return(Int32Constant(1234));
124 }
125
126 ReturnType Call() {
127 ReturnType return_value;
128 test_graph_signature_->VerifyParams();
129 CallHelper<int32_t>::Call(reinterpret_cast<void*>(&return_value));
130 return return_value;
131 }
132
133 template <typename P0>
134 ReturnType Call(P0 p0) {
135 ReturnType return_value;
136 test_graph_signature_->VerifyParams<P0>();
137 CallHelper<int32_t>::Call(reinterpret_cast<void*>(&p0),
138 reinterpret_cast<void*>(&return_value));
139 return return_value;
140 }
141
142 template <typename P0, typename P1>
143 ReturnType Call(P0 p0, P1 p1) {
144 ReturnType return_value;
145 test_graph_signature_->VerifyParams<P0, P1>();
146 CallHelper<int32_t>::Call(reinterpret_cast<void*>(&p0),
147 reinterpret_cast<void*>(&p1),
148 reinterpret_cast<void*>(&return_value));
149 return return_value;
150 }
151
152 template <typename P0, typename P1, typename P2>
153 ReturnType Call(P0 p0, P1 p1, P2 p2) {
154 ReturnType return_value;
155 test_graph_signature_->VerifyParams<P0, P1, P2>();
156 CallHelper<int32_t>::Call(
157 reinterpret_cast<void*>(&p0), reinterpret_cast<void*>(&p1),
158 reinterpret_cast<void*>(&p2), reinterpret_cast<void*>(&return_value));
159 return return_value;
160 }
161
162 template <typename P0, typename P1, typename P2, typename P3>
163 ReturnType Call(P0 p0, P1 p1, P2 p2, P3 p3) {
164 ReturnType return_value;
165 test_graph_signature_->VerifyParams<P0, P1, P2, P3>();
166 CallHelper<int32_t>::Call(
167 reinterpret_cast<void*>(&p0), reinterpret_cast<void*>(&p1),
168 reinterpret_cast<void*>(&p2), reinterpret_cast<void*>(&p3),
169 reinterpret_cast<void*>(&return_value));
170 return return_value;
171 }
172
173 private:
174 BufferedRawMachineAssemblerTester(uint32_t return_parameter_index,
175 MachineType p0, MachineType p1,
176 MachineType p2, MachineType p3)
177 : RawMachineAssemblerTester<int32_t>(
178 kMachPtr, p0 == kMachNone ? kMachNone : kMachPtr,
179 p1 == kMachNone ? kMachNone : kMachPtr,
180 p2 == kMachNone ? kMachNone : kMachPtr,
181 p3 == kMachNone ? kMachNone : kMachPtr),
182 test_graph_signature_(
183 CSignature::New(main_zone(), kMachInt32, p0, p1, p2, p3)),
184 return_parameter_index_(return_parameter_index) {
185 parameter_nodes_[0] =
186 p0 == kMachNone ? nullptr : Load(p0, RawMachineAssembler::Parameter(0));
187 parameter_nodes_[1] =
188 p1 == kMachNone ? nullptr : Load(p1, RawMachineAssembler::Parameter(1));
189 parameter_nodes_[2] =
190 p2 == kMachNone ? nullptr : Load(p2, RawMachineAssembler::Parameter(2));
191 parameter_nodes_[3] =
192 p3 == kMachNone ? nullptr : Load(p3, RawMachineAssembler::Parameter(3));
193 }
194
195
196 CSignature* test_graph_signature_;
197 Node* parameter_nodes_[4];
198 uint32_t return_parameter_index_;
199 };
200
201
202 template <>
203 class BufferedRawMachineAssemblerTester<void>
204 : public RawMachineAssemblerTester<void> {
205 public:
206 BufferedRawMachineAssemblerTester(MachineType p0 = kMachNone,
207 MachineType p1 = kMachNone,
208 MachineType p2 = kMachNone,
209 MachineType p3 = kMachNone)
210 : RawMachineAssemblerTester<void>(p0 == kMachNone ? kMachNone : kMachPtr,
211 p1 == kMachNone ? kMachNone : kMachPtr,
212 p2 == kMachNone ? kMachNone : kMachPtr,
213 p3 == kMachNone ? kMachNone : kMachPtr),
214 test_graph_signature_(
215 CSignature::New(RawMachineAssemblerTester<void>::main_zone(),
216 kMachNone, p0, p1, p2, p3)) {
217 parameter_nodes_[0] =
218 p0 == kMachNone ? nullptr : Load(p0, RawMachineAssembler::Parameter(0));
219 parameter_nodes_[1] =
220 p1 == kMachNone ? nullptr : Load(p1, RawMachineAssembler::Parameter(1));
221 parameter_nodes_[2] =
222 p2 == kMachNone ? nullptr : Load(p2, RawMachineAssembler::Parameter(2));
223 parameter_nodes_[3] =
224 p3 == kMachNone ? nullptr : Load(p3, RawMachineAssembler::Parameter(3));
225 }
226
227
228 // The BufferedRawMachineAssemblerTester does not pass parameters directly
229 // to the constructed IR graph. Instead it passes a pointer to the parameter
230 // to the IR graph, and adds Load nodes to the IR graph to load the
231 // parameters from memory. Thereby it is possible to pass 64 bit parameters
232 // to the IR graph.
233 Node* Parameter(size_t index) {
234 CHECK(index >= 0 && index < 4);
235 return parameter_nodes_[index];
236 }
237
238
239 void Call() {
240 test_graph_signature_->VerifyParams();
241 CallHelper<void>::Call();
242 }
243
244 template <typename P0>
245 void Call(P0 p0) {
246 test_graph_signature_->VerifyParams<P0>();
247 CallHelper<void>::Call(reinterpret_cast<void*>(&p0));
248 }
249
250 template <typename P0, typename P1>
251 void Call(P0 p0, P1 p1) {
252 test_graph_signature_->VerifyParams<P0, P1>();
253 CallHelper<void>::Call(reinterpret_cast<void*>(&p0),
254 reinterpret_cast<void*>(&p1));
255 }
256
257 template <typename P0, typename P1, typename P2>
258 void Call(P0 p0, P1 p1, P2 p2) {
259 test_graph_signature_->VerifyParams<P0, P1, P2>();
260 CallHelper<void>::Call(reinterpret_cast<void*>(&p0),
261 reinterpret_cast<void*>(&p1),
262 reinterpret_cast<void*>(&p2));
263 }
264
265 template <typename P0, typename P1, typename P2, typename P3>
266 void Call(P0 p0, P1 p1, P2 p2, P3 p3) {
267 test_graph_signature_->VerifyParams<P0, P1, P2, P3>();
268 CallHelper<void>::Call(
269 reinterpret_cast<void*>(&p0), reinterpret_cast<void*>(&p1),
270 reinterpret_cast<void*>(&p2), reinterpret_cast<void*>(&p3));
271 }
272
273 private:
274 CSignature* test_graph_signature_;
275 Node* parameter_nodes_[4];
276 };
76 static const bool USE_RESULT_BUFFER = true; 277 static const bool USE_RESULT_BUFFER = true;
77 static const bool USE_RETURN_REGISTER = false; 278 static const bool USE_RETURN_REGISTER = false;
78 static const int32_t CHECK_VALUE = 0x99BEEDCE; 279 static const int32_t CHECK_VALUE = 0x99BEEDCE;
79 280
80 281
81 // TODO(titzer): use the C-style calling convention, or any register-based 282 // TODO(titzer): use the C-style calling convention, or any register-based
82 // calling convention for binop tests. 283 // calling convention for binop tests.
83 template <typename CType, MachineType rep, bool use_result_buffer> 284 template <typename CType, MachineType rep, bool use_result_buffer>
84 class BinopTester { 285 class BinopTester {
85 public: 286 public:
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 } else { 520 } else {
320 CHECK_EQ(x, y); 521 CHECK_EQ(x, y);
321 } 522 }
322 } 523 }
323 524
324 } // namespace compiler 525 } // namespace compiler
325 } // namespace internal 526 } // namespace internal
326 } // namespace v8 527 } // namespace v8
327 528
328 #endif // V8_CCTEST_COMPILER_CODEGEN_TESTER_H_ 529 #endif // V8_CCTEST_COMPILER_CODEGEN_TESTER_H_
OLDNEW
« no previous file with comments | « test/cctest/compiler/call-tester.h ('k') | test/cctest/compiler/codegen-tester.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698