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

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

Issue 587273002: [turbofan] don't call out to c (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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/cctest.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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 <functional> 5 #include <functional>
6 #include <limits> 6 #include <limits>
7 7
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/compiler/generic-node-inl.h" 9 #include "src/compiler/generic-node-inl.h"
10 #include "test/cctest/cctest.h" 10 #include "test/cctest/cctest.h"
(...skipping 3549 matching lines...) Expand 10 before | Expand all | Expand 10 after
3560 Node* i6 = m.Int32Add(i3, i4); 3560 Node* i6 = m.Int32Add(i3, i4);
3561 3561
3562 Node* i7 = m.Int32Add(i5, i6); 3562 Node* i7 = m.Int32Add(i5, i6);
3563 3563
3564 m.Return(i7); 3564 m.Return(i7);
3565 3565
3566 CHECK_EQ(116, m.Call()); 3566 CHECK_EQ(116, m.Call());
3567 } 3567 }
3568 3568
3569 3569
3570 #if MACHINE_ASSEMBLER_SUPPORTS_CALL_C
3571
3572 static int Seven() { return 7; }
3573 static int UnaryMinus(int a) { return -a; }
3574 static int APlusTwoB(int a, int b) { return a + 2 * b; }
3575
3576
3577 TEST(RunCallSeven) {
3578 for (int i = 0; i < 2; i++) {
3579 bool call_direct = i == 0;
3580 void* function_address =
3581 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&Seven));
3582
3583 RawMachineAssemblerTester<int32_t> m;
3584 Node** args = NULL;
3585 MachineType* arg_types = NULL;
3586 Node* function = call_direct
3587 ? m.PointerConstant(function_address)
3588 : m.LoadFromPointer(&function_address, kMachPtr);
3589 m.Return(m.CallC(function, kMachInt32, arg_types, args, 0));
3590
3591 CHECK_EQ(7, m.Call());
3592 }
3593 }
3594
3595
3596 TEST(RunCallUnaryMinus) {
3597 for (int i = 0; i < 2; i++) {
3598 bool call_direct = i == 0;
3599 void* function_address =
3600 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&UnaryMinus));
3601
3602 RawMachineAssemblerTester<int32_t> m(kMachInt32);
3603 Node* args[] = {m.Parameter(0)};
3604 MachineType arg_types[] = {kMachInt32};
3605 Node* function = call_direct
3606 ? m.PointerConstant(function_address)
3607 : m.LoadFromPointer(&function_address, kMachPtr);
3608 m.Return(m.CallC(function, kMachInt32, arg_types, args, 1));
3609
3610 FOR_INT32_INPUTS(i) {
3611 int a = *i;
3612 CHECK_EQ(-a, m.Call(a));
3613 }
3614 }
3615 }
3616
3617
3618 TEST(RunCallAPlusTwoB) {
3619 for (int i = 0; i < 2; i++) {
3620 bool call_direct = i == 0;
3621 void* function_address =
3622 reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&APlusTwoB));
3623
3624 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32);
3625 Node* args[] = {m.Parameter(0), m.Parameter(1)};
3626 MachineType arg_types[] = {kMachInt32, kMachInt32};
3627 Node* function = call_direct
3628 ? m.PointerConstant(function_address)
3629 : m.LoadFromPointer(&function_address, kMachPtr);
3630 m.Return(m.CallC(function, kMachInt32, arg_types, args, 2));
3631
3632 FOR_INT32_INPUTS(i) {
3633 FOR_INT32_INPUTS(j) {
3634 int a = *i;
3635 int b = *j;
3636 int result = m.Call(a, b);
3637 CHECK_EQ(a + 2 * b, result);
3638 }
3639 }
3640 }
3641 }
3642
3643 #endif // MACHINE_ASSEMBLER_SUPPORTS_CALL_C
3644
3645
3646 static const int kFloat64CompareHelperTestCases = 15; 3570 static const int kFloat64CompareHelperTestCases = 15;
3647 static const int kFloat64CompareHelperNodeType = 4; 3571 static const int kFloat64CompareHelperNodeType = 4;
3648 3572
3649 static int Float64CompareHelper(RawMachineAssemblerTester<int32_t>* m, 3573 static int Float64CompareHelper(RawMachineAssemblerTester<int32_t>* m,
3650 int test_case, int node_type, double x, 3574 int test_case, int node_type, double x,
3651 double y) { 3575 double y) {
3652 static double buffer[2]; 3576 static double buffer[2];
3653 buffer[0] = x; 3577 buffer[0] = x;
3654 buffer[1] = y; 3578 buffer[1] = y;
3655 CHECK(0 <= test_case && test_case < kFloat64CompareHelperTestCases); 3579 CHECK(0 <= test_case && test_case < kFloat64CompareHelperTestCases);
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
4023 3947
4024 m.Bind(&end); 3948 m.Bind(&end);
4025 Node* phi = m.Phi(kMachAnyTagged, true_node, false_node); 3949 Node* phi = m.Phi(kMachAnyTagged, true_node, false_node);
4026 m.Return(phi); 3950 m.Return(phi);
4027 3951
4028 CHECK_EQ(*false_val, m.Call(0)); 3952 CHECK_EQ(*false_val, m.Call(0));
4029 CHECK_EQ(*true_val, m.Call(1)); 3953 CHECK_EQ(*true_val, m.Call(1));
4030 } 3954 }
4031 3955
4032 3956
4033 #if MACHINE_ASSEMBLER_SUPPORTS_CALL_C
4034
4035 TEST(RunSpillLotsOfThingsWithCall) {
4036 static const int kInputSize = 1000;
4037 RawMachineAssemblerTester<void> m;
4038 Node* accs[kInputSize];
4039 int32_t outputs[kInputSize];
4040 Node* one = m.Int32Constant(1);
4041 Node* acc = one;
4042 for (int i = 0; i < kInputSize; i++) {
4043 acc = m.Int32Add(acc, one);
4044 accs[i] = acc;
4045 }
4046 // If the spill slot computation is wrong, it might load from the c frame
4047 {
4048 void* func = reinterpret_cast<void*>(reinterpret_cast<intptr_t>(&Seven));
4049 Node** args = NULL;
4050 MachineType* arg_types = NULL;
4051 m.CallC(m.PointerConstant(func), kMachInt32, arg_types, args, 0);
4052 }
4053 for (int i = 0; i < kInputSize; i++) {
4054 m.StoreToPointer(&outputs[i], kMachInt32, accs[i]);
4055 }
4056 m.Return(one);
4057 m.Call();
4058 for (int i = 0; i < kInputSize; i++) {
4059 CHECK_EQ(outputs[i], i + 2);
4060 }
4061 }
4062
4063 #endif // MACHINE_ASSEMBLER_SUPPORTS_CALL_C
4064
4065
4066 TEST(RunInt32AddWithOverflowP) { 3957 TEST(RunInt32AddWithOverflowP) {
4067 int32_t actual_val = -1; 3958 int32_t actual_val = -1;
4068 RawMachineAssemblerTester<int32_t> m; 3959 RawMachineAssemblerTester<int32_t> m;
4069 Int32BinopTester bt(&m); 3960 Int32BinopTester bt(&m);
4070 Node* add = m.Int32AddWithOverflow(bt.param0, bt.param1); 3961 Node* add = m.Int32AddWithOverflow(bt.param0, bt.param1);
4071 Node* val = m.Projection(0, add); 3962 Node* val = m.Projection(0, add);
4072 Node* ovf = m.Projection(1, add); 3963 Node* ovf = m.Projection(1, add);
4073 m.StoreToPointer(&actual_val, kMachInt32, val); 3964 m.StoreToPointer(&actual_val, kMachInt32, val);
4074 bt.AddReturn(ovf); 3965 bt.AddReturn(ovf);
4075 FOR_INT32_INPUTS(i) { 3966 FOR_INT32_INPUTS(i) {
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
4345 RawMachineAssemblerTester<int32_t> m; 4236 RawMachineAssemblerTester<int32_t> m;
4346 m.Return(m.TruncateFloat64ToInt32(m.LoadFromPointer(&input, kMachFloat64))); 4237 m.Return(m.TruncateFloat64ToInt32(m.LoadFromPointer(&input, kMachFloat64)));
4347 for (size_t i = 0; i < arraysize(kValues); ++i) { 4238 for (size_t i = 0; i < arraysize(kValues); ++i) {
4348 input = kValues[i].from; 4239 input = kValues[i].from;
4349 uint64_t expected = static_cast<int64_t>(kValues[i].raw); 4240 uint64_t expected = static_cast<int64_t>(kValues[i].raw);
4350 CHECK_EQ(static_cast<int>(expected), m.Call()); 4241 CHECK_EQ(static_cast<int>(expected), m.Call());
4351 } 4242 }
4352 } 4243 }
4353 4244
4354 #endif // V8_TURBOFAN_TARGET 4245 #endif // V8_TURBOFAN_TARGET
OLDNEW
« no previous file with comments | « test/cctest/cctest.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698