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

Side by Side Diff: test/cctest/compiler/test-run-machops.cc

Issue 1425633002: [Interpreter] Add support for loading from / storing to outer context variables. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_conditional
Patch Set: Fix interpreter-assembler-unittests 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/codegen-tester.h ('k') | test/cctest/compiler/test-run-native-calls.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 #include <cmath> 5 #include <cmath>
6 #include <functional> 6 #include <functional>
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/base/utils/random-number-generator.h" 10 #include "src/base/utils/random-number-generator.h"
11 #include "src/codegen.h" 11 #include "src/codegen.h"
12 #include "test/cctest/cctest.h" 12 #include "test/cctest/cctest.h"
13 #include "test/cctest/compiler/codegen-tester.h" 13 #include "test/cctest/compiler/codegen-tester.h"
14 #include "test/cctest/compiler/value-helper.h" 14 #include "test/cctest/compiler/value-helper.h"
15 15
16 using namespace v8::base; 16 using namespace v8::base;
17 using namespace v8::internal; 17 using namespace v8::internal;
18 using namespace v8::internal::compiler; 18 using namespace v8::internal::compiler;
19 19
20 typedef RawMachineAssembler::Label MLabel; 20 typedef RawMachineAssembler::Label MLabel;
21 21
22
23 StoreRepresentation StoreRepForType(MachineType type) {
24 return StoreRepresentation(type, kNoWriteBarrier);
25 }
26
27
22 TEST(RunInt32Add) { 28 TEST(RunInt32Add) {
23 RawMachineAssemblerTester<int32_t> m; 29 RawMachineAssemblerTester<int32_t> m;
24 Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1)); 30 Node* add = m.Int32Add(m.Int32Constant(0), m.Int32Constant(1));
25 m.Return(add); 31 m.Return(add);
26 CHECK_EQ(1, m.Call()); 32 CHECK_EQ(1, m.Call());
27 } 33 }
28 34
29 35
30 void TestWord32Ctz(int32_t value, int32_t expected) { 36 void TestWord32Ctz(int32_t value, int32_t expected) {
31 RawMachineAssemblerTester<int32_t> m; 37 RawMachineAssemblerTester<int32_t> m;
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 797
792 FOR_INT32_INPUTS(i) { 798 FOR_INT32_INPUTS(i) {
793 int32_t magic = 0x2342aabb + *i * 3; 799 int32_t magic = 0x2342aabb + *i * 3;
794 RawMachineAssemblerTester<int32_t> m; 800 RawMachineAssemblerTester<int32_t> m;
795 int32_t offset = *i; 801 int32_t offset = *i;
796 byte* from = reinterpret_cast<byte*>(&p1) - offset; 802 byte* from = reinterpret_cast<byte*>(&p1) - offset;
797 byte* to = reinterpret_cast<byte*>(&p2) - offset; 803 byte* to = reinterpret_cast<byte*>(&p2) - offset;
798 // generate load [#base + #index] 804 // generate load [#base + #index]
799 Node* load = 805 Node* load =
800 m.Load(kMachFloat32, m.PointerConstant(from), m.IntPtrConstant(offset)); 806 m.Load(kMachFloat32, m.PointerConstant(from), m.IntPtrConstant(offset));
801 m.Store(kMachFloat32, m.PointerConstant(to), m.IntPtrConstant(offset), 807 m.Store(StoreRepresentation(kMachFloat32, kNoWriteBarrier),
802 load); 808 m.PointerConstant(to), m.IntPtrConstant(offset), load);
803 m.Return(m.Int32Constant(magic)); 809 m.Return(m.Int32Constant(magic));
804 810
805 FOR_FLOAT32_INPUTS(j) { 811 FOR_FLOAT32_INPUTS(j) {
806 p1 = *j; 812 p1 = *j;
807 p2 = *j - 5; 813 p2 = *j - 5;
808 CHECK_EQ(magic, m.Call()); 814 CHECK_EQ(magic, m.Call());
809 CheckDoubleEq(p1, p2); 815 CheckDoubleEq(p1, p2);
810 } 816 }
811 } 817 }
812 } 818 }
813 819
814 820
815 TEST(RunLoadStoreFloat64Offset) { 821 TEST(RunLoadStoreFloat64Offset) {
816 double p1 = 0; // loads directly from this location. 822 double p1 = 0; // loads directly from this location.
817 double p2 = 0; // and stores directly into this location. 823 double p2 = 0; // and stores directly into this location.
818 824
819 FOR_INT32_INPUTS(i) { 825 FOR_INT32_INPUTS(i) {
820 int32_t magic = 0x2342aabb + *i * 3; 826 int32_t magic = 0x2342aabb + *i * 3;
821 RawMachineAssemblerTester<int32_t> m; 827 RawMachineAssemblerTester<int32_t> m;
822 int32_t offset = *i; 828 int32_t offset = *i;
823 byte* from = reinterpret_cast<byte*>(&p1) - offset; 829 byte* from = reinterpret_cast<byte*>(&p1) - offset;
824 byte* to = reinterpret_cast<byte*>(&p2) - offset; 830 byte* to = reinterpret_cast<byte*>(&p2) - offset;
825 // generate load [#base + #index] 831 // generate load [#base + #index]
826 Node* load = 832 Node* load =
827 m.Load(kMachFloat64, m.PointerConstant(from), m.IntPtrConstant(offset)); 833 m.Load(kMachFloat64, m.PointerConstant(from), m.IntPtrConstant(offset));
828 m.Store(kMachFloat64, m.PointerConstant(to), m.IntPtrConstant(offset), 834 m.Store(StoreRepresentation(kMachFloat64, kNoWriteBarrier),
829 load); 835 m.PointerConstant(to), m.IntPtrConstant(offset), load);
830 m.Return(m.Int32Constant(magic)); 836 m.Return(m.Int32Constant(magic));
831 837
832 FOR_FLOAT64_INPUTS(j) { 838 FOR_FLOAT64_INPUTS(j) {
833 p1 = *j; 839 p1 = *j;
834 p2 = *j - 5; 840 p2 = *j - 5;
835 CHECK_EQ(magic, m.Call()); 841 CHECK_EQ(magic, m.Call());
836 CheckDoubleEq(p1, p2); 842 CheckDoubleEq(p1, p2);
837 } 843 }
838 } 844 }
839 } 845 }
(...skipping 2360 matching lines...) Expand 10 before | Expand all | Expand 10 after
3200 for (size_t i = 0; i < sizeof(buffer); i++) { 3206 for (size_t i = 0; i < sizeof(buffer); i++) {
3201 raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA); 3207 raw[i] = static_cast<byte>((i + sizeof(buffer)) ^ 0xAA);
3202 } 3208 }
3203 3209
3204 RawMachineAssemblerTester<int32_t> m; 3210 RawMachineAssemblerTester<int32_t> m;
3205 int32_t OK = 0x29000 + x; 3211 int32_t OK = 0x29000 + x;
3206 Node* base = m.PointerConstant(buffer); 3212 Node* base = m.PointerConstant(buffer);
3207 Node* index0 = m.IntPtrConstant(x * sizeof(buffer[0])); 3213 Node* index0 = m.IntPtrConstant(x * sizeof(buffer[0]));
3208 Node* load = m.Load(rep, base, index0); 3214 Node* load = m.Load(rep, base, index0);
3209 Node* index1 = m.IntPtrConstant(y * sizeof(buffer[0])); 3215 Node* index1 = m.IntPtrConstant(y * sizeof(buffer[0]));
3210 m.Store(rep, base, index1, load); 3216 StoreRepresentation store_rep(rep, kNoWriteBarrier);
3217 m.Store(StoreRepForType(rep), base, index1, load);
3211 m.Return(m.Int32Constant(OK)); 3218 m.Return(m.Int32Constant(OK));
3212 3219
3213 CHECK(buffer[x] != buffer[y]); 3220 CHECK(buffer[x] != buffer[y]);
3214 CHECK_EQ(OK, m.Call()); 3221 CHECK_EQ(OK, m.Call());
3215 CHECK(buffer[x] == buffer[y]); 3222 CHECK(buffer[x] == buffer[y]);
3216 } 3223 }
3217 } 3224 }
3218 3225
3219 3226
3220 TEST(RunLoadStore) { 3227 TEST(RunLoadStore) {
(...skipping 30 matching lines...) Expand all
3251 NULL}; 3258 NULL};
3252 3259
3253 for (int i = 0; ops[i] != NULL; i++) { 3260 for (int i = 0; ops[i] != NULL; i++) {
3254 for (int j = 0; inputs[j] != NULL; j += 2) { 3261 for (int j = 0; inputs[j] != NULL; j += 2) {
3255 RawMachineAssemblerTester<int32_t> m; 3262 RawMachineAssemblerTester<int32_t> m;
3256 Node* a = m.AddNode(inputs[j]); 3263 Node* a = m.AddNode(inputs[j]);
3257 Node* b = m.AddNode(inputs[j + 1]); 3264 Node* b = m.AddNode(inputs[j + 1]);
3258 Node* binop = m.AddNode(ops[i], a, b); 3265 Node* binop = m.AddNode(ops[i], a, b);
3259 Node* base = m.PointerConstant(&result); 3266 Node* base = m.PointerConstant(&result);
3260 Node* zero = m.IntPtrConstant(0); 3267 Node* zero = m.IntPtrConstant(0);
3261 m.Store(kMachFloat32, base, zero, binop); 3268 m.Store(StoreRepForType(kMachFloat32), base, zero, binop);
3262 m.Return(m.Int32Constant(i + j)); 3269 m.Return(m.Int32Constant(i + j));
3263 CHECK_EQ(i + j, m.Call()); 3270 CHECK_EQ(i + j, m.Call());
3264 } 3271 }
3265 } 3272 }
3266 } 3273 }
3267 3274
3268 3275
3269 TEST(RunFloat64Binop) { 3276 TEST(RunFloat64Binop) {
3270 RawMachineAssemblerTester<int32_t> m; 3277 RawMachineAssemblerTester<int32_t> m;
3271 double result; 3278 double result;
(...skipping 15 matching lines...) Expand all
3287 NULL}; 3294 NULL};
3288 3295
3289 for (int i = 0; ops[i] != NULL; i++) { 3296 for (int i = 0; ops[i] != NULL; i++) {
3290 for (int j = 0; inputs[j] != NULL; j += 2) { 3297 for (int j = 0; inputs[j] != NULL; j += 2) {
3291 RawMachineAssemblerTester<int32_t> m; 3298 RawMachineAssemblerTester<int32_t> m;
3292 Node* a = m.AddNode(inputs[j]); 3299 Node* a = m.AddNode(inputs[j]);
3293 Node* b = m.AddNode(inputs[j + 1]); 3300 Node* b = m.AddNode(inputs[j + 1]);
3294 Node* binop = m.AddNode(ops[i], a, b); 3301 Node* binop = m.AddNode(ops[i], a, b);
3295 Node* base = m.PointerConstant(&result); 3302 Node* base = m.PointerConstant(&result);
3296 Node* zero = m.Int32Constant(0); 3303 Node* zero = m.Int32Constant(0);
3297 m.Store(kMachFloat64, base, zero, binop); 3304 m.Store(StoreRepForType(kMachFloat64), base, zero, binop);
3298 m.Return(m.Int32Constant(i + j)); 3305 m.Return(m.Int32Constant(i + j));
3299 CHECK_EQ(i + j, m.Call()); 3306 CHECK_EQ(i + j, m.Call());
3300 } 3307 }
3301 } 3308 }
3302 } 3309 }
3303 3310
3304 3311
3305 TEST(RunDeadFloat32Binops) { 3312 TEST(RunDeadFloat32Binops) {
3306 RawMachineAssemblerTester<int32_t> m; 3313 RawMachineAssemblerTester<int32_t> m;
3307 3314
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
3382 3389
3383 3390
3384 TEST(RunFloat32SubImm1) { 3391 TEST(RunFloat32SubImm1) {
3385 float input = 0.0f; 3392 float input = 0.0f;
3386 float output = 0.0f; 3393 float output = 0.0f;
3387 3394
3388 FOR_FLOAT32_INPUTS(i) { 3395 FOR_FLOAT32_INPUTS(i) {
3389 RawMachineAssemblerTester<int32_t> m; 3396 RawMachineAssemblerTester<int32_t> m;
3390 Node* t0 = m.LoadFromPointer(&input, kMachFloat32); 3397 Node* t0 = m.LoadFromPointer(&input, kMachFloat32);
3391 Node* t1 = m.Float32Sub(m.Float32Constant(*i), t0); 3398 Node* t1 = m.Float32Sub(m.Float32Constant(*i), t0);
3392 m.StoreToPointer(&output, kMachFloat32, t1); 3399 m.StoreToPointer(&output, StoreRepForType(kMachFloat32), t1);
3393 m.Return(m.Int32Constant(0)); 3400 m.Return(m.Int32Constant(0));
3394 FOR_FLOAT32_INPUTS(j) { 3401 FOR_FLOAT32_INPUTS(j) {
3395 input = *j; 3402 input = *j;
3396 float expected = *i - input; 3403 float expected = *i - input;
3397 CHECK_EQ(0, m.Call()); 3404 CHECK_EQ(0, m.Call());
3398 CheckFloatEq(expected, output); 3405 CheckFloatEq(expected, output);
3399 } 3406 }
3400 } 3407 }
3401 } 3408 }
3402 3409
3403 3410
3404 TEST(RunFloat32SubImm2) { 3411 TEST(RunFloat32SubImm2) {
3405 float input = 0.0f; 3412 float input = 0.0f;
3406 float output = 0.0f; 3413 float output = 0.0f;
3407 3414
3408 FOR_FLOAT32_INPUTS(i) { 3415 FOR_FLOAT32_INPUTS(i) {
3409 RawMachineAssemblerTester<int32_t> m; 3416 RawMachineAssemblerTester<int32_t> m;
3410 Node* t0 = m.LoadFromPointer(&input, kMachFloat32); 3417 Node* t0 = m.LoadFromPointer(&input, kMachFloat32);
3411 Node* t1 = m.Float32Sub(t0, m.Float32Constant(*i)); 3418 Node* t1 = m.Float32Sub(t0, m.Float32Constant(*i));
3412 m.StoreToPointer(&output, kMachFloat32, t1); 3419 m.StoreToPointer(&output, StoreRepForType(kMachFloat32), t1);
3413 m.Return(m.Int32Constant(0)); 3420 m.Return(m.Int32Constant(0));
3414 FOR_FLOAT32_INPUTS(j) { 3421 FOR_FLOAT32_INPUTS(j) {
3415 input = *j; 3422 input = *j;
3416 float expected = input - *i; 3423 float expected = input - *i;
3417 CHECK_EQ(0, m.Call()); 3424 CHECK_EQ(0, m.Call());
3418 CheckFloatEq(expected, output); 3425 CheckFloatEq(expected, output);
3419 } 3426 }
3420 } 3427 }
3421 } 3428 }
3422 3429
(...skipping 14 matching lines...) Expand all
3437 3444
3438 3445
3439 TEST(RunFloat64SubImm1) { 3446 TEST(RunFloat64SubImm1) {
3440 double input = 0.0; 3447 double input = 0.0;
3441 double output = 0.0; 3448 double output = 0.0;
3442 3449
3443 FOR_FLOAT64_INPUTS(i) { 3450 FOR_FLOAT64_INPUTS(i) {
3444 RawMachineAssemblerTester<int32_t> m; 3451 RawMachineAssemblerTester<int32_t> m;
3445 Node* t0 = m.LoadFromPointer(&input, kMachFloat64); 3452 Node* t0 = m.LoadFromPointer(&input, kMachFloat64);
3446 Node* t1 = m.Float64Sub(m.Float64Constant(*i), t0); 3453 Node* t1 = m.Float64Sub(m.Float64Constant(*i), t0);
3447 m.StoreToPointer(&output, kMachFloat64, t1); 3454 m.StoreToPointer(&output, StoreRepForType(kMachFloat64), t1);
3448 m.Return(m.Int32Constant(0)); 3455 m.Return(m.Int32Constant(0));
3449 FOR_FLOAT64_INPUTS(j) { 3456 FOR_FLOAT64_INPUTS(j) {
3450 input = *j; 3457 input = *j;
3451 double expected = *i - input; 3458 double expected = *i - input;
3452 CHECK_EQ(0, m.Call()); 3459 CHECK_EQ(0, m.Call());
3453 CheckDoubleEq(expected, output); 3460 CheckDoubleEq(expected, output);
3454 } 3461 }
3455 } 3462 }
3456 } 3463 }
3457 3464
3458 3465
3459 TEST(RunFloat64SubImm2) { 3466 TEST(RunFloat64SubImm2) {
3460 double input = 0.0; 3467 double input = 0.0;
3461 double output = 0.0; 3468 double output = 0.0;
3462 3469
3463 FOR_FLOAT64_INPUTS(i) { 3470 FOR_FLOAT64_INPUTS(i) {
3464 RawMachineAssemblerTester<int32_t> m; 3471 RawMachineAssemblerTester<int32_t> m;
3465 Node* t0 = m.LoadFromPointer(&input, kMachFloat64); 3472 Node* t0 = m.LoadFromPointer(&input, kMachFloat64);
3466 Node* t1 = m.Float64Sub(t0, m.Float64Constant(*i)); 3473 Node* t1 = m.Float64Sub(t0, m.Float64Constant(*i));
3467 m.StoreToPointer(&output, kMachFloat64, t1); 3474 m.StoreToPointer(&output, StoreRepForType(kMachFloat64), t1);
3468 m.Return(m.Int32Constant(0)); 3475 m.Return(m.Int32Constant(0));
3469 FOR_FLOAT64_INPUTS(j) { 3476 FOR_FLOAT64_INPUTS(j) {
3470 input = *j; 3477 input = *j;
3471 double expected = input - *i; 3478 double expected = input - *i;
3472 CHECK_EQ(0, m.Call()); 3479 CHECK_EQ(0, m.Call());
3473 CheckDoubleEq(expected, output); 3480 CheckDoubleEq(expected, output);
3474 } 3481 }
3475 } 3482 }
3476 } 3483 }
3477 3484
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3510 double input_a = 0.0; 3517 double input_a = 0.0;
3511 double input_b = 0.0; 3518 double input_b = 0.0;
3512 double input_c = 0.0; 3519 double input_c = 0.0;
3513 double output = 0.0; 3520 double output = 0.0;
3514 3521
3515 { 3522 {
3516 RawMachineAssemblerTester<int32_t> m; 3523 RawMachineAssemblerTester<int32_t> m;
3517 Node* a = m.LoadFromPointer(&input_a, kMachFloat64); 3524 Node* a = m.LoadFromPointer(&input_a, kMachFloat64);
3518 Node* b = m.LoadFromPointer(&input_b, kMachFloat64); 3525 Node* b = m.LoadFromPointer(&input_b, kMachFloat64);
3519 Node* c = m.LoadFromPointer(&input_c, kMachFloat64); 3526 Node* c = m.LoadFromPointer(&input_c, kMachFloat64);
3520 m.StoreToPointer(&output, kMachFloat64, 3527 m.StoreToPointer(&output, StoreRepForType(kMachFloat64),
3521 m.Float64Add(m.Float64Mul(a, b), c)); 3528 m.Float64Add(m.Float64Mul(a, b), c));
3522 m.Return(m.Int32Constant(0)); 3529 m.Return(m.Int32Constant(0));
3523 FOR_FLOAT64_INPUTS(i) { 3530 FOR_FLOAT64_INPUTS(i) {
3524 FOR_FLOAT64_INPUTS(j) { 3531 FOR_FLOAT64_INPUTS(j) {
3525 FOR_FLOAT64_INPUTS(k) { 3532 FOR_FLOAT64_INPUTS(k) {
3526 input_a = *i; 3533 input_a = *i;
3527 input_b = *j; 3534 input_b = *j;
3528 input_c = *k; 3535 input_c = *k;
3529 volatile double temp = input_a * input_b; 3536 volatile double temp = input_a * input_b;
3530 volatile double expected = temp + input_c; 3537 volatile double expected = temp + input_c;
3531 CHECK_EQ(0, m.Call()); 3538 CHECK_EQ(0, m.Call());
3532 CheckDoubleEq(expected, output); 3539 CheckDoubleEq(expected, output);
3533 } 3540 }
3534 } 3541 }
3535 } 3542 }
3536 } 3543 }
3537 { 3544 {
3538 RawMachineAssemblerTester<int32_t> m; 3545 RawMachineAssemblerTester<int32_t> m;
3539 Node* a = m.LoadFromPointer(&input_a, kMachFloat64); 3546 Node* a = m.LoadFromPointer(&input_a, kMachFloat64);
3540 Node* b = m.LoadFromPointer(&input_b, kMachFloat64); 3547 Node* b = m.LoadFromPointer(&input_b, kMachFloat64);
3541 Node* c = m.LoadFromPointer(&input_c, kMachFloat64); 3548 Node* c = m.LoadFromPointer(&input_c, kMachFloat64);
3542 m.StoreToPointer(&output, kMachFloat64, 3549 m.StoreToPointer(&output, StoreRepForType(kMachFloat64),
3543 m.Float64Add(a, m.Float64Mul(b, c))); 3550 m.Float64Add(a, m.Float64Mul(b, c)));
3544 m.Return(m.Int32Constant(0)); 3551 m.Return(m.Int32Constant(0));
3545 FOR_FLOAT64_INPUTS(i) { 3552 FOR_FLOAT64_INPUTS(i) {
3546 FOR_FLOAT64_INPUTS(j) { 3553 FOR_FLOAT64_INPUTS(j) {
3547 FOR_FLOAT64_INPUTS(k) { 3554 FOR_FLOAT64_INPUTS(k) {
3548 input_a = *i; 3555 input_a = *i;
3549 input_b = *j; 3556 input_b = *j;
3550 input_c = *k; 3557 input_c = *k;
3551 volatile double temp = input_b * input_c; 3558 volatile double temp = input_b * input_c;
3552 volatile double expected = input_a + temp; 3559 volatile double expected = input_a + temp;
3553 CHECK_EQ(0, m.Call()); 3560 CHECK_EQ(0, m.Call());
3554 CheckDoubleEq(expected, output); 3561 CheckDoubleEq(expected, output);
3555 } 3562 }
3556 } 3563 }
3557 } 3564 }
3558 } 3565 }
3559 } 3566 }
3560 3567
3561 3568
3562 TEST(RunFloat64MulAndFloat64SubP) { 3569 TEST(RunFloat64MulAndFloat64SubP) {
3563 double input_a = 0.0; 3570 double input_a = 0.0;
3564 double input_b = 0.0; 3571 double input_b = 0.0;
3565 double input_c = 0.0; 3572 double input_c = 0.0;
3566 double output = 0.0; 3573 double output = 0.0;
3567 3574
3568 RawMachineAssemblerTester<int32_t> m; 3575 RawMachineAssemblerTester<int32_t> m;
3569 Node* a = m.LoadFromPointer(&input_a, kMachFloat64); 3576 Node* a = m.LoadFromPointer(&input_a, kMachFloat64);
3570 Node* b = m.LoadFromPointer(&input_b, kMachFloat64); 3577 Node* b = m.LoadFromPointer(&input_b, kMachFloat64);
3571 Node* c = m.LoadFromPointer(&input_c, kMachFloat64); 3578 Node* c = m.LoadFromPointer(&input_c, kMachFloat64);
3572 m.StoreToPointer(&output, kMachFloat64, m.Float64Sub(a, m.Float64Mul(b, c))); 3579 m.StoreToPointer(&output, StoreRepForType(kMachFloat64),
3580 m.Float64Sub(a, m.Float64Mul(b, c)));
3573 m.Return(m.Int32Constant(0)); 3581 m.Return(m.Int32Constant(0));
3574 3582
3575 FOR_FLOAT64_INPUTS(i) { 3583 FOR_FLOAT64_INPUTS(i) {
3576 FOR_FLOAT64_INPUTS(j) { 3584 FOR_FLOAT64_INPUTS(j) {
3577 FOR_FLOAT64_INPUTS(k) { 3585 FOR_FLOAT64_INPUTS(k) {
3578 input_a = *i; 3586 input_a = *i;
3579 input_b = *j; 3587 input_b = *j;
3580 input_c = *k; 3588 input_c = *k;
3581 volatile double temp = input_b * input_c; 3589 volatile double temp = input_b * input_c;
3582 volatile double expected = input_a - temp; 3590 volatile double expected = input_a - temp;
3583 CHECK_EQ(0, m.Call()); 3591 CHECK_EQ(0, m.Call());
3584 CheckDoubleEq(expected, output); 3592 CheckDoubleEq(expected, output);
3585 } 3593 }
3586 } 3594 }
3587 } 3595 }
3588 } 3596 }
3589 3597
3590 3598
3591 TEST(RunFloat64MulImm) { 3599 TEST(RunFloat64MulImm) {
3592 double input = 0.0; 3600 double input = 0.0;
3593 double output = 0.0; 3601 double output = 0.0;
3594 3602
3595 { 3603 {
3596 FOR_FLOAT64_INPUTS(i) { 3604 FOR_FLOAT64_INPUTS(i) {
3597 RawMachineAssemblerTester<int32_t> m; 3605 RawMachineAssemblerTester<int32_t> m;
3598 Node* t0 = m.LoadFromPointer(&input, kMachFloat64); 3606 Node* t0 = m.LoadFromPointer(&input, kMachFloat64);
3599 Node* t1 = m.Float64Mul(m.Float64Constant(*i), t0); 3607 Node* t1 = m.Float64Mul(m.Float64Constant(*i), t0);
3600 m.StoreToPointer(&output, kMachFloat64, t1); 3608 m.StoreToPointer(&output, StoreRepForType(kMachFloat64), t1);
3601 m.Return(m.Int32Constant(0)); 3609 m.Return(m.Int32Constant(0));
3602 FOR_FLOAT64_INPUTS(j) { 3610 FOR_FLOAT64_INPUTS(j) {
3603 input = *j; 3611 input = *j;
3604 double expected = *i * input; 3612 double expected = *i * input;
3605 CHECK_EQ(0, m.Call()); 3613 CHECK_EQ(0, m.Call());
3606 CheckDoubleEq(expected, output); 3614 CheckDoubleEq(expected, output);
3607 } 3615 }
3608 } 3616 }
3609 } 3617 }
3610 { 3618 {
3611 FOR_FLOAT64_INPUTS(i) { 3619 FOR_FLOAT64_INPUTS(i) {
3612 RawMachineAssemblerTester<int32_t> m; 3620 RawMachineAssemblerTester<int32_t> m;
3613 Node* t0 = m.LoadFromPointer(&input, kMachFloat64); 3621 Node* t0 = m.LoadFromPointer(&input, kMachFloat64);
3614 Node* t1 = m.Float64Mul(t0, m.Float64Constant(*i)); 3622 Node* t1 = m.Float64Mul(t0, m.Float64Constant(*i));
3615 m.StoreToPointer(&output, kMachFloat64, t1); 3623 m.StoreToPointer(&output, StoreRepForType(kMachFloat64), t1);
3616 m.Return(m.Int32Constant(0)); 3624 m.Return(m.Int32Constant(0));
3617 FOR_FLOAT64_INPUTS(j) { 3625 FOR_FLOAT64_INPUTS(j) {
3618 input = *j; 3626 input = *j;
3619 double expected = input * *i; 3627 double expected = input * *i;
3620 CHECK_EQ(0, m.Call()); 3628 CHECK_EQ(0, m.Call());
3621 CheckDoubleEq(expected, output); 3629 CheckDoubleEq(expected, output);
3622 } 3630 }
3623 } 3631 }
3624 } 3632 }
3625 } 3633 }
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3670 } 3678 }
3671 } 3679 }
3672 3680
3673 3681
3674 TEST(RunChangeInt32ToFloat64_A) { 3682 TEST(RunChangeInt32ToFloat64_A) {
3675 RawMachineAssemblerTester<int32_t> m; 3683 RawMachineAssemblerTester<int32_t> m;
3676 int32_t magic = 0x986234; 3684 int32_t magic = 0x986234;
3677 double result = 0; 3685 double result = 0;
3678 3686
3679 Node* convert = m.ChangeInt32ToFloat64(m.Int32Constant(magic)); 3687 Node* convert = m.ChangeInt32ToFloat64(m.Int32Constant(magic));
3680 m.Store(kMachFloat64, m.PointerConstant(&result), m.Int32Constant(0), 3688 m.Store(StoreRepForType(kMachFloat64), m.PointerConstant(&result),
3681 convert); 3689 m.Int32Constant(0), convert);
3682 m.Return(m.Int32Constant(magic)); 3690 m.Return(m.Int32Constant(magic));
3683 3691
3684 CHECK_EQ(magic, m.Call()); 3692 CHECK_EQ(magic, m.Call());
3685 CHECK_EQ(static_cast<double>(magic), result); 3693 CHECK_EQ(static_cast<double>(magic), result);
3686 } 3694 }
3687 3695
3688 3696
3689 TEST(RunChangeInt32ToFloat64_B) { 3697 TEST(RunChangeInt32ToFloat64_B) {
3690 RawMachineAssemblerTester<int32_t> m(kMachInt32); 3698 RawMachineAssemblerTester<int32_t> m(kMachInt32);
3691 double output = 0; 3699 double output = 0;
3692 3700
3693 Node* convert = m.ChangeInt32ToFloat64(m.Parameter(0)); 3701 Node* convert = m.ChangeInt32ToFloat64(m.Parameter(0));
3694 m.Store(kMachFloat64, m.PointerConstant(&output), m.Int32Constant(0), 3702 m.Store(StoreRepForType(kMachFloat64), m.PointerConstant(&output),
3695 convert); 3703 m.Int32Constant(0), convert);
3696 m.Return(m.Parameter(0)); 3704 m.Return(m.Parameter(0));
3697 3705
3698 FOR_INT32_INPUTS(i) { 3706 FOR_INT32_INPUTS(i) {
3699 int32_t expect = *i; 3707 int32_t expect = *i;
3700 CHECK_EQ(expect, m.Call(expect)); 3708 CHECK_EQ(expect, m.Call(expect));
3701 CHECK_EQ(static_cast<double>(expect), output); 3709 CHECK_EQ(static_cast<double>(expect), output);
3702 } 3710 }
3703 } 3711 }
3704 3712
3705 3713
3706 TEST(RunChangeUint32ToFloat64_B) { 3714 TEST(RunChangeUint32ToFloat64_B) {
3707 RawMachineAssemblerTester<uint32_t> m(kMachUint32); 3715 RawMachineAssemblerTester<uint32_t> m(kMachUint32);
3708 double output = 0; 3716 double output = 0;
3709 3717
3710 Node* convert = m.ChangeUint32ToFloat64(m.Parameter(0)); 3718 Node* convert = m.ChangeUint32ToFloat64(m.Parameter(0));
3711 m.Store(kMachFloat64, m.PointerConstant(&output), m.Int32Constant(0), 3719 m.Store(StoreRepForType(kMachFloat64), m.PointerConstant(&output),
3712 convert); 3720 m.Int32Constant(0), convert);
3713 m.Return(m.Parameter(0)); 3721 m.Return(m.Parameter(0));
3714 3722
3715 FOR_UINT32_INPUTS(i) { 3723 FOR_UINT32_INPUTS(i) {
3716 uint32_t expect = *i; 3724 uint32_t expect = *i;
3717 CHECK_EQ(expect, m.Call(expect)); 3725 CHECK_EQ(expect, m.Call(expect));
3718 CHECK_EQ(static_cast<double>(expect), output); 3726 CHECK_EQ(static_cast<double>(expect), output);
3719 } 3727 }
3720 } 3728 }
3721 3729
3722 3730
3723 TEST(RunChangeUint32ToFloat64_spilled) { 3731 TEST(RunChangeUint32ToFloat64_spilled) {
3724 RawMachineAssemblerTester<int32_t> m; 3732 RawMachineAssemblerTester<int32_t> m;
3725 const int kNumInputs = 32; 3733 const int kNumInputs = 32;
3726 int32_t magic = 0x786234; 3734 int32_t magic = 0x786234;
3727 uint32_t input[kNumInputs]; 3735 uint32_t input[kNumInputs];
3728 double result[kNumInputs]; 3736 double result[kNumInputs];
3729 Node* input_node[kNumInputs]; 3737 Node* input_node[kNumInputs];
3730 3738
3731 for (int i = 0; i < kNumInputs; i++) { 3739 for (int i = 0; i < kNumInputs; i++) {
3732 input_node[i] = 3740 input_node[i] =
3733 m.Load(kMachUint32, m.PointerConstant(&input), m.Int32Constant(i * 4)); 3741 m.Load(kMachUint32, m.PointerConstant(&input), m.Int32Constant(i * 4));
3734 } 3742 }
3735 3743
3736 for (int i = 0; i < kNumInputs; i++) { 3744 for (int i = 0; i < kNumInputs; i++) {
3737 m.Store(kMachFloat64, m.PointerConstant(&result), m.Int32Constant(i * 8), 3745 m.Store(StoreRepForType(kMachFloat64), m.PointerConstant(&result),
3738 m.ChangeUint32ToFloat64(input_node[i])); 3746 m.Int32Constant(i * 8), m.ChangeUint32ToFloat64(input_node[i]));
3739 } 3747 }
3740 3748
3741 m.Return(m.Int32Constant(magic)); 3749 m.Return(m.Int32Constant(magic));
3742 3750
3743 for (int i = 0; i < kNumInputs; i++) { 3751 for (int i = 0; i < kNumInputs; i++) {
3744 input[i] = 100 + i; 3752 input[i] = 100 + i;
3745 } 3753 }
3746 3754
3747 CHECK_EQ(magic, m.Call()); 3755 CHECK_EQ(magic, m.Call());
3748 3756
3749 for (int i = 0; i < kNumInputs; i++) { 3757 for (int i = 0; i < kNumInputs; i++) {
3750 CHECK_EQ(result[i], static_cast<double>(100 + i)); 3758 CHECK_EQ(result[i], static_cast<double>(100 + i));
3751 } 3759 }
3752 } 3760 }
3753 3761
3754 3762
3755 TEST(RunChangeFloat64ToInt32_A) { 3763 TEST(RunChangeFloat64ToInt32_A) {
3756 RawMachineAssemblerTester<int32_t> m; 3764 RawMachineAssemblerTester<int32_t> m;
3757 int32_t magic = 0x786234; 3765 int32_t magic = 0x786234;
3758 double input = 11.1; 3766 double input = 11.1;
3759 int32_t result = 0; 3767 int32_t result = 0;
3760 3768
3761 m.Store(kMachInt32, m.PointerConstant(&result), m.Int32Constant(0), 3769 m.Store(StoreRepForType(kMachInt32), m.PointerConstant(&result),
3762 m.ChangeFloat64ToInt32(m.Float64Constant(input))); 3770 m.Int32Constant(0), m.ChangeFloat64ToInt32(m.Float64Constant(input)));
3763 m.Return(m.Int32Constant(magic)); 3771 m.Return(m.Int32Constant(magic));
3764 3772
3765 CHECK_EQ(magic, m.Call()); 3773 CHECK_EQ(magic, m.Call());
3766 CHECK_EQ(static_cast<int32_t>(input), result); 3774 CHECK_EQ(static_cast<int32_t>(input), result);
3767 } 3775 }
3768 3776
3769 3777
3770 TEST(RunChangeFloat64ToInt32_B) { 3778 TEST(RunChangeFloat64ToInt32_B) {
3771 RawMachineAssemblerTester<int32_t> m; 3779 RawMachineAssemblerTester<int32_t> m;
3772 double input = 0; 3780 double input = 0;
3773 int32_t output = 0; 3781 int32_t output = 0;
3774 3782
3775 Node* load = 3783 Node* load =
3776 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(0)); 3784 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(0));
3777 Node* convert = m.ChangeFloat64ToInt32(load); 3785 Node* convert = m.ChangeFloat64ToInt32(load);
3778 m.Store(kMachInt32, m.PointerConstant(&output), m.Int32Constant(0), convert); 3786 m.Store(StoreRepForType(kMachInt32), m.PointerConstant(&output),
3787 m.Int32Constant(0), convert);
3779 m.Return(convert); 3788 m.Return(convert);
3780 3789
3781 { 3790 {
3782 FOR_INT32_INPUTS(i) { 3791 FOR_INT32_INPUTS(i) {
3783 input = *i; 3792 input = *i;
3784 int32_t expect = *i; 3793 int32_t expect = *i;
3785 CHECK_EQ(expect, m.Call()); 3794 CHECK_EQ(expect, m.Call());
3786 CHECK_EQ(expect, output); 3795 CHECK_EQ(expect, output);
3787 } 3796 }
3788 } 3797 }
(...skipping 20 matching lines...) Expand all
3809 3818
3810 3819
3811 TEST(RunChangeFloat64ToUint32_B) { 3820 TEST(RunChangeFloat64ToUint32_B) {
3812 RawMachineAssemblerTester<int32_t> m; 3821 RawMachineAssemblerTester<int32_t> m;
3813 double input = 0; 3822 double input = 0;
3814 int32_t output = 0; 3823 int32_t output = 0;
3815 3824
3816 Node* load = 3825 Node* load =
3817 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(0)); 3826 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(0));
3818 Node* convert = m.ChangeFloat64ToUint32(load); 3827 Node* convert = m.ChangeFloat64ToUint32(load);
3819 m.Store(kMachInt32, m.PointerConstant(&output), m.Int32Constant(0), convert); 3828 m.Store(StoreRepForType(kMachInt32), m.PointerConstant(&output),
3829 m.Int32Constant(0), convert);
3820 m.Return(convert); 3830 m.Return(convert);
3821 3831
3822 { 3832 {
3823 FOR_UINT32_INPUTS(i) { 3833 FOR_UINT32_INPUTS(i) {
3824 input = *i; 3834 input = *i;
3825 // TODO(titzer): add a CheckEqualsHelper overload for uint32_t. 3835 // TODO(titzer): add a CheckEqualsHelper overload for uint32_t.
3826 int32_t expect = static_cast<int32_t>(*i); 3836 int32_t expect = static_cast<int32_t>(*i);
3827 CHECK_EQ(expect, m.Call()); 3837 CHECK_EQ(expect, m.Call());
3828 CHECK_EQ(expect, output); 3838 CHECK_EQ(expect, output);
3829 } 3839 }
(...skipping 27 matching lines...) Expand all
3857 double input[kNumInputs]; 3867 double input[kNumInputs];
3858 int32_t result[kNumInputs]; 3868 int32_t result[kNumInputs];
3859 Node* input_node[kNumInputs]; 3869 Node* input_node[kNumInputs];
3860 3870
3861 for (int i = 0; i < kNumInputs; i++) { 3871 for (int i = 0; i < kNumInputs; i++) {
3862 input_node[i] = 3872 input_node[i] =
3863 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8)); 3873 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8));
3864 } 3874 }
3865 3875
3866 for (int i = 0; i < kNumInputs; i++) { 3876 for (int i = 0; i < kNumInputs; i++) {
3867 m.Store(kMachInt32, m.PointerConstant(&result), m.Int32Constant(i * 4), 3877 m.Store(StoreRepForType(kMachInt32), m.PointerConstant(&result),
3868 m.ChangeFloat64ToInt32(input_node[i])); 3878 m.Int32Constant(i * 4), m.ChangeFloat64ToInt32(input_node[i]));
3869 } 3879 }
3870 3880
3871 m.Return(m.Int32Constant(magic)); 3881 m.Return(m.Int32Constant(magic));
3872 3882
3873 for (int i = 0; i < kNumInputs; i++) { 3883 for (int i = 0; i < kNumInputs; i++) {
3874 input[i] = 100.9 + i; 3884 input[i] = 100.9 + i;
3875 } 3885 }
3876 3886
3877 CHECK_EQ(magic, m.Call()); 3887 CHECK_EQ(magic, m.Call());
3878 3888
(...skipping 10 matching lines...) Expand all
3889 double input[kNumInputs]; 3899 double input[kNumInputs];
3890 uint32_t result[kNumInputs]; 3900 uint32_t result[kNumInputs];
3891 Node* input_node[kNumInputs]; 3901 Node* input_node[kNumInputs];
3892 3902
3893 for (int i = 0; i < kNumInputs; i++) { 3903 for (int i = 0; i < kNumInputs; i++) {
3894 input_node[i] = 3904 input_node[i] =
3895 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8)); 3905 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8));
3896 } 3906 }
3897 3907
3898 for (int i = 0; i < kNumInputs; i++) { 3908 for (int i = 0; i < kNumInputs; i++) {
3899 m.Store(kMachUint32, m.PointerConstant(&result), m.Int32Constant(i * 4), 3909 m.Store(StoreRepForType(kMachUint32), m.PointerConstant(&result),
3900 m.ChangeFloat64ToUint32(input_node[i])); 3910 m.Int32Constant(i * 4), m.ChangeFloat64ToUint32(input_node[i]));
3901 } 3911 }
3902 3912
3903 m.Return(m.Int32Constant(magic)); 3913 m.Return(m.Int32Constant(magic));
3904 3914
3905 for (int i = 0; i < kNumInputs; i++) { 3915 for (int i = 0; i < kNumInputs; i++) {
3906 if (i % 2) { 3916 if (i % 2) {
3907 input[i] = 100 + i + 2147483648u; 3917 input[i] = 100 + i + 2147483648u;
3908 } else { 3918 } else {
3909 input[i] = 100 + i; 3919 input[i] = 100 + i;
3910 } 3920 }
(...skipping 18 matching lines...) Expand all
3929 double input[kNumInputs]; 3939 double input[kNumInputs];
3930 float result[kNumInputs]; 3940 float result[kNumInputs];
3931 Node* input_node[kNumInputs]; 3941 Node* input_node[kNumInputs];
3932 3942
3933 for (int i = 0; i < kNumInputs; i++) { 3943 for (int i = 0; i < kNumInputs; i++) {
3934 input_node[i] = 3944 input_node[i] =
3935 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8)); 3945 m.Load(kMachFloat64, m.PointerConstant(&input), m.Int32Constant(i * 8));
3936 } 3946 }
3937 3947
3938 for (int i = 0; i < kNumInputs; i++) { 3948 for (int i = 0; i < kNumInputs; i++) {
3939 m.Store(kMachFloat32, m.PointerConstant(&result), m.Int32Constant(i * 4), 3949 m.Store(StoreRepForType(kMachFloat32), m.PointerConstant(&result),
3940 m.TruncateFloat64ToFloat32(input_node[i])); 3950 m.Int32Constant(i * 4), m.TruncateFloat64ToFloat32(input_node[i]));
3941 } 3951 }
3942 3952
3943 m.Return(m.Int32Constant(magic)); 3953 m.Return(m.Int32Constant(magic));
3944 3954
3945 for (int i = 0; i < kNumInputs; i++) { 3955 for (int i = 0; i < kNumInputs; i++) {
3946 input[i] = 0.1 + i; 3956 input[i] = 0.1 + i;
3947 } 3957 }
3948 3958
3949 CHECK_EQ(magic, m.Call()); 3959 CHECK_EQ(magic, m.Call());
3950 3960
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
4005 MLabel blocka, blockb, end; 4015 MLabel blocka, blockb, end;
4006 Node* k1 = m.Float32Constant(constant); 4016 Node* k1 = m.Float32Constant(constant);
4007 Node* k2 = m.Float32Constant(0 - constant); 4017 Node* k2 = m.Float32Constant(0 - constant);
4008 m.Branch(m.Int32Constant(0), &blocka, &blockb); 4018 m.Branch(m.Int32Constant(0), &blocka, &blockb);
4009 m.Bind(&blocka); 4019 m.Bind(&blocka);
4010 m.Goto(&end); 4020 m.Goto(&end);
4011 m.Bind(&blockb); 4021 m.Bind(&blockb);
4012 m.Goto(&end); 4022 m.Goto(&end);
4013 m.Bind(&end); 4023 m.Bind(&end);
4014 Node* phi = m.Phi(kMachFloat32, k2, k1); 4024 Node* phi = m.Phi(kMachFloat32, k2, k1);
4015 m.Store(kMachFloat32, m.PointerConstant(&buffer), m.IntPtrConstant(0), phi); 4025 m.Store(StoreRepForType(kMachFloat32), m.PointerConstant(&buffer),
4026 m.IntPtrConstant(0), phi);
4016 m.Return(m.Int32Constant(magic)); 4027 m.Return(m.Int32Constant(magic));
4017 4028
4018 CHECK_EQ(magic, m.Call()); 4029 CHECK_EQ(magic, m.Call());
4019 CHECK(constant == buffer); 4030 CHECK(constant == buffer);
4020 } 4031 }
4021 4032
4022 4033
4023 TEST(RunDoubleDiamond) { 4034 TEST(RunDoubleDiamond) {
4024 RawMachineAssemblerTester<int32_t> m; 4035 RawMachineAssemblerTester<int32_t> m;
4025 4036
4026 const int magic = 99645; 4037 const int magic = 99645;
4027 double buffer = 0.1; 4038 double buffer = 0.1;
4028 double constant = 99.99; 4039 double constant = 99.99;
4029 4040
4030 MLabel blocka, blockb, end; 4041 MLabel blocka, blockb, end;
4031 Node* k1 = m.Float64Constant(constant); 4042 Node* k1 = m.Float64Constant(constant);
4032 Node* k2 = m.Float64Constant(0 - constant); 4043 Node* k2 = m.Float64Constant(0 - constant);
4033 m.Branch(m.Int32Constant(0), &blocka, &blockb); 4044 m.Branch(m.Int32Constant(0), &blocka, &blockb);
4034 m.Bind(&blocka); 4045 m.Bind(&blocka);
4035 m.Goto(&end); 4046 m.Goto(&end);
4036 m.Bind(&blockb); 4047 m.Bind(&blockb);
4037 m.Goto(&end); 4048 m.Goto(&end);
4038 m.Bind(&end); 4049 m.Bind(&end);
4039 Node* phi = m.Phi(kMachFloat64, k2, k1); 4050 Node* phi = m.Phi(kMachFloat64, k2, k1);
4040 m.Store(kMachFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi); 4051 m.Store(StoreRepForType(kMachFloat64), m.PointerConstant(&buffer),
4052 m.Int32Constant(0), phi);
4041 m.Return(m.Int32Constant(magic)); 4053 m.Return(m.Int32Constant(magic));
4042 4054
4043 CHECK_EQ(magic, m.Call()); 4055 CHECK_EQ(magic, m.Call());
4044 CHECK_EQ(constant, buffer); 4056 CHECK_EQ(constant, buffer);
4045 } 4057 }
4046 4058
4047 4059
4048 TEST(RunRefDiamond) { 4060 TEST(RunRefDiamond) {
4049 RawMachineAssemblerTester<int32_t> m; 4061 RawMachineAssemblerTester<int32_t> m;
4050 4062
4051 const int magic = 99644; 4063 const int magic = 99644;
4052 Handle<String> rexpected = 4064 Handle<String> rexpected =
4053 CcTest::i_isolate()->factory()->InternalizeUtf8String("A"); 4065 CcTest::i_isolate()->factory()->InternalizeUtf8String("A");
4054 String* buffer; 4066 String* buffer;
4055 4067
4056 MLabel blocka, blockb, end; 4068 MLabel blocka, blockb, end;
4057 Node* k1 = m.StringConstant("A"); 4069 Node* k1 = m.StringConstant("A");
4058 Node* k2 = m.StringConstant("B"); 4070 Node* k2 = m.StringConstant("B");
4059 m.Branch(m.Int32Constant(0), &blocka, &blockb); 4071 m.Branch(m.Int32Constant(0), &blocka, &blockb);
4060 m.Bind(&blocka); 4072 m.Bind(&blocka);
4061 m.Goto(&end); 4073 m.Goto(&end);
4062 m.Bind(&blockb); 4074 m.Bind(&blockb);
4063 m.Goto(&end); 4075 m.Goto(&end);
4064 m.Bind(&end); 4076 m.Bind(&end);
4065 Node* phi = m.Phi(kMachAnyTagged, k2, k1); 4077 Node* phi = m.Phi(kMachAnyTagged, k2, k1);
4066 m.Store(kMachAnyTagged, m.PointerConstant(&buffer), m.Int32Constant(0), phi); 4078 m.Store(StoreRepForType(kMachAnyTagged), m.PointerConstant(&buffer),
4079 m.Int32Constant(0), phi);
4067 m.Return(m.Int32Constant(magic)); 4080 m.Return(m.Int32Constant(magic));
4068 4081
4069 CHECK_EQ(magic, m.Call()); 4082 CHECK_EQ(magic, m.Call());
4070 CHECK(rexpected->SameValue(buffer)); 4083 CHECK(rexpected->SameValue(buffer));
4071 } 4084 }
4072 4085
4073 4086
4074 TEST(RunDoubleRefDiamond) { 4087 TEST(RunDoubleRefDiamond) {
4075 RawMachineAssemblerTester<int32_t> m; 4088 RawMachineAssemblerTester<int32_t> m;
4076 4089
(...skipping 10 matching lines...) Expand all
4087 Node* r1 = m.StringConstant("AX"); 4100 Node* r1 = m.StringConstant("AX");
4088 Node* r2 = m.StringConstant("BX"); 4101 Node* r2 = m.StringConstant("BX");
4089 m.Branch(m.Int32Constant(0), &blocka, &blockb); 4102 m.Branch(m.Int32Constant(0), &blocka, &blockb);
4090 m.Bind(&blocka); 4103 m.Bind(&blocka);
4091 m.Goto(&end); 4104 m.Goto(&end);
4092 m.Bind(&blockb); 4105 m.Bind(&blockb);
4093 m.Goto(&end); 4106 m.Goto(&end);
4094 m.Bind(&end); 4107 m.Bind(&end);
4095 Node* dphi = m.Phi(kMachFloat64, d2, d1); 4108 Node* dphi = m.Phi(kMachFloat64, d2, d1);
4096 Node* rphi = m.Phi(kMachAnyTagged, r2, r1); 4109 Node* rphi = m.Phi(kMachAnyTagged, r2, r1);
4097 m.Store(kMachFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi); 4110 m.Store(StoreRepForType(kMachFloat64), m.PointerConstant(&dbuffer),
4098 m.Store(kMachAnyTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), 4111 m.Int32Constant(0), dphi);
4099 rphi); 4112 m.Store(StoreRepForType(kMachAnyTagged), m.PointerConstant(&rbuffer),
4113 m.Int32Constant(0), rphi);
4100 m.Return(m.Int32Constant(magic)); 4114 m.Return(m.Int32Constant(magic));
4101 4115
4102 CHECK_EQ(magic, m.Call()); 4116 CHECK_EQ(magic, m.Call());
4103 CHECK_EQ(dconstant, dbuffer); 4117 CHECK_EQ(dconstant, dbuffer);
4104 CHECK(rexpected->SameValue(rbuffer)); 4118 CHECK(rexpected->SameValue(rbuffer));
4105 } 4119 }
4106 4120
4107 4121
4108 TEST(RunDoubleRefDoubleDiamond) { 4122 TEST(RunDoubleRefDoubleDiamond) {
4109 RawMachineAssemblerTester<int32_t> m; 4123 RawMachineAssemblerTester<int32_t> m;
(...skipping 21 matching lines...) Expand all
4131 m.Branch(m.Int32Constant(0), &blockd, &blocke); 4145 m.Branch(m.Int32Constant(0), &blockd, &blocke);
4132 4146
4133 m.Bind(&blockd); 4147 m.Bind(&blockd);
4134 m.Goto(&end); 4148 m.Goto(&end);
4135 m.Bind(&blocke); 4149 m.Bind(&blocke);
4136 m.Goto(&end); 4150 m.Goto(&end);
4137 m.Bind(&end); 4151 m.Bind(&end);
4138 Node* dphi2 = m.Phi(kMachFloat64, d1, dphi1); 4152 Node* dphi2 = m.Phi(kMachFloat64, d1, dphi1);
4139 Node* rphi2 = m.Phi(kMachAnyTagged, r1, rphi1); 4153 Node* rphi2 = m.Phi(kMachAnyTagged, r1, rphi1);
4140 4154
4141 m.Store(kMachFloat64, m.PointerConstant(&dbuffer), m.Int32Constant(0), dphi2); 4155 m.Store(StoreRepForType(kMachFloat64), m.PointerConstant(&dbuffer),
4142 m.Store(kMachAnyTagged, m.PointerConstant(&rbuffer), m.Int32Constant(0), 4156 m.Int32Constant(0), dphi2);
4143 rphi2); 4157 m.Store(StoreRepForType(kMachAnyTagged), m.PointerConstant(&rbuffer),
4158 m.Int32Constant(0), rphi2);
4144 m.Return(m.Int32Constant(magic)); 4159 m.Return(m.Int32Constant(magic));
4145 4160
4146 CHECK_EQ(magic, m.Call()); 4161 CHECK_EQ(magic, m.Call());
4147 CHECK_EQ(dconstant, dbuffer); 4162 CHECK_EQ(dconstant, dbuffer);
4148 CHECK(rexpected->SameValue(rbuffer)); 4163 CHECK(rexpected->SameValue(rbuffer));
4149 } 4164 }
4150 4165
4151 4166
4152 TEST(RunDoubleLoopPhi) { 4167 TEST(RunDoubleLoopPhi) {
4153 RawMachineAssemblerTester<int32_t> m; 4168 RawMachineAssemblerTester<int32_t> m;
4154 MLabel header, body, end; 4169 MLabel header, body, end;
4155 4170
4156 int magic = 99773; 4171 int magic = 99773;
4157 double buffer = 0.99; 4172 double buffer = 0.99;
4158 double dconstant = 777.1; 4173 double dconstant = 777.1;
4159 4174
4160 Node* zero = m.Int32Constant(0); 4175 Node* zero = m.Int32Constant(0);
4161 Node* dk = m.Float64Constant(dconstant); 4176 Node* dk = m.Float64Constant(dconstant);
4162 4177
4163 m.Goto(&header); 4178 m.Goto(&header);
4164 m.Bind(&header); 4179 m.Bind(&header);
4165 Node* phi = m.Phi(kMachFloat64, dk, dk); 4180 Node* phi = m.Phi(kMachFloat64, dk, dk);
4166 phi->ReplaceInput(1, phi); 4181 phi->ReplaceInput(1, phi);
4167 m.Branch(zero, &body, &end); 4182 m.Branch(zero, &body, &end);
4168 m.Bind(&body); 4183 m.Bind(&body);
4169 m.Goto(&header); 4184 m.Goto(&header);
4170 m.Bind(&end); 4185 m.Bind(&end);
4171 m.Store(kMachFloat64, m.PointerConstant(&buffer), m.Int32Constant(0), phi); 4186 m.Store(StoreRepForType(kMachFloat64), m.PointerConstant(&buffer),
4187 m.Int32Constant(0), phi);
4172 m.Return(m.Int32Constant(magic)); 4188 m.Return(m.Int32Constant(magic));
4173 4189
4174 CHECK_EQ(magic, m.Call()); 4190 CHECK_EQ(magic, m.Call());
4175 } 4191 }
4176 4192
4177 4193
4178 TEST(RunCountToTenAccRaw) { 4194 TEST(RunCountToTenAccRaw) {
4179 RawMachineAssemblerTester<int32_t> m; 4195 RawMachineAssemblerTester<int32_t> m;
4180 4196
4181 Node* zero = m.Int32Constant(0); 4197 Node* zero = m.Int32Constant(0);
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
4455 } 4471 }
4456 4472
4457 4473
4458 template <typename IntType, MachineType kRepresentation> 4474 template <typename IntType, MachineType kRepresentation>
4459 static void LoadStoreTruncation() { 4475 static void LoadStoreTruncation() {
4460 IntType input; 4476 IntType input;
4461 4477
4462 RawMachineAssemblerTester<int32_t> m; 4478 RawMachineAssemblerTester<int32_t> m;
4463 Node* a = m.LoadFromPointer(&input, kRepresentation); 4479 Node* a = m.LoadFromPointer(&input, kRepresentation);
4464 Node* ap1 = m.Int32Add(a, m.Int32Constant(1)); 4480 Node* ap1 = m.Int32Add(a, m.Int32Constant(1));
4465 m.StoreToPointer(&input, kRepresentation, ap1); 4481 m.StoreToPointer(&input, StoreRepForType(kRepresentation), ap1);
4466 m.Return(ap1); 4482 m.Return(ap1);
4467 4483
4468 const IntType max = std::numeric_limits<IntType>::max(); 4484 const IntType max = std::numeric_limits<IntType>::max();
4469 const IntType min = std::numeric_limits<IntType>::min(); 4485 const IntType min = std::numeric_limits<IntType>::min();
4470 4486
4471 // Test upper bound. 4487 // Test upper bound.
4472 input = max; 4488 input = max;
4473 CHECK_EQ(max + 1, m.Call()); 4489 CHECK_EQ(max + 1, m.Call());
4474 CHECK_EQ(min, input); 4490 CHECK_EQ(min, input);
4475 4491
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
4558 int32_t outputs[kInputSize]; 4574 int32_t outputs[kInputSize];
4559 for (int i = 0; i < kInputSize; i++) { 4575 for (int i = 0; i < kInputSize; i++) {
4560 inputs[i] = i; 4576 inputs[i] = i;
4561 outputs[i] = -1; 4577 outputs[i] = -1;
4562 } 4578 }
4563 RawMachineAssemblerTester<int32_t*> m; 4579 RawMachineAssemblerTester<int32_t*> m;
4564 Node* input = m.PointerConstant(&inputs[0]); 4580 Node* input = m.PointerConstant(&inputs[0]);
4565 Node* output = m.PointerConstant(&outputs[kInputSize - 1]); 4581 Node* output = m.PointerConstant(&outputs[kInputSize - 1]);
4566 Node* elem_size = m.IntPtrConstant(sizeof(inputs[0])); 4582 Node* elem_size = m.IntPtrConstant(sizeof(inputs[0]));
4567 for (int i = 0; i < kInputSize; i++) { 4583 for (int i = 0; i < kInputSize; i++) {
4568 m.Store(kMachInt32, output, m.Load(kMachInt32, input)); 4584 m.Store(StoreRepForType(kMachInt32), output, m.Load(kMachInt32, input));
4569 input = m.IntPtrAdd(input, elem_size); 4585 input = m.IntPtrAdd(input, elem_size);
4570 output = m.IntPtrSub(output, elem_size); 4586 output = m.IntPtrSub(output, elem_size);
4571 } 4587 }
4572 m.Return(input); 4588 m.Return(input);
4573 CHECK_EQ(&inputs[kInputSize], m.Call()); 4589 CHECK_EQ(&inputs[kInputSize], m.Call());
4574 for (int i = 0; i < kInputSize; i++) { 4590 for (int i = 0; i < kInputSize; i++) {
4575 CHECK_EQ(i, inputs[i]); 4591 CHECK_EQ(i, inputs[i]);
4576 CHECK_EQ(kInputSize - i - 1, outputs[i]); 4592 CHECK_EQ(kInputSize - i - 1, outputs[i]);
4577 } 4593 }
4578 } 4594 }
4579 4595
4580 4596
4581 TEST(RunSpillLotsOfThings) { 4597 TEST(RunSpillLotsOfThings) {
4582 static const int kInputSize = 1000; 4598 static const int kInputSize = 1000;
4583 RawMachineAssemblerTester<int32_t> m; 4599 RawMachineAssemblerTester<int32_t> m;
4584 Node* accs[kInputSize]; 4600 Node* accs[kInputSize];
4585 int32_t outputs[kInputSize]; 4601 int32_t outputs[kInputSize];
4586 Node* one = m.Int32Constant(1); 4602 Node* one = m.Int32Constant(1);
4587 Node* acc = one; 4603 Node* acc = one;
4588 for (int i = 0; i < kInputSize; i++) { 4604 for (int i = 0; i < kInputSize; i++) {
4589 acc = m.Int32Add(acc, one); 4605 acc = m.Int32Add(acc, one);
4590 accs[i] = acc; 4606 accs[i] = acc;
4591 } 4607 }
4592 for (int i = 0; i < kInputSize; i++) { 4608 for (int i = 0; i < kInputSize; i++) {
4593 m.StoreToPointer(&outputs[i], kMachInt32, accs[i]); 4609 m.StoreToPointer(&outputs[i], StoreRepForType(kMachInt32), accs[i]);
4594 } 4610 }
4595 m.Return(one); 4611 m.Return(one);
4596 m.Call(); 4612 m.Call();
4597 for (int i = 0; i < kInputSize; i++) { 4613 for (int i = 0; i < kInputSize; i++) {
4598 CHECK_EQ(outputs[i], i + 2); 4614 CHECK_EQ(outputs[i], i + 2);
4599 } 4615 }
4600 } 4616 }
4601 4617
4602 4618
4603 TEST(RunSpillConstantsAndParameters) { 4619 TEST(RunSpillConstantsAndParameters) {
4604 static const int kInputSize = 1000; 4620 static const int kInputSize = 1000;
4605 static const int32_t kBase = 987; 4621 static const int32_t kBase = 987;
4606 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); 4622 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32);
4607 int32_t outputs[kInputSize]; 4623 int32_t outputs[kInputSize];
4608 Node* csts[kInputSize]; 4624 Node* csts[kInputSize];
4609 Node* accs[kInputSize]; 4625 Node* accs[kInputSize];
4610 Node* acc = m.Int32Constant(0); 4626 Node* acc = m.Int32Constant(0);
4611 for (int i = 0; i < kInputSize; i++) { 4627 for (int i = 0; i < kInputSize; i++) {
4612 csts[i] = m.Int32Constant(static_cast<int32_t>(kBase + i)); 4628 csts[i] = m.Int32Constant(static_cast<int32_t>(kBase + i));
4613 } 4629 }
4614 for (int i = 0; i < kInputSize; i++) { 4630 for (int i = 0; i < kInputSize; i++) {
4615 acc = m.Int32Add(acc, csts[i]); 4631 acc = m.Int32Add(acc, csts[i]);
4616 accs[i] = acc; 4632 accs[i] = acc;
4617 } 4633 }
4618 for (int i = 0; i < kInputSize; i++) { 4634 for (int i = 0; i < kInputSize; i++) {
4619 m.StoreToPointer(&outputs[i], kMachInt32, accs[i]); 4635 m.StoreToPointer(&outputs[i], StoreRepForType(kMachInt32), accs[i]);
4620 } 4636 }
4621 m.Return(m.Int32Add(acc, m.Int32Add(m.Parameter(0), m.Parameter(1)))); 4637 m.Return(m.Int32Add(acc, m.Int32Add(m.Parameter(0), m.Parameter(1))));
4622 FOR_INT32_INPUTS(i) { 4638 FOR_INT32_INPUTS(i) {
4623 FOR_INT32_INPUTS(j) { 4639 FOR_INT32_INPUTS(j) {
4624 int32_t expected = *i + *j; 4640 int32_t expected = *i + *j;
4625 for (int k = 0; k < kInputSize; k++) { 4641 for (int k = 0; k < kInputSize; k++) {
4626 expected += kBase + k; 4642 expected += kBase + k;
4627 } 4643 }
4628 CHECK_EQ(expected, m.Call(*i, *j)); 4644 CHECK_EQ(expected, m.Call(*i, *j));
4629 expected = 0; 4645 expected = 0;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
4661 } 4677 }
4662 4678
4663 4679
4664 TEST(RunInt32AddWithOverflowP) { 4680 TEST(RunInt32AddWithOverflowP) {
4665 int32_t actual_val = -1; 4681 int32_t actual_val = -1;
4666 RawMachineAssemblerTester<int32_t> m; 4682 RawMachineAssemblerTester<int32_t> m;
4667 Int32BinopTester bt(&m); 4683 Int32BinopTester bt(&m);
4668 Node* add = m.Int32AddWithOverflow(bt.param0, bt.param1); 4684 Node* add = m.Int32AddWithOverflow(bt.param0, bt.param1);
4669 Node* val = m.Projection(0, add); 4685 Node* val = m.Projection(0, add);
4670 Node* ovf = m.Projection(1, add); 4686 Node* ovf = m.Projection(1, add);
4671 m.StoreToPointer(&actual_val, kMachInt32, val); 4687 m.StoreToPointer(&actual_val, StoreRepForType(kMachInt32), val);
4672 bt.AddReturn(ovf); 4688 bt.AddReturn(ovf);
4673 FOR_INT32_INPUTS(i) { 4689 FOR_INT32_INPUTS(i) {
4674 FOR_INT32_INPUTS(j) { 4690 FOR_INT32_INPUTS(j) {
4675 int32_t expected_val; 4691 int32_t expected_val;
4676 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); 4692 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val);
4677 CHECK_EQ(expected_ovf, bt.call(*i, *j)); 4693 CHECK_EQ(expected_ovf, bt.call(*i, *j));
4678 CHECK_EQ(expected_val, actual_val); 4694 CHECK_EQ(expected_val, actual_val);
4679 } 4695 }
4680 } 4696 }
4681 } 4697 }
4682 4698
4683 4699
4684 TEST(RunInt32AddWithOverflowImm) { 4700 TEST(RunInt32AddWithOverflowImm) {
4685 int32_t actual_val = -1, expected_val = 0; 4701 int32_t actual_val = -1, expected_val = 0;
4686 FOR_INT32_INPUTS(i) { 4702 FOR_INT32_INPUTS(i) {
4687 { 4703 {
4688 RawMachineAssemblerTester<int32_t> m(kMachInt32); 4704 RawMachineAssemblerTester<int32_t> m(kMachInt32);
4689 Node* add = m.Int32AddWithOverflow(m.Int32Constant(*i), m.Parameter(0)); 4705 Node* add = m.Int32AddWithOverflow(m.Int32Constant(*i), m.Parameter(0));
4690 Node* val = m.Projection(0, add); 4706 Node* val = m.Projection(0, add);
4691 Node* ovf = m.Projection(1, add); 4707 Node* ovf = m.Projection(1, add);
4692 m.StoreToPointer(&actual_val, kMachInt32, val); 4708 m.StoreToPointer(&actual_val, StoreRepForType(kMachInt32), val);
4693 m.Return(ovf); 4709 m.Return(ovf);
4694 FOR_INT32_INPUTS(j) { 4710 FOR_INT32_INPUTS(j) {
4695 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); 4711 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val);
4696 CHECK_EQ(expected_ovf, m.Call(*j)); 4712 CHECK_EQ(expected_ovf, m.Call(*j));
4697 CHECK_EQ(expected_val, actual_val); 4713 CHECK_EQ(expected_val, actual_val);
4698 } 4714 }
4699 } 4715 }
4700 { 4716 {
4701 RawMachineAssemblerTester<int32_t> m(kMachInt32); 4717 RawMachineAssemblerTester<int32_t> m(kMachInt32);
4702 Node* add = m.Int32AddWithOverflow(m.Parameter(0), m.Int32Constant(*i)); 4718 Node* add = m.Int32AddWithOverflow(m.Parameter(0), m.Int32Constant(*i));
4703 Node* val = m.Projection(0, add); 4719 Node* val = m.Projection(0, add);
4704 Node* ovf = m.Projection(1, add); 4720 Node* ovf = m.Projection(1, add);
4705 m.StoreToPointer(&actual_val, kMachInt32, val); 4721 m.StoreToPointer(&actual_val, StoreRepForType(kMachInt32), val);
4706 m.Return(ovf); 4722 m.Return(ovf);
4707 FOR_INT32_INPUTS(j) { 4723 FOR_INT32_INPUTS(j) {
4708 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); 4724 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val);
4709 CHECK_EQ(expected_ovf, m.Call(*j)); 4725 CHECK_EQ(expected_ovf, m.Call(*j));
4710 CHECK_EQ(expected_val, actual_val); 4726 CHECK_EQ(expected_val, actual_val);
4711 } 4727 }
4712 } 4728 }
4713 FOR_INT32_INPUTS(j) { 4729 FOR_INT32_INPUTS(j) {
4714 RawMachineAssemblerTester<int32_t> m; 4730 RawMachineAssemblerTester<int32_t> m;
4715 Node* add = 4731 Node* add =
4716 m.Int32AddWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j)); 4732 m.Int32AddWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j));
4717 Node* val = m.Projection(0, add); 4733 Node* val = m.Projection(0, add);
4718 Node* ovf = m.Projection(1, add); 4734 Node* ovf = m.Projection(1, add);
4719 m.StoreToPointer(&actual_val, kMachInt32, val); 4735 m.StoreToPointer(&actual_val, StoreRepForType(kMachInt32), val);
4720 m.Return(ovf); 4736 m.Return(ovf);
4721 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val); 4737 int expected_ovf = bits::SignedAddOverflow32(*i, *j, &expected_val);
4722 CHECK_EQ(expected_ovf, m.Call()); 4738 CHECK_EQ(expected_ovf, m.Call());
4723 CHECK_EQ(expected_val, actual_val); 4739 CHECK_EQ(expected_val, actual_val);
4724 } 4740 }
4725 } 4741 }
4726 } 4742 }
4727 4743
4728 4744
4729 TEST(RunInt32AddWithOverflowInBranchP) { 4745 TEST(RunInt32AddWithOverflowInBranchP) {
(...skipping 19 matching lines...) Expand all
4749 } 4765 }
4750 4766
4751 4767
4752 TEST(RunInt32SubWithOverflowP) { 4768 TEST(RunInt32SubWithOverflowP) {
4753 int32_t actual_val = -1; 4769 int32_t actual_val = -1;
4754 RawMachineAssemblerTester<int32_t> m; 4770 RawMachineAssemblerTester<int32_t> m;
4755 Int32BinopTester bt(&m); 4771 Int32BinopTester bt(&m);
4756 Node* add = m.Int32SubWithOverflow(bt.param0, bt.param1); 4772 Node* add = m.Int32SubWithOverflow(bt.param0, bt.param1);
4757 Node* val = m.Projection(0, add); 4773 Node* val = m.Projection(0, add);
4758 Node* ovf = m.Projection(1, add); 4774 Node* ovf = m.Projection(1, add);
4759 m.StoreToPointer(&actual_val, kMachInt32, val); 4775 m.StoreToPointer(&actual_val, StoreRepForType(kMachInt32), val);
4760 bt.AddReturn(ovf); 4776 bt.AddReturn(ovf);
4761 FOR_INT32_INPUTS(i) { 4777 FOR_INT32_INPUTS(i) {
4762 FOR_INT32_INPUTS(j) { 4778 FOR_INT32_INPUTS(j) {
4763 int32_t expected_val; 4779 int32_t expected_val;
4764 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); 4780 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val);
4765 CHECK_EQ(expected_ovf, bt.call(*i, *j)); 4781 CHECK_EQ(expected_ovf, bt.call(*i, *j));
4766 CHECK_EQ(expected_val, actual_val); 4782 CHECK_EQ(expected_val, actual_val);
4767 } 4783 }
4768 } 4784 }
4769 } 4785 }
4770 4786
4771 4787
4772 TEST(RunInt32SubWithOverflowImm) { 4788 TEST(RunInt32SubWithOverflowImm) {
4773 int32_t actual_val = -1, expected_val = 0; 4789 int32_t actual_val = -1, expected_val = 0;
4774 FOR_INT32_INPUTS(i) { 4790 FOR_INT32_INPUTS(i) {
4775 { 4791 {
4776 RawMachineAssemblerTester<int32_t> m(kMachInt32); 4792 RawMachineAssemblerTester<int32_t> m(kMachInt32);
4777 Node* add = m.Int32SubWithOverflow(m.Int32Constant(*i), m.Parameter(0)); 4793 Node* add = m.Int32SubWithOverflow(m.Int32Constant(*i), m.Parameter(0));
4778 Node* val = m.Projection(0, add); 4794 Node* val = m.Projection(0, add);
4779 Node* ovf = m.Projection(1, add); 4795 Node* ovf = m.Projection(1, add);
4780 m.StoreToPointer(&actual_val, kMachInt32, val); 4796 m.StoreToPointer(&actual_val, StoreRepForType(kMachInt32), val);
4781 m.Return(ovf); 4797 m.Return(ovf);
4782 FOR_INT32_INPUTS(j) { 4798 FOR_INT32_INPUTS(j) {
4783 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); 4799 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val);
4784 CHECK_EQ(expected_ovf, m.Call(*j)); 4800 CHECK_EQ(expected_ovf, m.Call(*j));
4785 CHECK_EQ(expected_val, actual_val); 4801 CHECK_EQ(expected_val, actual_val);
4786 } 4802 }
4787 } 4803 }
4788 { 4804 {
4789 RawMachineAssemblerTester<int32_t> m(kMachInt32); 4805 RawMachineAssemblerTester<int32_t> m(kMachInt32);
4790 Node* add = m.Int32SubWithOverflow(m.Parameter(0), m.Int32Constant(*i)); 4806 Node* add = m.Int32SubWithOverflow(m.Parameter(0), m.Int32Constant(*i));
4791 Node* val = m.Projection(0, add); 4807 Node* val = m.Projection(0, add);
4792 Node* ovf = m.Projection(1, add); 4808 Node* ovf = m.Projection(1, add);
4793 m.StoreToPointer(&actual_val, kMachInt32, val); 4809 m.StoreToPointer(&actual_val, StoreRepForType(kMachInt32), val);
4794 m.Return(ovf); 4810 m.Return(ovf);
4795 FOR_INT32_INPUTS(j) { 4811 FOR_INT32_INPUTS(j) {
4796 int expected_ovf = bits::SignedSubOverflow32(*j, *i, &expected_val); 4812 int expected_ovf = bits::SignedSubOverflow32(*j, *i, &expected_val);
4797 CHECK_EQ(expected_ovf, m.Call(*j)); 4813 CHECK_EQ(expected_ovf, m.Call(*j));
4798 CHECK_EQ(expected_val, actual_val); 4814 CHECK_EQ(expected_val, actual_val);
4799 } 4815 }
4800 } 4816 }
4801 FOR_INT32_INPUTS(j) { 4817 FOR_INT32_INPUTS(j) {
4802 RawMachineAssemblerTester<int32_t> m; 4818 RawMachineAssemblerTester<int32_t> m;
4803 Node* add = 4819 Node* add =
4804 m.Int32SubWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j)); 4820 m.Int32SubWithOverflow(m.Int32Constant(*i), m.Int32Constant(*j));
4805 Node* val = m.Projection(0, add); 4821 Node* val = m.Projection(0, add);
4806 Node* ovf = m.Projection(1, add); 4822 Node* ovf = m.Projection(1, add);
4807 m.StoreToPointer(&actual_val, kMachInt32, val); 4823 m.StoreToPointer(&actual_val, StoreRepForType(kMachInt32), val);
4808 m.Return(ovf); 4824 m.Return(ovf);
4809 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val); 4825 int expected_ovf = bits::SignedSubOverflow32(*i, *j, &expected_val);
4810 CHECK_EQ(expected_ovf, m.Call()); 4826 CHECK_EQ(expected_ovf, m.Call());
4811 CHECK_EQ(expected_val, actual_val); 4827 CHECK_EQ(expected_val, actual_val);
4812 } 4828 }
4813 } 4829 }
4814 } 4830 }
4815 4831
4816 4832
4817 TEST(RunInt32SubWithOverflowInBranchP) { 4833 TEST(RunInt32SubWithOverflowInBranchP) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
4854 CHECK_EQ(2, m.Call()); 4870 CHECK_EQ(2, m.Call());
4855 input = V8_INT64_C(0x100000000); 4871 input = V8_INT64_C(0x100000000);
4856 CHECK_EQ(2, m.Call()); 4872 CHECK_EQ(2, m.Call());
4857 } 4873 }
4858 4874
4859 4875
4860 TEST(RunChangeInt32ToInt64P) { 4876 TEST(RunChangeInt32ToInt64P) {
4861 if (kPointerSize < 8) return; 4877 if (kPointerSize < 8) return;
4862 int64_t actual = -1; 4878 int64_t actual = -1;
4863 RawMachineAssemblerTester<int32_t> m(kMachInt32); 4879 RawMachineAssemblerTester<int32_t> m(kMachInt32);
4864 m.StoreToPointer(&actual, kMachInt64, m.ChangeInt32ToInt64(m.Parameter(0))); 4880 m.StoreToPointer(&actual, StoreRepForType(kMachInt64),
4881 m.ChangeInt32ToInt64(m.Parameter(0)));
4865 m.Return(m.Int32Constant(0)); 4882 m.Return(m.Int32Constant(0));
4866 FOR_INT32_INPUTS(i) { 4883 FOR_INT32_INPUTS(i) {
4867 int64_t expected = *i; 4884 int64_t expected = *i;
4868 CHECK_EQ(0, m.Call(*i)); 4885 CHECK_EQ(0, m.Call(*i));
4869 CHECK_EQ(expected, actual); 4886 CHECK_EQ(expected, actual);
4870 } 4887 }
4871 } 4888 }
4872 4889
4873 4890
4874 TEST(RunChangeUint32ToUint64P) { 4891 TEST(RunChangeUint32ToUint64P) {
4875 if (kPointerSize < 8) return; 4892 if (kPointerSize < 8) return;
4876 int64_t actual = -1; 4893 int64_t actual = -1;
4877 RawMachineAssemblerTester<int32_t> m(kMachUint32); 4894 RawMachineAssemblerTester<int32_t> m(kMachUint32);
4878 m.StoreToPointer(&actual, kMachUint64, 4895 m.StoreToPointer(&actual, StoreRepForType(kMachUint64),
4879 m.ChangeUint32ToUint64(m.Parameter(0))); 4896 m.ChangeUint32ToUint64(m.Parameter(0)));
4880 m.Return(m.Int32Constant(0)); 4897 m.Return(m.Int32Constant(0));
4881 FOR_UINT32_INPUTS(i) { 4898 FOR_UINT32_INPUTS(i) {
4882 int64_t expected = static_cast<uint64_t>(*i); 4899 int64_t expected = static_cast<uint64_t>(*i);
4883 CHECK_EQ(0, m.Call(*i)); 4900 CHECK_EQ(0, m.Call(*i));
4884 CHECK_EQ(expected, actual); 4901 CHECK_EQ(expected, actual);
4885 } 4902 }
4886 } 4903 }
4887 4904
4888 4905
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
4969 CHECK_EQ(static_cast<int>(expected), m.Call()); 4986 CHECK_EQ(static_cast<int>(expected), m.Call());
4970 } 4987 }
4971 } 4988 }
4972 4989
4973 4990
4974 TEST(RunChangeFloat32ToFloat64) { 4991 TEST(RunChangeFloat32ToFloat64) {
4975 double actual = 0.0f; 4992 double actual = 0.0f;
4976 float expected = 0.0; 4993 float expected = 0.0;
4977 RawMachineAssemblerTester<int32_t> m; 4994 RawMachineAssemblerTester<int32_t> m;
4978 m.StoreToPointer( 4995 m.StoreToPointer(
4979 &actual, kMachFloat64, 4996 &actual, StoreRepForType(kMachFloat64),
4980 m.ChangeFloat32ToFloat64(m.LoadFromPointer(&expected, kMachFloat32))); 4997 m.ChangeFloat32ToFloat64(m.LoadFromPointer(&expected, kMachFloat32)));
4981 m.Return(m.Int32Constant(0)); 4998 m.Return(m.Int32Constant(0));
4982 FOR_FLOAT32_INPUTS(i) { 4999 FOR_FLOAT32_INPUTS(i) {
4983 expected = *i; 5000 expected = *i;
4984 CHECK_EQ(0, m.Call()); 5001 CHECK_EQ(0, m.Call());
4985 CHECK_EQ(static_cast<double>(expected), actual); 5002 CHECK_EQ(static_cast<double>(expected), actual);
4986 } 5003 }
4987 } 5004 }
4988 5005
4989 5006
4990 TEST(RunChangeFloat32ToFloat64_spilled) { 5007 TEST(RunChangeFloat32ToFloat64_spilled) {
4991 RawMachineAssemblerTester<int32_t> m; 5008 RawMachineAssemblerTester<int32_t> m;
4992 const int kNumInputs = 32; 5009 const int kNumInputs = 32;
4993 int32_t magic = 0x786234; 5010 int32_t magic = 0x786234;
4994 float input[kNumInputs]; 5011 float input[kNumInputs];
4995 double result[kNumInputs]; 5012 double result[kNumInputs];
4996 Node* input_node[kNumInputs]; 5013 Node* input_node[kNumInputs];
4997 5014
4998 for (int i = 0; i < kNumInputs; i++) { 5015 for (int i = 0; i < kNumInputs; i++) {
4999 input_node[i] = 5016 input_node[i] =
5000 m.Load(kMachFloat32, m.PointerConstant(&input), m.Int32Constant(i * 4)); 5017 m.Load(kMachFloat32, m.PointerConstant(&input), m.Int32Constant(i * 4));
5001 } 5018 }
5002 5019
5003 for (int i = 0; i < kNumInputs; i++) { 5020 for (int i = 0; i < kNumInputs; i++) {
5004 m.Store(kMachFloat64, m.PointerConstant(&result), m.Int32Constant(i * 8), 5021 m.Store(StoreRepForType(kMachFloat64), m.PointerConstant(&result),
5005 m.ChangeFloat32ToFloat64(input_node[i])); 5022 m.Int32Constant(i * 8), m.ChangeFloat32ToFloat64(input_node[i]));
5006 } 5023 }
5007 5024
5008 m.Return(m.Int32Constant(magic)); 5025 m.Return(m.Int32Constant(magic));
5009 5026
5010 for (int i = 0; i < kNumInputs; i++) { 5027 for (int i = 0; i < kNumInputs; i++) {
5011 input[i] = 100.9f + i; 5028 input[i] = 100.9f + i;
5012 } 5029 }
5013 5030
5014 CHECK_EQ(magic, m.Call()); 5031 CHECK_EQ(magic, m.Call());
5015 5032
5016 for (int i = 0; i < kNumInputs; i++) { 5033 for (int i = 0; i < kNumInputs; i++) {
5017 CHECK_EQ(result[i], static_cast<double>(input[i])); 5034 CHECK_EQ(result[i], static_cast<double>(input[i]));
5018 } 5035 }
5019 } 5036 }
5020 5037
5021 5038
5022 TEST(RunTruncateFloat64ToFloat32) { 5039 TEST(RunTruncateFloat64ToFloat32) {
5023 float actual = 0.0f; 5040 float actual = 0.0f;
5024 double input = 0.0; 5041 double input = 0.0;
5025 RawMachineAssemblerTester<int32_t> m; 5042 RawMachineAssemblerTester<int32_t> m;
5026 m.StoreToPointer( 5043 m.StoreToPointer(
5027 &actual, kMachFloat32, 5044 &actual, StoreRepForType(kMachFloat32),
5028 m.TruncateFloat64ToFloat32(m.LoadFromPointer(&input, kMachFloat64))); 5045 m.TruncateFloat64ToFloat32(m.LoadFromPointer(&input, kMachFloat64)));
5029 m.Return(m.Int32Constant(0)); 5046 m.Return(m.Int32Constant(0));
5030 FOR_FLOAT64_INPUTS(i) { 5047 FOR_FLOAT64_INPUTS(i) {
5031 input = *i; 5048 input = *i;
5032 volatile double expected = DoubleToFloat32(input); 5049 volatile double expected = DoubleToFloat32(input);
5033 CHECK_EQ(0, m.Call()); 5050 CHECK_EQ(0, m.Call());
5034 CheckDoubleEq(expected, actual); 5051 CheckDoubleEq(expected, actual);
5035 } 5052 }
5036 } 5053 }
5037 5054
5038 5055
5039 TEST(RunFloat32Constant) { 5056 TEST(RunFloat32Constant) {
5040 FOR_FLOAT32_INPUTS(i) { 5057 FOR_FLOAT32_INPUTS(i) {
5041 float expected = *i; 5058 float expected = *i;
5042 float actual = *i; 5059 float actual = *i;
5043 RawMachineAssemblerTester<int32_t> m; 5060 RawMachineAssemblerTester<int32_t> m;
5044 m.StoreToPointer(&actual, kMachFloat32, m.Float32Constant(expected)); 5061 m.StoreToPointer(&actual, StoreRepForType(kMachFloat32),
5062 m.Float32Constant(expected));
5045 m.Return(m.Int32Constant(0)); 5063 m.Return(m.Int32Constant(0));
5046 CHECK_EQ(0, m.Call()); 5064 CHECK_EQ(0, m.Call());
5047 CHECK_EQ(expected, actual); 5065 CHECK_EQ(expected, actual);
5048 } 5066 }
5049 } 5067 }
5050 5068
5051 5069
5052 TEST(RunFloat64ExtractLowWord32) { 5070 TEST(RunFloat64ExtractLowWord32) {
5053 uint64_t input = 0; 5071 uint64_t input = 0;
5054 RawMachineAssemblerTester<int32_t> m; 5072 RawMachineAssemblerTester<int32_t> m;
(...skipping 16 matching lines...) Expand all
5071 CHECK_EQ(expected, m.Call()); 5089 CHECK_EQ(expected, m.Call());
5072 } 5090 }
5073 } 5091 }
5074 5092
5075 5093
5076 TEST(RunFloat64InsertLowWord32) { 5094 TEST(RunFloat64InsertLowWord32) {
5077 uint64_t input = 0; 5095 uint64_t input = 0;
5078 uint64_t result = 0; 5096 uint64_t result = 0;
5079 RawMachineAssemblerTester<int32_t> m(kMachInt32); 5097 RawMachineAssemblerTester<int32_t> m(kMachInt32);
5080 m.StoreToPointer( 5098 m.StoreToPointer(
5081 &result, kMachFloat64, 5099 &result, StoreRepForType(kMachFloat64),
5082 m.Float64InsertLowWord32(m.LoadFromPointer(&input, kMachFloat64), 5100 m.Float64InsertLowWord32(m.LoadFromPointer(&input, kMachFloat64),
5083 m.Parameter(0))); 5101 m.Parameter(0)));
5084 m.Return(m.Int32Constant(0)); 5102 m.Return(m.Int32Constant(0));
5085 FOR_FLOAT64_INPUTS(i) { 5103 FOR_FLOAT64_INPUTS(i) {
5086 FOR_INT32_INPUTS(j) { 5104 FOR_INT32_INPUTS(j) {
5087 input = bit_cast<uint64_t>(*i); 5105 input = bit_cast<uint64_t>(*i);
5088 uint64_t expected = (input & ~(V8_UINT64_C(0xFFFFFFFF))) | 5106 uint64_t expected = (input & ~(V8_UINT64_C(0xFFFFFFFF))) |
5089 (static_cast<uint64_t>(bit_cast<uint32_t>(*j))); 5107 (static_cast<uint64_t>(bit_cast<uint32_t>(*j)));
5090 CHECK_EQ(0, m.Call(*j)); 5108 CHECK_EQ(0, m.Call(*j));
5091 CHECK_EQ(expected, result); 5109 CHECK_EQ(expected, result);
5092 } 5110 }
5093 } 5111 }
5094 } 5112 }
5095 5113
5096 5114
5097 TEST(RunFloat64InsertHighWord32) { 5115 TEST(RunFloat64InsertHighWord32) {
5098 uint64_t input = 0; 5116 uint64_t input = 0;
5099 uint64_t result = 0; 5117 uint64_t result = 0;
5100 RawMachineAssemblerTester<int32_t> m(kMachInt32); 5118 RawMachineAssemblerTester<int32_t> m(kMachInt32);
5101 m.StoreToPointer( 5119 m.StoreToPointer(
5102 &result, kMachFloat64, 5120 &result, StoreRepForType(kMachFloat64),
5103 m.Float64InsertHighWord32(m.LoadFromPointer(&input, kMachFloat64), 5121 m.Float64InsertHighWord32(m.LoadFromPointer(&input, kMachFloat64),
5104 m.Parameter(0))); 5122 m.Parameter(0)));
5105 m.Return(m.Int32Constant(0)); 5123 m.Return(m.Int32Constant(0));
5106 FOR_FLOAT64_INPUTS(i) { 5124 FOR_FLOAT64_INPUTS(i) {
5107 FOR_INT32_INPUTS(j) { 5125 FOR_INT32_INPUTS(j) {
5108 input = bit_cast<uint64_t>(*i); 5126 input = bit_cast<uint64_t>(*i);
5109 uint64_t expected = (input & ~(V8_UINT64_C(0xFFFFFFFF) << 32)) | 5127 uint64_t expected = (input & ~(V8_UINT64_C(0xFFFFFFFF) << 32)) |
5110 (static_cast<uint64_t>(bit_cast<uint32_t>(*j)) << 32); 5128 (static_cast<uint64_t>(bit_cast<uint32_t>(*j)) << 32);
5111 CHECK_EQ(0, m.Call(*j)); 5129 CHECK_EQ(0, m.Call(*j));
5112 CHECK_EQ(expected, result); 5130 CHECK_EQ(expected, result);
5113 } 5131 }
5114 } 5132 }
5115 } 5133 }
5116 5134
5117 5135
5118 TEST(RunFloat32Abs) { 5136 TEST(RunFloat32Abs) {
5119 float input = -1.0; 5137 float input = -1.0;
5120 float result = 0.0; 5138 float result = 0.0;
5121 RawMachineAssemblerTester<int32_t> m; 5139 RawMachineAssemblerTester<int32_t> m;
5122 m.StoreToPointer(&result, kMachFloat32, 5140 m.StoreToPointer(&result, StoreRepForType(kMachFloat32),
5123 m.Float32Abs(m.LoadFromPointer(&input, kMachFloat32))); 5141 m.Float32Abs(m.LoadFromPointer(&input, kMachFloat32)));
5124 m.Return(m.Int32Constant(0)); 5142 m.Return(m.Int32Constant(0));
5125 FOR_FLOAT32_INPUTS(i) { 5143 FOR_FLOAT32_INPUTS(i) {
5126 input = *i; 5144 input = *i;
5127 float expected = std::abs(input); 5145 float expected = std::abs(input);
5128 CHECK_EQ(0, m.Call()); 5146 CHECK_EQ(0, m.Call());
5129 CheckFloatEq(expected, result); 5147 CheckFloatEq(expected, result);
5130 } 5148 }
5131 } 5149 }
5132 5150
5133 5151
5134 TEST(RunFloat64Abs) { 5152 TEST(RunFloat64Abs) {
5135 double input = -1.0; 5153 double input = -1.0;
5136 double result = 0.0; 5154 double result = 0.0;
5137 RawMachineAssemblerTester<int32_t> m; 5155 RawMachineAssemblerTester<int32_t> m;
5138 m.StoreToPointer(&result, kMachFloat64, 5156 m.StoreToPointer(&result, StoreRepForType(kMachFloat64),
5139 m.Float64Abs(m.LoadFromPointer(&input, kMachFloat64))); 5157 m.Float64Abs(m.LoadFromPointer(&input, kMachFloat64)));
5140 m.Return(m.Int32Constant(0)); 5158 m.Return(m.Int32Constant(0));
5141 FOR_FLOAT64_INPUTS(i) { 5159 FOR_FLOAT64_INPUTS(i) {
5142 input = *i; 5160 input = *i;
5143 double expected = std::abs(input); 5161 double expected = std::abs(input);
5144 CHECK_EQ(0, m.Call()); 5162 CHECK_EQ(0, m.Call());
5145 CheckDoubleEq(expected, result); 5163 CheckDoubleEq(expected, result);
5146 } 5164 }
5147 } 5165 }
5148 5166
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
5243 -two_52 + 1 - 0.1, 5261 -two_52 + 1 - 0.1,
5244 -two_52 + 1 - 0.5, 5262 -two_52 + 1 - 0.5,
5245 -two_52 + 1 - 0.7}; 5263 -two_52 + 1 - 0.7};
5246 5264
5247 5265
5248 TEST(RunFloat64RoundDown1) { 5266 TEST(RunFloat64RoundDown1) {
5249 double input = -1.0; 5267 double input = -1.0;
5250 double result = 0.0; 5268 double result = 0.0;
5251 RawMachineAssemblerTester<int32_t> m; 5269 RawMachineAssemblerTester<int32_t> m;
5252 if (!m.machine()->Float64RoundDown().IsSupported()) return; 5270 if (!m.machine()->Float64RoundDown().IsSupported()) return;
5253 m.StoreToPointer(&result, kMachFloat64, 5271 m.StoreToPointer(&result, StoreRepForType(kMachFloat64),
5254 m.Float64RoundDown(m.LoadFromPointer(&input, kMachFloat64))); 5272 m.Float64RoundDown(m.LoadFromPointer(&input, kMachFloat64)));
5255 m.Return(m.Int32Constant(0)); 5273 m.Return(m.Int32Constant(0));
5256 for (size_t i = 0; i < arraysize(kValues); ++i) { 5274 for (size_t i = 0; i < arraysize(kValues); ++i) {
5257 input = kValues[i]; 5275 input = kValues[i];
5258 CHECK_EQ(0, m.Call()); 5276 CHECK_EQ(0, m.Call());
5259 double expected = std::floor(kValues[i]); 5277 double expected = std::floor(kValues[i]);
5260 CHECK_EQ(expected, result); 5278 CHECK_EQ(expected, result);
5261 } 5279 }
5262 } 5280 }
5263 5281
5264 5282
5265 TEST(RunFloat64RoundDown2) { 5283 TEST(RunFloat64RoundDown2) {
5266 double input = -1.0; 5284 double input = -1.0;
5267 double result = 0.0; 5285 double result = 0.0;
5268 RawMachineAssemblerTester<int32_t> m; 5286 RawMachineAssemblerTester<int32_t> m;
5269 if (!m.machine()->Float64RoundDown().IsSupported()) return; 5287 if (!m.machine()->Float64RoundDown().IsSupported()) return;
5270 m.StoreToPointer(&result, kMachFloat64, 5288 m.StoreToPointer(&result, StoreRepForType(kMachFloat64),
5271 m.Float64Sub(m.Float64Constant(-0.0), 5289 m.Float64Sub(m.Float64Constant(-0.0),
5272 m.Float64RoundDown(m.Float64Sub( 5290 m.Float64RoundDown(m.Float64Sub(
5273 m.Float64Constant(-0.0), 5291 m.Float64Constant(-0.0),
5274 m.LoadFromPointer(&input, kMachFloat64))))); 5292 m.LoadFromPointer(&input, kMachFloat64)))));
5275 m.Return(m.Int32Constant(0)); 5293 m.Return(m.Int32Constant(0));
5276 for (size_t i = 0; i < arraysize(kValues); ++i) { 5294 for (size_t i = 0; i < arraysize(kValues); ++i) {
5277 input = kValues[i]; 5295 input = kValues[i];
5278 CHECK_EQ(0, m.Call()); 5296 CHECK_EQ(0, m.Call());
5279 double expected = std::ceil(kValues[i]); 5297 double expected = std::ceil(kValues[i]);
5280 CHECK_EQ(expected, result); 5298 CHECK_EQ(expected, result);
5281 } 5299 }
5282 } 5300 }
5283 5301
5284 5302
5285 TEST(RunFloat64RoundTruncate) { 5303 TEST(RunFloat64RoundTruncate) {
5286 double input = -1.0; 5304 double input = -1.0;
5287 double result = 0.0; 5305 double result = 0.0;
5288 RawMachineAssemblerTester<int32_t> m; 5306 RawMachineAssemblerTester<int32_t> m;
5289 if (!m.machine()->Float64RoundTruncate().IsSupported()) return; 5307 if (!m.machine()->Float64RoundTruncate().IsSupported()) return;
5290 m.StoreToPointer( 5308 m.StoreToPointer(
5291 &result, kMachFloat64, 5309 &result, StoreRepForType(kMachFloat64),
5292 m.Float64RoundTruncate(m.LoadFromPointer(&input, kMachFloat64))); 5310 m.Float64RoundTruncate(m.LoadFromPointer(&input, kMachFloat64)));
5293 m.Return(m.Int32Constant(0)); 5311 m.Return(m.Int32Constant(0));
5294 for (size_t i = 0; i < arraysize(kValues); ++i) { 5312 for (size_t i = 0; i < arraysize(kValues); ++i) {
5295 input = kValues[i]; 5313 input = kValues[i];
5296 CHECK_EQ(0, m.Call()); 5314 CHECK_EQ(0, m.Call());
5297 double expected = trunc(kValues[i]); 5315 double expected = trunc(kValues[i]);
5298 CHECK_EQ(expected, result); 5316 CHECK_EQ(expected, result);
5299 } 5317 }
5300 } 5318 }
5301 5319
5302 5320
5303 TEST(RunFloat64RoundTiesAway) { 5321 TEST(RunFloat64RoundTiesAway) {
5304 double input = -1.0; 5322 double input = -1.0;
5305 double result = 0.0; 5323 double result = 0.0;
5306 RawMachineAssemblerTester<int32_t> m; 5324 RawMachineAssemblerTester<int32_t> m;
5307 if (!m.machine()->Float64RoundTiesAway().IsSupported()) return; 5325 if (!m.machine()->Float64RoundTiesAway().IsSupported()) return;
5308 m.StoreToPointer( 5326 m.StoreToPointer(
5309 &result, kMachFloat64, 5327 &result, StoreRepForType(kMachFloat64),
5310 m.Float64RoundTiesAway(m.LoadFromPointer(&input, kMachFloat64))); 5328 m.Float64RoundTiesAway(m.LoadFromPointer(&input, kMachFloat64)));
5311 m.Return(m.Int32Constant(0)); 5329 m.Return(m.Int32Constant(0));
5312 for (size_t i = 0; i < arraysize(kValues); ++i) { 5330 for (size_t i = 0; i < arraysize(kValues); ++i) {
5313 input = kValues[i]; 5331 input = kValues[i];
5314 CHECK_EQ(0, m.Call()); 5332 CHECK_EQ(0, m.Call());
5315 double expected = round(kValues[i]); 5333 double expected = round(kValues[i]);
5316 CHECK_EQ(expected, result); 5334 CHECK_EQ(expected, result);
5317 } 5335 }
5318 } 5336 }
5319 5337
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
5439 CHECK_EQ(write, buffer[0]); 5457 CHECK_EQ(write, buffer[0]);
5440 CHECK_EQ(write, buffer[1]); 5458 CHECK_EQ(write, buffer[1]);
5441 } 5459 }
5442 5460
5443 5461
5444 TEST(RunBitcastInt64ToFloat64) { 5462 TEST(RunBitcastInt64ToFloat64) {
5445 int64_t input = 1; 5463 int64_t input = 1;
5446 double output = 0.0; 5464 double output = 0.0;
5447 RawMachineAssemblerTester<int32_t> m; 5465 RawMachineAssemblerTester<int32_t> m;
5448 m.StoreToPointer( 5466 m.StoreToPointer(
5449 &output, kMachFloat64, 5467 &output, StoreRepForType(kMachFloat64),
5450 m.BitcastInt64ToFloat64(m.LoadFromPointer(&input, kMachInt64))); 5468 m.BitcastInt64ToFloat64(m.LoadFromPointer(&input, kMachInt64)));
5451 m.Return(m.Int32Constant(11)); 5469 m.Return(m.Int32Constant(11));
5452 FOR_INT64_INPUTS(i) { 5470 FOR_INT64_INPUTS(i) {
5453 input = *i; 5471 input = *i;
5454 CHECK_EQ(11, m.Call()); 5472 CHECK_EQ(11, m.Call());
5455 double expected = bit_cast<double>(input); 5473 double expected = bit_cast<double>(input);
5456 CHECK_EQ(bit_cast<int64_t>(expected), bit_cast<int64_t>(output)); 5474 CHECK_EQ(bit_cast<int64_t>(expected), bit_cast<int64_t>(output));
5457 } 5475 }
5458 } 5476 }
5459 5477
5460 5478
5461 TEST(RunBitcastFloat64ToInt64) { 5479 TEST(RunBitcastFloat64ToInt64) {
5462 double input = 0; 5480 double input = 0;
5463 int64_t output = 0; 5481 int64_t output = 0;
5464 RawMachineAssemblerTester<int32_t> m; 5482 RawMachineAssemblerTester<int32_t> m;
5465 m.StoreToPointer( 5483 m.StoreToPointer(
5466 &output, kMachInt64, 5484 &output, StoreRepForType(kMachInt64),
5467 m.BitcastFloat64ToInt64(m.LoadFromPointer(&input, kMachFloat64))); 5485 m.BitcastFloat64ToInt64(m.LoadFromPointer(&input, kMachFloat64)));
5468 m.Return(m.Int32Constant(11)); 5486 m.Return(m.Int32Constant(11));
5469 FOR_FLOAT64_INPUTS(i) { 5487 FOR_FLOAT64_INPUTS(i) {
5470 input = *i; 5488 input = *i;
5471 CHECK_EQ(11, m.Call()); 5489 CHECK_EQ(11, m.Call());
5472 double expected = bit_cast<int64_t>(input); 5490 double expected = bit_cast<int64_t>(input);
5473 CHECK_EQ(expected, output); 5491 CHECK_EQ(expected, output);
5474 } 5492 }
5475 } 5493 }
5476 #endif 5494 #endif
5477 5495
5478 5496
5479 TEST(RunBitcastFloat32ToInt32) { 5497 TEST(RunBitcastFloat32ToInt32) {
5480 float input = 32.25; 5498 float input = 32.25;
5481 RawMachineAssemblerTester<int32_t> m; 5499 RawMachineAssemblerTester<int32_t> m;
5482 m.Return(m.BitcastFloat32ToInt32(m.LoadFromPointer(&input, kMachFloat32))); 5500 m.Return(m.BitcastFloat32ToInt32(m.LoadFromPointer(&input, kMachFloat32)));
5483 FOR_FLOAT32_INPUTS(i) { 5501 FOR_FLOAT32_INPUTS(i) {
5484 input = *i; 5502 input = *i;
5485 int32_t expected = bit_cast<int32_t>(input); 5503 int32_t expected = bit_cast<int32_t>(input);
5486 CHECK_EQ(expected, m.Call()); 5504 CHECK_EQ(expected, m.Call());
5487 } 5505 }
5488 } 5506 }
5489 5507
5490 5508
5491 TEST(RunBitcastInt32ToFloat32) { 5509 TEST(RunBitcastInt32ToFloat32) {
5492 int32_t input = 1; 5510 int32_t input = 1;
5493 float output = 0.0; 5511 float output = 0.0;
5494 RawMachineAssemblerTester<int32_t> m; 5512 RawMachineAssemblerTester<int32_t> m;
5495 m.StoreToPointer( 5513 m.StoreToPointer(
5496 &output, kMachFloat32, 5514 &output, StoreRepForType(kMachFloat32),
5497 m.BitcastInt32ToFloat32(m.LoadFromPointer(&input, kMachInt32))); 5515 m.BitcastInt32ToFloat32(m.LoadFromPointer(&input, kMachInt32)));
5498 m.Return(m.Int32Constant(11)); 5516 m.Return(m.Int32Constant(11));
5499 FOR_INT32_INPUTS(i) { 5517 FOR_INT32_INPUTS(i) {
5500 input = *i; 5518 input = *i;
5501 CHECK_EQ(11, m.Call()); 5519 CHECK_EQ(11, m.Call());
5502 float expected = bit_cast<float>(input); 5520 float expected = bit_cast<float>(input);
5503 CHECK_EQ(bit_cast<int32_t>(expected), bit_cast<int32_t>(output)); 5521 CHECK_EQ(bit_cast<int32_t>(expected), bit_cast<int32_t>(output));
5504 } 5522 }
5505 } 5523 }
5506 5524
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
5545 c->CalleeSavedRegisters(), // callee saved 5563 c->CalleeSavedRegisters(), // callee saved
5546 c->CalleeSavedFPRegisters(), // callee saved FP 5564 c->CalleeSavedFPRegisters(), // callee saved FP
5547 CallDescriptor::kNoFlags, // flags 5565 CallDescriptor::kNoFlags, // flags
5548 "c-call-as-code"); 5566 "c-call-as-code");
5549 Node* call = r.AddNode(r.common()->Call(desc), phi); 5567 Node* call = r.AddNode(r.common()->Call(desc), phi);
5550 r.Return(call); 5568 r.Return(call);
5551 5569
5552 CHECK_EQ(33, r.Call(1)); 5570 CHECK_EQ(33, r.Call(1));
5553 CHECK_EQ(44, r.Call(0)); 5571 CHECK_EQ(44, r.Call(0));
5554 } 5572 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/codegen-tester.h ('k') | test/cctest/compiler/test-run-native-calls.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698