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