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 #ifndef V8_CCTEST_COMPILER_VALUE_HELPER_H_ | 5 #ifndef V8_CCTEST_COMPILER_VALUE_HELPER_H_ |
6 #define V8_CCTEST_COMPILER_VALUE_HELPER_H_ | 6 #define V8_CCTEST_COMPILER_VALUE_HELPER_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
11 #include "src/compiler/node.h" | 11 #include "src/compiler/node.h" |
12 #include "src/compiler/node-matchers.h" | 12 #include "src/compiler/node-matchers.h" |
13 #include "src/isolate.h" | 13 #include "src/isolate.h" |
14 #include "src/objects.h" | 14 #include "src/objects.h" |
15 #include "test/cctest/cctest.h" | 15 #include "test/cctest/cctest.h" |
16 | 16 |
17 namespace v8 { | 17 namespace v8 { |
18 namespace internal { | 18 namespace internal { |
19 namespace compiler { | 19 namespace compiler { |
20 | 20 |
21 // A collection of utilities related to numerical and heap values, including | 21 // A collection of utilities related to numerical and heap values, including |
22 // example input values of various types, including int32_t, uint32_t, double, | 22 // example input values of various types, including int32_t, uint32_t, double, |
23 // etc. | 23 // etc. |
24 class ValueHelper { | 24 class ValueHelper { |
25 public: | 25 public: |
26 Isolate* isolate_; | 26 Isolate* isolate_; |
27 | 27 |
28 ValueHelper() : isolate_(CcTest::InitIsolateOnce()) {} | 28 ValueHelper() : isolate_(CcTest::InitIsolateOnce()) {} |
29 | 29 |
30 template <typename T> | |
31 void CheckConstant(T expected, Node* node) { | |
32 CHECK_EQ(expected, ValueOf<T>(node->op())); | |
33 } | |
34 | |
35 void CheckFloat64Constant(double expected, Node* node) { | 30 void CheckFloat64Constant(double expected, Node* node) { |
36 CHECK_EQ(IrOpcode::kFloat64Constant, node->opcode()); | 31 CHECK_EQ(IrOpcode::kFloat64Constant, node->opcode()); |
37 CHECK_EQ(expected, ValueOf<double>(node->op())); | 32 CHECK_EQ(expected, OpParameter<double>(node)); |
38 } | 33 } |
39 | 34 |
40 void CheckNumberConstant(double expected, Node* node) { | 35 void CheckNumberConstant(double expected, Node* node) { |
41 CHECK_EQ(IrOpcode::kNumberConstant, node->opcode()); | 36 CHECK_EQ(IrOpcode::kNumberConstant, node->opcode()); |
42 CHECK_EQ(expected, ValueOf<double>(node->op())); | 37 CHECK_EQ(expected, OpParameter<double>(node)); |
43 } | 38 } |
44 | 39 |
45 void CheckInt32Constant(int32_t expected, Node* node) { | 40 void CheckInt32Constant(int32_t expected, Node* node) { |
46 CHECK_EQ(IrOpcode::kInt32Constant, node->opcode()); | 41 CHECK_EQ(IrOpcode::kInt32Constant, node->opcode()); |
47 CHECK_EQ(expected, ValueOf<int32_t>(node->op())); | 42 CHECK_EQ(expected, OpParameter<int32_t>(node)); |
48 } | 43 } |
49 | 44 |
50 void CheckUint32Constant(int32_t expected, Node* node) { | 45 void CheckUint32Constant(int32_t expected, Node* node) { |
51 CHECK_EQ(IrOpcode::kInt32Constant, node->opcode()); | 46 CHECK_EQ(IrOpcode::kInt32Constant, node->opcode()); |
52 CHECK_EQ(expected, ValueOf<uint32_t>(node->op())); | 47 CHECK_EQ(expected, OpParameter<uint32_t>(node)); |
53 } | 48 } |
54 | 49 |
55 void CheckHeapConstant(Object* expected, Node* node) { | 50 void CheckHeapConstant(Object* expected, Node* node) { |
56 CHECK_EQ(IrOpcode::kHeapConstant, node->opcode()); | 51 CHECK_EQ(IrOpcode::kHeapConstant, node->opcode()); |
57 CHECK_EQ(expected, *ValueOf<Handle<Object> >(node->op())); | 52 CHECK_EQ(expected, *OpParameter<Unique<Object> >(node).handle()); |
58 } | 53 } |
59 | 54 |
60 void CheckTrue(Node* node) { | 55 void CheckTrue(Node* node) { |
61 CheckHeapConstant(isolate_->heap()->true_value(), node); | 56 CheckHeapConstant(isolate_->heap()->true_value(), node); |
62 } | 57 } |
63 | 58 |
64 void CheckFalse(Node* node) { | 59 void CheckFalse(Node* node) { |
65 CheckHeapConstant(isolate_->heap()->false_value(), node); | 60 CheckHeapConstant(isolate_->heap()->false_value(), node); |
66 } | 61 } |
67 | 62 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 121 |
127 #define FOR_INT32_SHIFTS(var) for (int32_t var = 0; var < 32; var++) | 122 #define FOR_INT32_SHIFTS(var) for (int32_t var = 0; var < 32; var++) |
128 | 123 |
129 #define FOR_UINT32_SHIFTS(var) for (uint32_t var = 0; var < 32; var++) | 124 #define FOR_UINT32_SHIFTS(var) for (uint32_t var = 0; var < 32; var++) |
130 | 125 |
131 } // namespace compiler | 126 } // namespace compiler |
132 } // namespace internal | 127 } // namespace internal |
133 } // namespace v8 | 128 } // namespace v8 |
134 | 129 |
135 #endif // V8_CCTEST_COMPILER_VALUE_HELPER_H_ | 130 #endif // V8_CCTEST_COMPILER_VALUE_HELPER_H_ |
OLD | NEW |