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 <limits> | 5 #include <limits> |
6 | 6 |
7 #include "src/v8.h" | 7 #include "src/v8.h" |
8 #include "test/cctest/cctest.h" | 8 #include "test/cctest/cctest.h" |
| 9 #include "test/cctest/compiler/codegen-tester.h" |
9 #include "test/cctest/compiler/graph-builder-tester.h" | 10 #include "test/cctest/compiler/graph-builder-tester.h" |
10 #include "test/cctest/compiler/value-helper.h" | 11 #include "test/cctest/compiler/value-helper.h" |
11 | 12 |
12 #include "src/compiler/node-matchers.h" | 13 #include "src/compiler/node-matchers.h" |
13 #include "src/compiler/representation-change.h" | 14 #include "src/compiler/representation-change.h" |
14 | 15 |
15 using namespace v8::internal; | 16 using namespace v8::internal; |
16 using namespace v8::internal::compiler; | 17 using namespace v8::internal::compiler; |
17 | 18 |
18 namespace v8 { // for friendiness. | 19 namespace v8 { // for friendiness. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 52 |
52 void CheckUint32Constant(Node* n, uint32_t expected) { | 53 void CheckUint32Constant(Node* n, uint32_t expected) { |
53 Uint32Matcher m(n); | 54 Uint32Matcher m(n); |
54 CHECK(m.HasValue()); | 55 CHECK(m.HasValue()); |
55 CHECK_EQ(static_cast<int>(expected), static_cast<int>(m.Value())); | 56 CHECK_EQ(static_cast<int>(expected), static_cast<int>(m.Value())); |
56 } | 57 } |
57 | 58 |
58 void CheckFloat64Constant(Node* n, double expected) { | 59 void CheckFloat64Constant(Node* n, double expected) { |
59 Float64Matcher m(n); | 60 Float64Matcher m(n); |
60 CHECK(m.HasValue()); | 61 CHECK(m.HasValue()); |
61 CHECK_EQ(expected, m.Value()); | 62 CheckDoubleEq(expected, m.Value()); |
62 } | 63 } |
63 | 64 |
64 void CheckFloat32Constant(Node* n, float expected) { | 65 void CheckFloat32Constant(Node* n, float expected) { |
65 CHECK_EQ(IrOpcode::kFloat32Constant, n->opcode()); | 66 CHECK_EQ(IrOpcode::kFloat32Constant, n->opcode()); |
66 float fval = OpParameter<float>(n->op()); | 67 float fval = OpParameter<float>(n->op()); |
67 CHECK_EQ(expected, fval); | 68 CHECK_EQ(expected, fval); |
68 } | 69 } |
69 | 70 |
70 void CheckHeapConstant(Node* n, HeapObject* expected) { | 71 void CheckHeapConstant(Node* n, HeapObject* expected) { |
71 HeapObjectMatcher<HeapObject> m(n); | 72 HeapObjectMatcher<HeapObject> m(n); |
72 CHECK(m.HasValue()); | 73 CHECK(m.HasValue()); |
73 CHECK_EQ(expected, *m.Value().handle()); | 74 CHECK_EQ(expected, *m.Value().handle()); |
74 } | 75 } |
75 | 76 |
76 void CheckNumberConstant(Node* n, double expected) { | 77 void CheckNumberConstant(Node* n, double expected) { |
77 NumberMatcher m(n); | 78 NumberMatcher m(n); |
78 CHECK_EQ(IrOpcode::kNumberConstant, n->opcode()); | 79 CHECK_EQ(IrOpcode::kNumberConstant, n->opcode()); |
79 CHECK(m.HasValue()); | 80 CHECK(m.HasValue()); |
80 CHECK_EQ(expected, m.Value()); | 81 CheckDoubleEq(expected, m.Value()); |
81 } | 82 } |
82 | 83 |
83 Node* Parameter(int index = 0) { | 84 Node* Parameter(int index = 0) { |
84 return graph()->NewNode(common()->Parameter(index), graph()->start()); | 85 return graph()->NewNode(common()->Parameter(index), graph()->start()); |
85 } | 86 } |
86 | 87 |
87 void CheckTypeError(MachineTypeUnion from, MachineTypeUnion to) { | 88 void CheckTypeError(MachineTypeUnion from, MachineTypeUnion to) { |
88 changer()->testing_type_errors_ = true; | 89 changer()->testing_type_errors_ = true; |
89 changer()->type_error_ = false; | 90 changer()->type_error_ = false; |
90 Node* n = Parameter(0); | 91 Node* n = Parameter(0); |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 r.CheckTypeError(kRepWord32 | kTypeUint32, kRepWord64); | 544 r.CheckTypeError(kRepWord32 | kTypeUint32, kRepWord64); |
544 | 545 |
545 for (size_t i = 0; i < arraysize(all_reps); i++) { | 546 for (size_t i = 0; i < arraysize(all_reps); i++) { |
546 for (size_t j = 0; j < arraysize(all_reps); j++) { | 547 for (size_t j = 0; j < arraysize(all_reps); j++) { |
547 if (i == j) continue; | 548 if (i == j) continue; |
548 // Only a single from representation is allowed. | 549 // Only a single from representation is allowed. |
549 r.CheckTypeError(all_reps[i] | all_reps[j], kRepTagged); | 550 r.CheckTypeError(all_reps[i] | all_reps[j], kRepTagged); |
550 } | 551 } |
551 } | 552 } |
552 } | 553 } |
OLD | NEW |