OLD | NEW |
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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "test/cctest/cctest.h" | 7 #include "test/cctest/cctest.h" |
8 #include "test/cctest/compiler/codegen-tester.h" | 8 #include "test/cctest/compiler/codegen-tester.h" |
9 #include "test/cctest/compiler/value-helper.h" | 9 #include "test/cctest/compiler/value-helper.h" |
10 | 10 |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 | 286 |
287 | 287 |
288 void Int32BinopInputShapeTester::TestAllInputShapes() { | 288 void Int32BinopInputShapeTester::TestAllInputShapes() { |
289 std::vector<int32_t> inputs = ValueHelper::int32_vector(); | 289 std::vector<int32_t> inputs = ValueHelper::int32_vector(); |
290 int num_int_inputs = static_cast<int>(inputs.size()); | 290 int num_int_inputs = static_cast<int>(inputs.size()); |
291 if (num_int_inputs > 16) num_int_inputs = 16; // limit to 16 inputs | 291 if (num_int_inputs > 16) num_int_inputs = 16; // limit to 16 inputs |
292 | 292 |
293 for (int i = -2; i < num_int_inputs; i++) { // for all left shapes | 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 | 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 | 295 if (i >= 0 && j >= 0) break; // No constant/constant combos |
296 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); | 296 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); |
297 Node* p0 = m.Parameter(0); | 297 Node* p0 = m.Parameter(0); |
298 Node* p1 = m.Parameter(1); | 298 Node* p1 = m.Parameter(1); |
299 Node* n0; | 299 Node* n0; |
300 Node* n1; | 300 Node* n1; |
301 | 301 |
302 // left = Parameter | Load | Constant | 302 // left = Parameter | Load | Constant |
303 if (i == -2) { | 303 if (i == -2) { |
304 n0 = p0; | 304 n0 = p0; |
305 } else if (i == -1) { | 305 } else if (i == -1) { |
306 n0 = m.LoadFromPointer(&input_a, kMachineWord32); | 306 n0 = m.LoadFromPointer(&input_a, kMachInt32); |
307 } else { | 307 } else { |
308 n0 = m.Int32Constant(inputs[i]); | 308 n0 = m.Int32Constant(inputs[i]); |
309 } | 309 } |
310 | 310 |
311 // right = Parameter | Load | Constant | 311 // right = Parameter | Load | Constant |
312 if (j == -2) { | 312 if (j == -2) { |
313 n1 = p1; | 313 n1 = p1; |
314 } else if (j == -1) { | 314 } else if (j == -1) { |
315 n1 = m.LoadFromPointer(&input_b, kMachineWord32); | 315 n1 = m.LoadFromPointer(&input_b, kMachInt32); |
316 } else { | 316 } else { |
317 n1 = m.Int32Constant(inputs[j]); | 317 n1 = m.Int32Constant(inputs[j]); |
318 } | 318 } |
319 | 319 |
320 gen->gen(&m, n0, n1); | 320 gen->gen(&m, n0, n1); |
321 | 321 |
322 if (false) printf("Int32BinopInputShapeTester i=%d, j=%d\n", i, j); | 322 if (false) printf("Int32BinopInputShapeTester i=%d, j=%d\n", i, j); |
323 if (i >= 0) { | 323 if (i >= 0) { |
324 input_a = inputs[i]; | 324 input_a = inputs[i]; |
325 RunRight(&m); | 325 RunRight(&m); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 FOR_UINT32_INPUTS(i) { | 363 FOR_UINT32_INPUTS(i) { |
364 input_b = *i; | 364 input_b = *i; |
365 int32_t expect = gen->expected(input_a, input_b); | 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); | 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)); | 367 CHECK_EQ(expect, m->Call(input_a, input_b)); |
368 } | 368 } |
369 } | 369 } |
370 | 370 |
371 | 371 |
372 TEST(ParametersEqual) { | 372 TEST(ParametersEqual) { |
373 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); | 373 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); |
374 Node* p1 = m.Parameter(1); | 374 Node* p1 = m.Parameter(1); |
375 CHECK_NE(NULL, p1); | 375 CHECK_NE(NULL, p1); |
376 Node* p0 = m.Parameter(0); | 376 Node* p0 = m.Parameter(0); |
377 CHECK_NE(NULL, p0); | 377 CHECK_NE(NULL, p0); |
378 CHECK_EQ(p0, m.Parameter(0)); | 378 CHECK_EQ(p0, m.Parameter(0)); |
379 CHECK_EQ(p1, m.Parameter(1)); | 379 CHECK_EQ(p1, m.Parameter(1)); |
380 } | 380 } |
381 | 381 |
382 | 382 |
383 #if V8_TURBOFAN_TARGET | 383 #if V8_TURBOFAN_TARGET |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 TEST(RunHeapNumberConstant) { | 479 TEST(RunHeapNumberConstant) { |
480 RawMachineAssemblerTester<Object*> m; | 480 RawMachineAssemblerTester<Object*> m; |
481 Handle<Object> number = m.isolate()->factory()->NewHeapNumber(100.5); | 481 Handle<Object> number = m.isolate()->factory()->NewHeapNumber(100.5); |
482 m.Return(m.HeapConstant(number)); | 482 m.Return(m.HeapConstant(number)); |
483 Object* result = m.Call(); | 483 Object* result = m.Call(); |
484 CHECK_EQ(result, *number); | 484 CHECK_EQ(result, *number); |
485 } | 485 } |
486 | 486 |
487 | 487 |
488 TEST(RunParam1) { | 488 TEST(RunParam1) { |
489 RawMachineAssemblerTester<int32_t> m(kMachineWord32); | 489 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
490 m.Return(m.Parameter(0)); | 490 m.Return(m.Parameter(0)); |
491 | 491 |
492 FOR_INT32_INPUTS(i) { | 492 FOR_INT32_INPUTS(i) { |
493 int32_t result = m.Call(*i); | 493 int32_t result = m.Call(*i); |
494 CHECK_EQ(*i, result); | 494 CHECK_EQ(*i, result); |
495 } | 495 } |
496 } | 496 } |
497 | 497 |
498 | 498 |
499 TEST(RunParam2_1) { | 499 TEST(RunParam2_1) { |
500 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); | 500 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); |
501 Node* p0 = m.Parameter(0); | 501 Node* p0 = m.Parameter(0); |
502 Node* p1 = m.Parameter(1); | 502 Node* p1 = m.Parameter(1); |
503 m.Return(p0); | 503 m.Return(p0); |
504 USE(p1); | 504 USE(p1); |
505 | 505 |
506 FOR_INT32_INPUTS(i) { | 506 FOR_INT32_INPUTS(i) { |
507 int32_t result = m.Call(*i, -9999); | 507 int32_t result = m.Call(*i, -9999); |
508 CHECK_EQ(*i, result); | 508 CHECK_EQ(*i, result); |
509 } | 509 } |
510 } | 510 } |
511 | 511 |
512 | 512 |
513 TEST(RunParam2_2) { | 513 TEST(RunParam2_2) { |
514 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); | 514 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); |
515 Node* p0 = m.Parameter(0); | 515 Node* p0 = m.Parameter(0); |
516 Node* p1 = m.Parameter(1); | 516 Node* p1 = m.Parameter(1); |
517 m.Return(p1); | 517 m.Return(p1); |
518 USE(p0); | 518 USE(p0); |
519 | 519 |
520 FOR_INT32_INPUTS(i) { | 520 FOR_INT32_INPUTS(i) { |
521 int32_t result = m.Call(-7777, *i); | 521 int32_t result = m.Call(-7777, *i); |
522 CHECK_EQ(*i, result); | 522 CHECK_EQ(*i, result); |
523 } | 523 } |
524 } | 524 } |
525 | 525 |
526 | 526 |
527 TEST(RunParam3) { | 527 TEST(RunParam3) { |
528 for (int i = 0; i < 3; i++) { | 528 for (int i = 0; i < 3; i++) { |
529 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32, | 529 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32, kMachInt32); |
530 kMachineWord32); | |
531 Node* nodes[] = {m.Parameter(0), m.Parameter(1), m.Parameter(2)}; | 530 Node* nodes[] = {m.Parameter(0), m.Parameter(1), m.Parameter(2)}; |
532 m.Return(nodes[i]); | 531 m.Return(nodes[i]); |
533 | 532 |
534 int p[] = {-99, -77, -88}; | 533 int p[] = {-99, -77, -88}; |
535 FOR_INT32_INPUTS(j) { | 534 FOR_INT32_INPUTS(j) { |
536 p[i] = *j; | 535 p[i] = *j; |
537 int32_t result = m.Call(p[0], p[1], p[2]); | 536 int32_t result = m.Call(p[0], p[1], p[2]); |
538 CHECK_EQ(*j, result); | 537 CHECK_EQ(*j, result); |
539 } | 538 } |
540 } | 539 } |
(...skipping 28 matching lines...) Expand all Loading... |
569 { | 568 { |
570 RawMachineAssemblerTester<int32_t> m; | 569 RawMachineAssemblerTester<int32_t> m; |
571 Float64BinopTester bt(&m); | 570 Float64BinopTester bt(&m); |
572 bt.AddReturn(bt.param1); | 571 bt.AddReturn(bt.param1); |
573 | 572 |
574 FOR_FLOAT64_INPUTS(i) { CHECK_EQ(*i, bt.call(-11.25, *i)); } | 573 FOR_FLOAT64_INPUTS(i) { CHECK_EQ(*i, bt.call(-11.25, *i)); } |
575 } | 574 } |
576 } | 575 } |
577 | 576 |
578 #endif // V8_TURBOFAN_TARGET | 577 #endif // V8_TURBOFAN_TARGET |
OLD | NEW |