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 "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/assembler.h" | 7 #include "src/assembler.h" |
8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
9 #include "src/compiler/node-properties-inl.h" | 9 #include "src/compiler/node-properties-inl.h" |
10 #include "src/compiler/typer.h" | 10 #include "src/compiler/typer.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 TEST(ZeroConstant1) { | 59 TEST(ZeroConstant1) { |
60 JSConstantCacheTester T; | 60 JSConstantCacheTester T; |
61 | 61 |
62 Node* zero = T.ZeroConstant(); | 62 Node* zero = T.ZeroConstant(); |
63 | 63 |
64 CHECK_EQ(IrOpcode::kNumberConstant, zero->opcode()); | 64 CHECK_EQ(IrOpcode::kNumberConstant, zero->opcode()); |
65 CHECK_EQ(zero, T.Constant(0)); | 65 CHECK_EQ(zero, T.Constant(0)); |
66 CHECK_NE(zero, T.Constant(-0.0)); | 66 CHECK_NE(zero, T.Constant(-0.0)); |
67 CHECK_NE(zero, T.Constant(1.0)); | 67 CHECK_NE(zero, T.Constant(1.0)); |
68 CHECK_NE(zero, T.Constant(v8::base::OS::nan_value())); | 68 CHECK_NE(zero, T.Constant(std::numeric_limits<double>::quiet_NaN())); |
69 CHECK_NE(zero, T.Float64Constant(0)); | 69 CHECK_NE(zero, T.Float64Constant(0)); |
70 CHECK_NE(zero, T.Int32Constant(0)); | 70 CHECK_NE(zero, T.Int32Constant(0)); |
71 | 71 |
72 Type* t = T.upper(zero); | 72 Type* t = T.upper(zero); |
73 | 73 |
74 CHECK(t->Is(Type::Number())); | 74 CHECK(t->Is(Type::Number())); |
75 CHECK(t->Is(Type::Integral32())); | 75 CHECK(t->Is(Type::Integral32())); |
76 CHECK(t->Is(Type::Signed32())); | 76 CHECK(t->Is(Type::Signed32())); |
77 CHECK(t->Is(Type::Unsigned32())); | 77 CHECK(t->Is(Type::Unsigned32())); |
78 CHECK(t->Is(Type::SignedSmall())); | 78 CHECK(t->Is(Type::SignedSmall())); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 TEST(ZeroConstant2) { | 113 TEST(ZeroConstant2) { |
114 JSConstantCacheTester T; | 114 JSConstantCacheTester T; |
115 | 115 |
116 Node* zero = T.Constant(0); | 116 Node* zero = T.Constant(0); |
117 | 117 |
118 CHECK_EQ(IrOpcode::kNumberConstant, zero->opcode()); | 118 CHECK_EQ(IrOpcode::kNumberConstant, zero->opcode()); |
119 CHECK_EQ(zero, T.ZeroConstant()); | 119 CHECK_EQ(zero, T.ZeroConstant()); |
120 CHECK_NE(zero, T.Constant(-0.0)); | 120 CHECK_NE(zero, T.Constant(-0.0)); |
121 CHECK_NE(zero, T.Constant(1.0)); | 121 CHECK_NE(zero, T.Constant(1.0)); |
122 CHECK_NE(zero, T.Constant(v8::base::OS::nan_value())); | 122 CHECK_NE(zero, T.Constant(std::numeric_limits<double>::quiet_NaN())); |
123 CHECK_NE(zero, T.Float64Constant(0)); | 123 CHECK_NE(zero, T.Float64Constant(0)); |
124 CHECK_NE(zero, T.Int32Constant(0)); | 124 CHECK_NE(zero, T.Int32Constant(0)); |
125 | 125 |
126 Type* t = T.upper(zero); | 126 Type* t = T.upper(zero); |
127 | 127 |
128 CHECK(t->Is(Type::Number())); | 128 CHECK(t->Is(Type::Number())); |
129 CHECK(t->Is(Type::Integral32())); | 129 CHECK(t->Is(Type::Integral32())); |
130 CHECK(t->Is(Type::Signed32())); | 130 CHECK(t->Is(Type::Signed32())); |
131 CHECK(t->Is(Type::Unsigned32())); | 131 CHECK(t->Is(Type::Unsigned32())); |
132 CHECK(t->Is(Type::SignedSmall())); | 132 CHECK(t->Is(Type::SignedSmall())); |
133 CHECK(t->Is(Type::UnsignedSmall())); | 133 CHECK(t->Is(Type::UnsignedSmall())); |
134 } | 134 } |
135 | 135 |
136 | 136 |
137 TEST(OneConstant1) { | 137 TEST(OneConstant1) { |
138 JSConstantCacheTester T; | 138 JSConstantCacheTester T; |
139 | 139 |
140 Node* one = T.OneConstant(); | 140 Node* one = T.OneConstant(); |
141 | 141 |
142 CHECK_EQ(IrOpcode::kNumberConstant, one->opcode()); | 142 CHECK_EQ(IrOpcode::kNumberConstant, one->opcode()); |
143 CHECK_EQ(one, T.Constant(1)); | 143 CHECK_EQ(one, T.Constant(1)); |
144 CHECK_EQ(one, T.Constant(1.0)); | 144 CHECK_EQ(one, T.Constant(1.0)); |
145 CHECK_NE(one, T.Constant(1.01)); | 145 CHECK_NE(one, T.Constant(1.01)); |
146 CHECK_NE(one, T.Constant(-1.01)); | 146 CHECK_NE(one, T.Constant(-1.01)); |
147 CHECK_NE(one, T.Constant(v8::base::OS::nan_value())); | 147 CHECK_NE(one, T.Constant(std::numeric_limits<double>::quiet_NaN())); |
148 CHECK_NE(one, T.Float64Constant(1.0)); | 148 CHECK_NE(one, T.Float64Constant(1.0)); |
149 CHECK_NE(one, T.Int32Constant(1)); | 149 CHECK_NE(one, T.Int32Constant(1)); |
150 | 150 |
151 Type* t = T.upper(one); | 151 Type* t = T.upper(one); |
152 | 152 |
153 CHECK(t->Is(Type::Number())); | 153 CHECK(t->Is(Type::Number())); |
154 CHECK(t->Is(Type::Integral32())); | 154 CHECK(t->Is(Type::Integral32())); |
155 CHECK(t->Is(Type::Signed32())); | 155 CHECK(t->Is(Type::Signed32())); |
156 CHECK(t->Is(Type::Unsigned32())); | 156 CHECK(t->Is(Type::Unsigned32())); |
157 CHECK(t->Is(Type::SignedSmall())); | 157 CHECK(t->Is(Type::SignedSmall())); |
158 CHECK(t->Is(Type::UnsignedSmall())); | 158 CHECK(t->Is(Type::UnsignedSmall())); |
159 } | 159 } |
160 | 160 |
161 | 161 |
162 TEST(OneConstant2) { | 162 TEST(OneConstant2) { |
163 JSConstantCacheTester T; | 163 JSConstantCacheTester T; |
164 | 164 |
165 Node* one = T.Constant(1); | 165 Node* one = T.Constant(1); |
166 | 166 |
167 CHECK_EQ(IrOpcode::kNumberConstant, one->opcode()); | 167 CHECK_EQ(IrOpcode::kNumberConstant, one->opcode()); |
168 CHECK_EQ(one, T.OneConstant()); | 168 CHECK_EQ(one, T.OneConstant()); |
169 CHECK_EQ(one, T.Constant(1.0)); | 169 CHECK_EQ(one, T.Constant(1.0)); |
170 CHECK_NE(one, T.Constant(1.01)); | 170 CHECK_NE(one, T.Constant(1.01)); |
171 CHECK_NE(one, T.Constant(-1.01)); | 171 CHECK_NE(one, T.Constant(-1.01)); |
172 CHECK_NE(one, T.Constant(v8::base::OS::nan_value())); | 172 CHECK_NE(one, T.Constant(std::numeric_limits<double>::quiet_NaN())); |
173 CHECK_NE(one, T.Float64Constant(1.0)); | 173 CHECK_NE(one, T.Float64Constant(1.0)); |
174 CHECK_NE(one, T.Int32Constant(1)); | 174 CHECK_NE(one, T.Int32Constant(1)); |
175 | 175 |
176 Type* t = T.upper(one); | 176 Type* t = T.upper(one); |
177 | 177 |
178 CHECK(t->Is(Type::Number())); | 178 CHECK(t->Is(Type::Number())); |
179 CHECK(t->Is(Type::Integral32())); | 179 CHECK(t->Is(Type::Integral32())); |
180 CHECK(t->Is(Type::Signed32())); | 180 CHECK(t->Is(Type::Signed32())); |
181 CHECK(t->Is(Type::Unsigned32())); | 181 CHECK(t->Is(Type::Unsigned32())); |
182 CHECK(t->Is(Type::SignedSmall())); | 182 CHECK(t->Is(Type::SignedSmall())); |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
465 T.Constant(1.11), | 465 T.Constant(1.11), |
466 T.ExternalConstant(ExternalReference::address_of_one_half())}; | 466 T.ExternalConstant(ExternalReference::address_of_one_half())}; |
467 | 467 |
468 NodeVector nodes(T.main_zone()); | 468 NodeVector nodes(T.main_zone()); |
469 T.GetCachedNodes(&nodes); | 469 T.GetCachedNodes(&nodes); |
470 | 470 |
471 for (size_t i = 0; i < arraysize(constants); i++) { | 471 for (size_t i = 0; i < arraysize(constants); i++) { |
472 CHECK(Contains(&nodes, constants[i])); | 472 CHECK(Contains(&nodes, constants[i])); |
473 } | 473 } |
474 } | 474 } |
OLD | NEW |