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

Side by Side Diff: test/cctest/compiler/codegen-tester.cc

Issue 426233002: Land the Fan (disabled) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback, rebase and "git cl format" Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « test/cctest/compiler/codegen-tester.h ('k') | test/cctest/compiler/compiler/call-tester.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "src/v8.h"
6
7 #include "test/cctest/cctest.h"
8 #include "test/cctest/compiler/codegen-tester.h"
9 #include "test/cctest/compiler/value-helper.h"
10
11 using namespace v8::internal;
12 using namespace v8::internal::compiler;
13
14 TEST(CompareWrapper) {
15 // Who tests the testers?
16 // If CompareWrapper is broken, then test expectations will be broken.
17 RawMachineAssemblerTester<int32_t> m;
18 CompareWrapper wWord32Equal(IrOpcode::kWord32Equal);
19 CompareWrapper wInt32LessThan(IrOpcode::kInt32LessThan);
20 CompareWrapper wInt32LessThanOrEqual(IrOpcode::kInt32LessThanOrEqual);
21 CompareWrapper wUint32LessThan(IrOpcode::kUint32LessThan);
22 CompareWrapper wUint32LessThanOrEqual(IrOpcode::kUint32LessThanOrEqual);
23
24 {
25 FOR_INT32_INPUTS(pl) {
26 FOR_INT32_INPUTS(pr) {
27 int32_t a = *pl;
28 int32_t b = *pr;
29 CHECK_EQ(a == b, wWord32Equal.Int32Compare(a, b));
30 CHECK_EQ(a < b, wInt32LessThan.Int32Compare(a, b));
31 CHECK_EQ(a <= b, wInt32LessThanOrEqual.Int32Compare(a, b));
32 }
33 }
34 }
35
36 {
37 FOR_UINT32_INPUTS(pl) {
38 FOR_UINT32_INPUTS(pr) {
39 uint32_t a = *pl;
40 uint32_t b = *pr;
41 CHECK_EQ(a == b, wWord32Equal.Int32Compare(a, b));
42 CHECK_EQ(a < b, wUint32LessThan.Int32Compare(a, b));
43 CHECK_EQ(a <= b, wUint32LessThanOrEqual.Int32Compare(a, b));
44 }
45 }
46 }
47
48 CHECK_EQ(true, wWord32Equal.Int32Compare(0, 0));
49 CHECK_EQ(true, wWord32Equal.Int32Compare(257, 257));
50 CHECK_EQ(true, wWord32Equal.Int32Compare(65539, 65539));
51 CHECK_EQ(true, wWord32Equal.Int32Compare(-1, -1));
52 CHECK_EQ(true, wWord32Equal.Int32Compare(0xffffffff, 0xffffffff));
53
54 CHECK_EQ(false, wWord32Equal.Int32Compare(0, 1));
55 CHECK_EQ(false, wWord32Equal.Int32Compare(257, 256));
56 CHECK_EQ(false, wWord32Equal.Int32Compare(65539, 65537));
57 CHECK_EQ(false, wWord32Equal.Int32Compare(-1, -2));
58 CHECK_EQ(false, wWord32Equal.Int32Compare(0xffffffff, 0xfffffffe));
59
60 CHECK_EQ(false, wInt32LessThan.Int32Compare(0, 0));
61 CHECK_EQ(false, wInt32LessThan.Int32Compare(357, 357));
62 CHECK_EQ(false, wInt32LessThan.Int32Compare(75539, 75539));
63 CHECK_EQ(false, wInt32LessThan.Int32Compare(-1, -1));
64 CHECK_EQ(false, wInt32LessThan.Int32Compare(0xffffffff, 0xffffffff));
65
66 CHECK_EQ(true, wInt32LessThan.Int32Compare(0, 1));
67 CHECK_EQ(true, wInt32LessThan.Int32Compare(456, 457));
68 CHECK_EQ(true, wInt32LessThan.Int32Compare(85537, 85539));
69 CHECK_EQ(true, wInt32LessThan.Int32Compare(-2, -1));
70 CHECK_EQ(true, wInt32LessThan.Int32Compare(0xfffffffe, 0xffffffff));
71
72 CHECK_EQ(false, wInt32LessThan.Int32Compare(1, 0));
73 CHECK_EQ(false, wInt32LessThan.Int32Compare(457, 456));
74 CHECK_EQ(false, wInt32LessThan.Int32Compare(85539, 85537));
75 CHECK_EQ(false, wInt32LessThan.Int32Compare(-1, -2));
76 CHECK_EQ(false, wInt32LessThan.Int32Compare(0xffffffff, 0xfffffffe));
77
78 CHECK_EQ(true, wInt32LessThanOrEqual.Int32Compare(0, 0));
79 CHECK_EQ(true, wInt32LessThanOrEqual.Int32Compare(357, 357));
80 CHECK_EQ(true, wInt32LessThanOrEqual.Int32Compare(75539, 75539));
81 CHECK_EQ(true, wInt32LessThanOrEqual.Int32Compare(-1, -1));
82 CHECK_EQ(true, wInt32LessThanOrEqual.Int32Compare(0xffffffff, 0xffffffff));
83
84 CHECK_EQ(true, wInt32LessThanOrEqual.Int32Compare(0, 1));
85 CHECK_EQ(true, wInt32LessThanOrEqual.Int32Compare(456, 457));
86 CHECK_EQ(true, wInt32LessThanOrEqual.Int32Compare(85537, 85539));
87 CHECK_EQ(true, wInt32LessThanOrEqual.Int32Compare(-2, -1));
88 CHECK_EQ(true, wInt32LessThanOrEqual.Int32Compare(0xfffffffe, 0xffffffff));
89
90 CHECK_EQ(false, wInt32LessThanOrEqual.Int32Compare(1, 0));
91 CHECK_EQ(false, wInt32LessThanOrEqual.Int32Compare(457, 456));
92 CHECK_EQ(false, wInt32LessThanOrEqual.Int32Compare(85539, 85537));
93 CHECK_EQ(false, wInt32LessThanOrEqual.Int32Compare(-1, -2));
94 CHECK_EQ(false, wInt32LessThanOrEqual.Int32Compare(0xffffffff, 0xfffffffe));
95
96 // Unsigned comparisons.
97 CHECK_EQ(false, wUint32LessThan.Int32Compare(0, 0));
98 CHECK_EQ(false, wUint32LessThan.Int32Compare(357, 357));
99 CHECK_EQ(false, wUint32LessThan.Int32Compare(75539, 75539));
100 CHECK_EQ(false, wUint32LessThan.Int32Compare(-1, -1));
101 CHECK_EQ(false, wUint32LessThan.Int32Compare(0xffffffff, 0xffffffff));
102 CHECK_EQ(false, wUint32LessThan.Int32Compare(0xffffffff, 0));
103 CHECK_EQ(false, wUint32LessThan.Int32Compare(-2999, 0));
104
105 CHECK_EQ(true, wUint32LessThan.Int32Compare(0, 1));
106 CHECK_EQ(true, wUint32LessThan.Int32Compare(456, 457));
107 CHECK_EQ(true, wUint32LessThan.Int32Compare(85537, 85539));
108 CHECK_EQ(true, wUint32LessThan.Int32Compare(-11, -10));
109 CHECK_EQ(true, wUint32LessThan.Int32Compare(0xfffffffe, 0xffffffff));
110 CHECK_EQ(true, wUint32LessThan.Int32Compare(0, 0xffffffff));
111 CHECK_EQ(true, wUint32LessThan.Int32Compare(0, -2996));
112
113 CHECK_EQ(false, wUint32LessThan.Int32Compare(1, 0));
114 CHECK_EQ(false, wUint32LessThan.Int32Compare(457, 456));
115 CHECK_EQ(false, wUint32LessThan.Int32Compare(85539, 85537));
116 CHECK_EQ(false, wUint32LessThan.Int32Compare(-10, -21));
117 CHECK_EQ(false, wUint32LessThan.Int32Compare(0xffffffff, 0xfffffffe));
118
119 CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(0, 0));
120 CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(357, 357));
121 CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(75539, 75539));
122 CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(-1, -1));
123 CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(0xffffffff, 0xffffffff));
124
125 CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(0, 1));
126 CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(456, 457));
127 CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(85537, 85539));
128 CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(-300, -299));
129 CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(-300, -300));
130 CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(0xfffffffe, 0xffffffff));
131 CHECK_EQ(true, wUint32LessThanOrEqual.Int32Compare(0, -2995));
132
133 CHECK_EQ(false, wUint32LessThanOrEqual.Int32Compare(1, 0));
134 CHECK_EQ(false, wUint32LessThanOrEqual.Int32Compare(457, 456));
135 CHECK_EQ(false, wUint32LessThanOrEqual.Int32Compare(85539, 85537));
136 CHECK_EQ(false, wUint32LessThanOrEqual.Int32Compare(-130, -170));
137 CHECK_EQ(false, wUint32LessThanOrEqual.Int32Compare(0xffffffff, 0xfffffffe));
138 CHECK_EQ(false, wUint32LessThanOrEqual.Int32Compare(-2997, 0));
139
140 CompareWrapper wFloat64Equal(IrOpcode::kFloat64Equal);
141 CompareWrapper wFloat64LessThan(IrOpcode::kFloat64LessThan);
142 CompareWrapper wFloat64LessThanOrEqual(IrOpcode::kFloat64LessThanOrEqual);
143
144 // Check NaN handling.
145 double nan = v8::base::OS::nan_value();
146 double inf = V8_INFINITY;
147 CHECK_EQ(false, wFloat64Equal.Float64Compare(nan, 0.0));
148 CHECK_EQ(false, wFloat64Equal.Float64Compare(nan, 1.0));
149 CHECK_EQ(false, wFloat64Equal.Float64Compare(nan, inf));
150 CHECK_EQ(false, wFloat64Equal.Float64Compare(nan, -inf));
151 CHECK_EQ(false, wFloat64Equal.Float64Compare(nan, nan));
152
153 CHECK_EQ(false, wFloat64Equal.Float64Compare(0.0, nan));
154 CHECK_EQ(false, wFloat64Equal.Float64Compare(1.0, nan));
155 CHECK_EQ(false, wFloat64Equal.Float64Compare(inf, nan));
156 CHECK_EQ(false, wFloat64Equal.Float64Compare(-inf, nan));
157 CHECK_EQ(false, wFloat64Equal.Float64Compare(nan, nan));
158
159 CHECK_EQ(false, wFloat64LessThan.Float64Compare(nan, 0.0));
160 CHECK_EQ(false, wFloat64LessThan.Float64Compare(nan, 1.0));
161 CHECK_EQ(false, wFloat64LessThan.Float64Compare(nan, inf));
162 CHECK_EQ(false, wFloat64LessThan.Float64Compare(nan, -inf));
163 CHECK_EQ(false, wFloat64LessThan.Float64Compare(nan, nan));
164
165 CHECK_EQ(false, wFloat64LessThan.Float64Compare(0.0, nan));
166 CHECK_EQ(false, wFloat64LessThan.Float64Compare(1.0, nan));
167 CHECK_EQ(false, wFloat64LessThan.Float64Compare(inf, nan));
168 CHECK_EQ(false, wFloat64LessThan.Float64Compare(-inf, nan));
169 CHECK_EQ(false, wFloat64LessThan.Float64Compare(nan, nan));
170
171 CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(nan, 0.0));
172 CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(nan, 1.0));
173 CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(nan, inf));
174 CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(nan, -inf));
175 CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(nan, nan));
176
177 CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(0.0, nan));
178 CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(1.0, nan));
179 CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(inf, nan));
180 CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(-inf, nan));
181 CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(nan, nan));
182
183 // Check inf handling.
184 CHECK_EQ(false, wFloat64Equal.Float64Compare(inf, 0.0));
185 CHECK_EQ(false, wFloat64Equal.Float64Compare(inf, 1.0));
186 CHECK_EQ(true, wFloat64Equal.Float64Compare(inf, inf));
187 CHECK_EQ(false, wFloat64Equal.Float64Compare(inf, -inf));
188
189 CHECK_EQ(false, wFloat64Equal.Float64Compare(0.0, inf));
190 CHECK_EQ(false, wFloat64Equal.Float64Compare(1.0, inf));
191 CHECK_EQ(true, wFloat64Equal.Float64Compare(inf, inf));
192 CHECK_EQ(false, wFloat64Equal.Float64Compare(-inf, inf));
193
194 CHECK_EQ(false, wFloat64LessThan.Float64Compare(inf, 0.0));
195 CHECK_EQ(false, wFloat64LessThan.Float64Compare(inf, 1.0));
196 CHECK_EQ(false, wFloat64LessThan.Float64Compare(inf, inf));
197 CHECK_EQ(false, wFloat64LessThan.Float64Compare(inf, -inf));
198
199 CHECK_EQ(true, wFloat64LessThan.Float64Compare(0.0, inf));
200 CHECK_EQ(true, wFloat64LessThan.Float64Compare(1.0, inf));
201 CHECK_EQ(false, wFloat64LessThan.Float64Compare(inf, inf));
202 CHECK_EQ(true, wFloat64LessThan.Float64Compare(-inf, inf));
203
204 CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(inf, 0.0));
205 CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(inf, 1.0));
206 CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(inf, inf));
207 CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(inf, -inf));
208
209 CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(0.0, inf));
210 CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(1.0, inf));
211 CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(inf, inf));
212 CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(-inf, inf));
213
214 // Check -inf handling.
215 CHECK_EQ(false, wFloat64Equal.Float64Compare(-inf, 0.0));
216 CHECK_EQ(false, wFloat64Equal.Float64Compare(-inf, 1.0));
217 CHECK_EQ(false, wFloat64Equal.Float64Compare(-inf, inf));
218 CHECK_EQ(true, wFloat64Equal.Float64Compare(-inf, -inf));
219
220 CHECK_EQ(false, wFloat64Equal.Float64Compare(0.0, -inf));
221 CHECK_EQ(false, wFloat64Equal.Float64Compare(1.0, -inf));
222 CHECK_EQ(false, wFloat64Equal.Float64Compare(inf, -inf));
223 CHECK_EQ(true, wFloat64Equal.Float64Compare(-inf, -inf));
224
225 CHECK_EQ(true, wFloat64LessThan.Float64Compare(-inf, 0.0));
226 CHECK_EQ(true, wFloat64LessThan.Float64Compare(-inf, 1.0));
227 CHECK_EQ(true, wFloat64LessThan.Float64Compare(-inf, inf));
228 CHECK_EQ(false, wFloat64LessThan.Float64Compare(-inf, -inf));
229
230 CHECK_EQ(false, wFloat64LessThan.Float64Compare(0.0, -inf));
231 CHECK_EQ(false, wFloat64LessThan.Float64Compare(1.0, -inf));
232 CHECK_EQ(false, wFloat64LessThan.Float64Compare(inf, -inf));
233 CHECK_EQ(false, wFloat64LessThan.Float64Compare(-inf, -inf));
234
235 CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(-inf, 0.0));
236 CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(-inf, 1.0));
237 CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(-inf, inf));
238 CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(-inf, -inf));
239
240 CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(0.0, -inf));
241 CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(1.0, -inf));
242 CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(inf, -inf));
243 CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(-inf, -inf));
244
245 // Check basic values.
246 CHECK_EQ(true, wFloat64Equal.Float64Compare(0, 0));
247 CHECK_EQ(true, wFloat64Equal.Float64Compare(257.1, 257.1));
248 CHECK_EQ(true, wFloat64Equal.Float64Compare(65539.1, 65539.1));
249 CHECK_EQ(true, wFloat64Equal.Float64Compare(-1.1, -1.1));
250
251 CHECK_EQ(false, wFloat64Equal.Float64Compare(0, 1));
252 CHECK_EQ(false, wFloat64Equal.Float64Compare(257.2, 256.2));
253 CHECK_EQ(false, wFloat64Equal.Float64Compare(65539.2, 65537.2));
254 CHECK_EQ(false, wFloat64Equal.Float64Compare(-1.2, -2.2));
255
256 CHECK_EQ(false, wFloat64LessThan.Float64Compare(0, 0));
257 CHECK_EQ(false, wFloat64LessThan.Float64Compare(357.3, 357.3));
258 CHECK_EQ(false, wFloat64LessThan.Float64Compare(75539.3, 75539.3));
259 CHECK_EQ(false, wFloat64LessThan.Float64Compare(-1.3, -1.3));
260
261 CHECK_EQ(true, wFloat64LessThan.Float64Compare(0, 1));
262 CHECK_EQ(true, wFloat64LessThan.Float64Compare(456.4, 457.4));
263 CHECK_EQ(true, wFloat64LessThan.Float64Compare(85537.4, 85539.4));
264 CHECK_EQ(true, wFloat64LessThan.Float64Compare(-2.4, -1.4));
265
266 CHECK_EQ(false, wFloat64LessThan.Float64Compare(1, 0));
267 CHECK_EQ(false, wFloat64LessThan.Float64Compare(457.5, 456.5));
268 CHECK_EQ(false, wFloat64LessThan.Float64Compare(85539.5, 85537.5));
269 CHECK_EQ(false, wFloat64LessThan.Float64Compare(-1.5, -2.5));
270
271 CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(0, 0));
272 CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(357.6, 357.6));
273 CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(75539.6, 75539.6));
274 CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(-1.6, -1.6));
275
276 CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(0, 1));
277 CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(456.7, 457.7));
278 CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(85537.7, 85539.7));
279 CHECK_EQ(true, wFloat64LessThanOrEqual.Float64Compare(-2.7, -1.7));
280
281 CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(1, 0));
282 CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(457.8, 456.8));
283 CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(85539.8, 85537.8));
284 CHECK_EQ(false, wFloat64LessThanOrEqual.Float64Compare(-1.8, -2.8));
285 }
286
287
288 void Int32BinopInputShapeTester::TestAllInputShapes() {
289 std::vector<int32_t> inputs = ValueHelper::int32_vector();
290 int num_int_inputs = static_cast<int>(inputs.size());
291 if (num_int_inputs > 16) num_int_inputs = 16; // limit to 16 inputs
292
293 for (int i = -2; i < num_int_inputs; i++) { // for all left shapes
294 for (int j = -2; j < num_int_inputs; j++) { // for all right shapes
295 if (i >= 0 && j >= 0) break; // No constant/constant combos
296 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32);
297 Node* p0 = m.Parameter(0);
298 Node* p1 = m.Parameter(1);
299 Node* n0;
300 Node* n1;
301
302 // left = Parameter | Load | Constant
303 if (i == -2) {
304 n0 = p0;
305 } else if (i == -1) {
306 n0 = m.LoadFromPointer(&input_a, kMachineWord32);
307 } else {
308 n0 = m.Int32Constant(inputs[i]);
309 }
310
311 // right = Parameter | Load | Constant
312 if (j == -2) {
313 n1 = p1;
314 } else if (j == -1) {
315 n1 = m.LoadFromPointer(&input_b, kMachineWord32);
316 } else {
317 n1 = m.Int32Constant(inputs[j]);
318 }
319
320 gen->gen(&m, n0, n1);
321
322 if (false) printf("Int32BinopInputShapeTester i=%d, j=%d\n", i, j);
323 if (i >= 0) {
324 input_a = inputs[i];
325 RunRight(&m);
326 } else if (j >= 0) {
327 input_b = inputs[j];
328 RunLeft(&m);
329 } else {
330 Run(&m);
331 }
332 }
333 }
334 }
335
336
337 void Int32BinopInputShapeTester::Run(RawMachineAssemblerTester<int32_t>* m) {
338 FOR_INT32_INPUTS(pl) {
339 FOR_INT32_INPUTS(pr) {
340 input_a = *pl;
341 input_b = *pr;
342 int32_t expect = gen->expected(input_a, input_b);
343 if (false) printf(" cmp(a=%d, b=%d) ?== %d\n", input_a, input_b, expect);
344 CHECK_EQ(expect, m->Call(input_a, input_b));
345 }
346 }
347 }
348
349
350 void Int32BinopInputShapeTester::RunLeft(
351 RawMachineAssemblerTester<int32_t>* m) {
352 FOR_UINT32_INPUTS(i) {
353 input_a = *i;
354 int32_t expect = gen->expected(input_a, input_b);
355 if (false) printf(" cmp(a=%d, b=%d) ?== %d\n", input_a, input_b, expect);
356 CHECK_EQ(expect, m->Call(input_a, input_b));
357 }
358 }
359
360
361 void Int32BinopInputShapeTester::RunRight(
362 RawMachineAssemblerTester<int32_t>* m) {
363 FOR_UINT32_INPUTS(i) {
364 input_b = *i;
365 int32_t expect = gen->expected(input_a, input_b);
366 if (false) printf(" cmp(a=%d, b=%d) ?== %d\n", input_a, input_b, expect);
367 CHECK_EQ(expect, m->Call(input_a, input_b));
368 }
369 }
370
371
372 TEST(ParametersEqual) {
373 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32);
374 Node* p1 = m.Parameter(1);
375 CHECK_NE(NULL, p1);
376 Node* p0 = m.Parameter(0);
377 CHECK_NE(NULL, p0);
378 CHECK_EQ(p0, m.Parameter(0));
379 CHECK_EQ(p1, m.Parameter(1));
380 }
381
382
383 #if V8_TURBOFAN_TARGET
384
385 void RunSmiConstant(int32_t v) {
386 // TODO(dcarney): on x64 Smis are generated with the SmiConstantRegister
387 #if !V8_TARGET_ARCH_X64
388 if (Smi::IsValid(v)) {
389 RawMachineAssemblerTester<Object*> m;
390 m.Return(m.NumberConstant(v));
391 CHECK_EQ(Smi::FromInt(v), m.Call());
392 }
393 #endif
394 }
395
396
397 void RunNumberConstant(double v) {
398 RawMachineAssemblerTester<Object*> m;
399 #if V8_TARGET_ARCH_X64
400 // TODO(dcarney): on x64 Smis are generated with the SmiConstantRegister
401 Handle<Object> number = m.isolate()->factory()->NewNumber(v);
402 if (number->IsSmi()) return;
403 #endif
404 m.Return(m.NumberConstant(v));
405 Object* result = m.Call();
406 m.CheckNumber(v, result);
407 }
408
409
410 TEST(RunEmpty) {
411 RawMachineAssemblerTester<int32_t> m;
412 m.Return(m.Int32Constant(0));
413 CHECK_EQ(0, m.Call());
414 }
415
416
417 TEST(RunInt32Constants) {
418 FOR_INT32_INPUTS(i) {
419 RawMachineAssemblerTester<int32_t> m;
420 m.Return(m.Int32Constant(*i));
421 CHECK_EQ(*i, m.Call());
422 }
423 }
424
425
426 TEST(RunSmiConstants) {
427 for (int32_t i = 1; i < Smi::kMaxValue && i != 0; i = i << 1) {
428 RunSmiConstant(i);
429 RunSmiConstant(3 * i);
430 RunSmiConstant(5 * i);
431 RunSmiConstant(-i);
432 RunSmiConstant(i | 1);
433 RunSmiConstant(i | 3);
434 }
435 RunSmiConstant(Smi::kMaxValue);
436 RunSmiConstant(Smi::kMaxValue - 1);
437 RunSmiConstant(Smi::kMinValue);
438 RunSmiConstant(Smi::kMinValue + 1);
439
440 FOR_INT32_INPUTS(i) { RunSmiConstant(*i); }
441 }
442
443
444 TEST(RunNumberConstants) {
445 {
446 FOR_FLOAT64_INPUTS(i) { RunNumberConstant(*i); }
447 }
448 {
449 FOR_INT32_INPUTS(i) { RunNumberConstant(*i); }
450 }
451
452 for (int32_t i = 1; i < Smi::kMaxValue && i != 0; i = i << 1) {
453 RunNumberConstant(i);
454 RunNumberConstant(-i);
455 RunNumberConstant(i | 1);
456 RunNumberConstant(i | 3);
457 }
458 RunNumberConstant(Smi::kMaxValue);
459 RunNumberConstant(Smi::kMaxValue - 1);
460 RunNumberConstant(Smi::kMinValue);
461 RunNumberConstant(Smi::kMinValue + 1);
462 }
463
464
465 TEST(RunEmptyString) {
466 RawMachineAssemblerTester<Object*> m;
467 m.Return(m.StringConstant("empty"));
468 m.CheckString("empty", m.Call());
469 }
470
471
472 TEST(RunHeapConstant) {
473 RawMachineAssemblerTester<Object*> m;
474 m.Return(m.StringConstant("empty"));
475 m.CheckString("empty", m.Call());
476 }
477
478
479 TEST(RunHeapNumberConstant) {
480 RawMachineAssemblerTester<Object*> m;
481 Handle<Object> number = m.isolate()->factory()->NewHeapNumber(100.5);
482 m.Return(m.HeapConstant(number));
483 Object* result = m.Call();
484 CHECK_EQ(result, *number);
485 }
486
487
488 TEST(RunParam1) {
489 RawMachineAssemblerTester<int32_t> m(kMachineWord32);
490 m.Return(m.Parameter(0));
491
492 FOR_INT32_INPUTS(i) {
493 int32_t result = m.Call(*i);
494 CHECK_EQ(*i, result);
495 }
496 }
497
498
499 TEST(RunParam2_1) {
500 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32);
501 Node* p0 = m.Parameter(0);
502 Node* p1 = m.Parameter(1);
503 m.Return(p0);
504 USE(p1);
505
506 FOR_INT32_INPUTS(i) {
507 int32_t result = m.Call(*i, -9999);
508 CHECK_EQ(*i, result);
509 }
510 }
511
512
513 TEST(RunParam2_2) {
514 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32);
515 Node* p0 = m.Parameter(0);
516 Node* p1 = m.Parameter(1);
517 m.Return(p1);
518 USE(p0);
519
520 FOR_INT32_INPUTS(i) {
521 int32_t result = m.Call(-7777, *i);
522 CHECK_EQ(*i, result);
523 }
524 }
525
526
527 TEST(RunParam3) {
528 for (int i = 0; i < 3; i++) {
529 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32,
530 kMachineWord32);
531 Node* nodes[] = {m.Parameter(0), m.Parameter(1), m.Parameter(2)};
532 m.Return(nodes[i]);
533
534 int p[] = {-99, -77, -88};
535 FOR_INT32_INPUTS(j) {
536 p[i] = *j;
537 int32_t result = m.Call(p[0], p[1], p[2]);
538 CHECK_EQ(*j, result);
539 }
540 }
541 }
542
543
544 TEST(RunBinopTester) {
545 {
546 RawMachineAssemblerTester<int32_t> m;
547 Int32BinopTester bt(&m);
548 bt.AddReturn(bt.param0);
549
550 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, bt.call(*i, 777)); }
551 }
552
553 {
554 RawMachineAssemblerTester<int32_t> m;
555 Int32BinopTester bt(&m);
556 bt.AddReturn(bt.param1);
557
558 FOR_INT32_INPUTS(i) { CHECK_EQ(*i, bt.call(666, *i)); }
559 }
560
561 {
562 RawMachineAssemblerTester<int32_t> m;
563 Float64BinopTester bt(&m);
564 bt.AddReturn(bt.param0);
565
566 FOR_FLOAT64_INPUTS(i) { CHECK_EQ(*i, bt.call(*i, 9.0)); }
567 }
568
569 {
570 RawMachineAssemblerTester<int32_t> m;
571 Float64BinopTester bt(&m);
572 bt.AddReturn(bt.param1);
573
574 FOR_FLOAT64_INPUTS(i) { CHECK_EQ(*i, bt.call(-11.25, *i)); }
575 }
576 }
577
578 #endif // V8_TURBOFAN_TARGET
OLDNEW
« no previous file with comments | « test/cctest/compiler/codegen-tester.h ('k') | test/cctest/compiler/compiler/call-tester.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698