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

Side by Side Diff: test/unittests/compiler/typer-unittest.cc

Issue 904863002: [turbofan] Separate representation type operations from the semantic types. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixes Created 5 years, 10 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
« no previous file with comments | « test/cctest/types-fuzz.h ('k') | test/unittests/unittests.gyp » ('j') | 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 2015 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 6
7 #include "src/codegen.h" 7 #include "src/codegen.h"
8 #include "src/compiler/js-operator.h" 8 #include "src/compiler/js-operator.h"
9 #include "src/compiler/node-properties.h" 9 #include "src/compiler/node-properties.h"
10 #include "src/compiler/typer.h"
11 #include "test/cctest/cctest.h"
12 #include "test/cctest/compiler/graph-builder-tester.h"
13 #include "test/cctest/types-fuzz.h" 10 #include "test/cctest/types-fuzz.h"
11 #include "test/unittests/compiler/graph-unittest.h"
14 12
15 using namespace v8::internal; 13 using namespace v8::internal;
16 using namespace v8::internal::compiler; 14 using namespace v8::internal::compiler;
17 15
18 16
19 // TODO(titzer): generate a large set of deterministic inputs for these tests. 17 // TODO(titzer): generate a large set of deterministic inputs for these tests.
20 class TyperTester : public HandleAndZoneScope, public GraphAndBuilders { 18 class TyperTest : public TypedGraphTest {
21 public: 19 public:
22 TyperTester() 20 TyperTest()
23 : GraphAndBuilders(main_zone()), 21 : TypedGraphTest(3),
24 types_(main_zone(), isolate()), 22 types_(zone(), isolate(), random_number_generator()),
25 typer_(isolate(), graph(), MaybeHandle<Context>()), 23 javascript_(zone()) {
26 javascript_(main_zone()) {
27 Node* s = graph()->NewNode(common()->Start(3));
28 graph()->SetStart(s);
29 context_node_ = graph()->NewNode(common()->Parameter(2), graph()->start()); 24 context_node_ = graph()->NewNode(common()->Parameter(2), graph()->start());
30 rng_ = isolate()->random_number_generator(); 25 rng_ = random_number_generator();
31 26
32 integers.push_back(0); 27 integers.push_back(0);
33 integers.push_back(0); 28 integers.push_back(0);
34 integers.push_back(-1); 29 integers.push_back(-1);
35 integers.push_back(+1); 30 integers.push_back(+1);
36 integers.push_back(-V8_INFINITY); 31 integers.push_back(-V8_INFINITY);
37 integers.push_back(+V8_INFINITY); 32 integers.push_back(+V8_INFINITY);
38 for (int i = 0; i < 5; ++i) { 33 for (int i = 0; i < 5; ++i) {
39 double x = rng_->NextInt(); 34 double x = rng_->NextInt();
40 integers.push_back(x); 35 integers.push_back(x);
41 x *= rng_->NextInt(); 36 x *= rng_->NextInt();
42 if (!IsMinusZero(x)) integers.push_back(x); 37 if (!IsMinusZero(x)) integers.push_back(x);
43 } 38 }
44 39
45 int32s.push_back(0); 40 int32s.push_back(0);
46 int32s.push_back(0); 41 int32s.push_back(0);
47 int32s.push_back(-1); 42 int32s.push_back(-1);
48 int32s.push_back(+1); 43 int32s.push_back(+1);
49 int32s.push_back(kMinInt); 44 int32s.push_back(kMinInt);
50 int32s.push_back(kMaxInt); 45 int32s.push_back(kMaxInt);
51 for (int i = 0; i < 10; ++i) { 46 for (int i = 0; i < 10; ++i) {
52 int32s.push_back(rng_->NextInt()); 47 int32s.push_back(rng_->NextInt());
53 } 48 }
54 } 49 }
55 50
56 Types<Type, Type*, Zone> types_; 51 Types<Type, Type*, Zone> types_;
57 Typer typer_;
58 JSOperatorBuilder javascript_; 52 JSOperatorBuilder javascript_;
59 Node* context_node_; 53 Node* context_node_;
60 v8::base::RandomNumberGenerator* rng_; 54 v8::base::RandomNumberGenerator* rng_;
61 std::vector<double> integers; 55 std::vector<double> integers;
62 std::vector<double> int32s; 56 std::vector<double> int32s;
63 57
64 Isolate* isolate() { return main_isolate(); }
65 Graph* graph() { return main_graph_; }
66 CommonOperatorBuilder* common() { return &main_common_; }
67
68 Node* Parameter(int index = 0) {
69 return graph()->NewNode(common()->Parameter(index), graph()->start());
70 }
71
72 Type* TypeBinaryOp(const Operator* op, Type* lhs, Type* rhs) { 58 Type* TypeBinaryOp(const Operator* op, Type* lhs, Type* rhs) {
73 Node* p0 = Parameter(0); 59 Node* p0 = Parameter(0);
74 Node* p1 = Parameter(1); 60 Node* p1 = Parameter(1);
75 NodeProperties::SetBounds(p0, Bounds(lhs)); 61 NodeProperties::SetBounds(p0, Bounds(lhs));
76 NodeProperties::SetBounds(p1, Bounds(rhs)); 62 NodeProperties::SetBounds(p1, Bounds(rhs));
77 Node* n = graph()->NewNode( 63 Node* n = graph()->NewNode(op, p0, p1, context_node_, graph()->start(),
78 op, p0, p1, context_node_, graph()->start(), graph()->start()); 64 graph()->start());
79 return NodeProperties::GetBounds(n).upper; 65 return NodeProperties::GetBounds(n).upper;
80 } 66 }
81 67
82 Type* RandomRange(bool int32 = false) { 68 Type* RandomRange(bool int32 = false) {
83 std::vector<double>& numbers = int32 ? int32s : integers; 69 std::vector<double>& numbers = int32 ? int32s : integers;
84 double i = numbers[rng_->NextInt(static_cast<int>(numbers.size()))]; 70 double i = numbers[rng_->NextInt(static_cast<int>(numbers.size()))];
85 double j = numbers[rng_->NextInt(static_cast<int>(numbers.size()))]; 71 double j = numbers[rng_->NextInt(static_cast<int>(numbers.size()))];
86 return NewRange(i, j); 72 return NewRange(i, j);
87 } 73 }
88 74
89 Type* NewRange(double i, double j) { 75 Type* NewRange(double i, double j) {
90 if (i > j) std::swap(i, j); 76 if (i > j) std::swap(i, j);
91 return Type::Range(i, j, main_zone()); 77 return Type::Range(i, j, zone());
92 } 78 }
93 79
94 double RandomInt(double min, double max) { 80 double RandomInt(double min, double max) {
95 switch (rng_->NextInt(4)) { 81 switch (rng_->NextInt(4)) {
96 case 0: return min; 82 case 0:
97 case 1: return max; 83 return min;
98 default: break; 84 case 1:
85 return max;
86 default:
87 break;
99 } 88 }
100 if (min == +V8_INFINITY) return +V8_INFINITY; 89 if (min == +V8_INFINITY) return +V8_INFINITY;
101 if (max == -V8_INFINITY) return -V8_INFINITY; 90 if (max == -V8_INFINITY) return -V8_INFINITY;
102 if (min == -V8_INFINITY && max == +V8_INFINITY) { 91 if (min == -V8_INFINITY && max == +V8_INFINITY) {
103 return rng_->NextInt() * static_cast<double>(rng_->NextInt()); 92 return rng_->NextInt() * static_cast<double>(rng_->NextInt());
104 } 93 }
105 double result = nearbyint(min + (max - min) * rng_->NextDouble()); 94 double result = nearbyint(min + (max - min) * rng_->NextDouble());
106 if (IsMinusZero(result)) return 0; 95 if (IsMinusZero(result)) return 0;
107 if (std::isnan(result)) return rng_->NextInt(2) ? min : max; 96 if (std::isnan(result)) return rng_->NextInt(2) ? min : max;
108 DCHECK(min <= result && result <= max); 97 DCHECK(min <= result && result <= max);
(...skipping 14 matching lines...) Expand all
123 for (int lmin = min_min; lmin <= max_min; lmin++) { 112 for (int lmin = min_min; lmin <= max_min; lmin++) {
124 for (int rmin = min_min; rmin <= max_min; rmin++) { 113 for (int rmin = min_min; rmin <= max_min; rmin++) {
125 Type* r1 = NewRange(lmin, lmin + width); 114 Type* r1 = NewRange(lmin, lmin + width);
126 Type* r2 = NewRange(rmin, rmin + width); 115 Type* r2 = NewRange(rmin, rmin + width);
127 Type* expected_type = TypeBinaryOp(op, r1, r2); 116 Type* expected_type = TypeBinaryOp(op, r1, r2);
128 117
129 for (int x1 = lmin; x1 < lmin + width; x1++) { 118 for (int x1 = lmin; x1 < lmin + width; x1++) {
130 for (int x2 = rmin; x2 < rmin + width; x2++) { 119 for (int x2 = rmin; x2 < rmin + width; x2++) {
131 double result_value = opfun(x1, x2); 120 double result_value = opfun(x1, x2);
132 Type* result_type = Type::Constant( 121 Type* result_type = Type::Constant(
133 isolate()->factory()->NewNumber(result_value), main_zone()); 122 isolate()->factory()->NewNumber(result_value), zone());
134 CHECK(result_type->Is(expected_type)); 123 EXPECT_TRUE(result_type->Is(expected_type));
135 } 124 }
136 } 125 }
137 } 126 }
138 } 127 }
139 } 128 }
140 } 129 }
141 130
142 template <class BinaryFunction> 131 template <class BinaryFunction>
143 void TestBinaryArithOp(const Operator* op, BinaryFunction opfun) { 132 void TestBinaryArithOp(const Operator* op, BinaryFunction opfun) {
144 TestBinaryArithOpCloseToZero(op, opfun, 8); 133 TestBinaryArithOpCloseToZero(op, opfun, 8);
145 for (int i = 0; i < 100; ++i) { 134 for (int i = 0; i < 100; ++i) {
146 Type::RangeType* r1 = RandomRange()->AsRange(); 135 Type::RangeType* r1 = RandomRange()->AsRange();
147 Type::RangeType* r2 = RandomRange()->AsRange(); 136 Type::RangeType* r2 = RandomRange()->AsRange();
148 Type* expected_type = TypeBinaryOp(op, r1, r2); 137 Type* expected_type = TypeBinaryOp(op, r1, r2);
149 for (int i = 0; i < 10; i++) { 138 for (int i = 0; i < 10; i++) {
150 double x1 = RandomInt(r1); 139 double x1 = RandomInt(r1);
151 double x2 = RandomInt(r2); 140 double x2 = RandomInt(r2);
152 double result_value = opfun(x1, x2); 141 double result_value = opfun(x1, x2);
153 Type* result_type = Type::Constant( 142 Type* result_type = Type::Constant(
154 isolate()->factory()->NewNumber(result_value), main_zone()); 143 isolate()->factory()->NewNumber(result_value), zone());
155 CHECK(result_type->Is(expected_type)); 144 EXPECT_TRUE(result_type->Is(expected_type));
156 } 145 }
157 } 146 }
158 } 147 }
159 148
160 template <class BinaryFunction> 149 template <class BinaryFunction>
161 void TestBinaryCompareOp(const Operator* op, BinaryFunction opfun) { 150 void TestBinaryCompareOp(const Operator* op, BinaryFunction opfun) {
162 for (int i = 0; i < 100; ++i) { 151 for (int i = 0; i < 100; ++i) {
163 Type::RangeType* r1 = RandomRange()->AsRange(); 152 Type::RangeType* r1 = RandomRange()->AsRange();
164 Type::RangeType* r2 = RandomRange()->AsRange(); 153 Type::RangeType* r2 = RandomRange()->AsRange();
165 Type* expected_type = TypeBinaryOp(op, r1, r2); 154 Type* expected_type = TypeBinaryOp(op, r1, r2);
166 for (int i = 0; i < 10; i++) { 155 for (int i = 0; i < 10; i++) {
167 double x1 = RandomInt(r1); 156 double x1 = RandomInt(r1);
168 double x2 = RandomInt(r2); 157 double x2 = RandomInt(r2);
169 bool result_value = opfun(x1, x2); 158 bool result_value = opfun(x1, x2);
170 Type* result_type = 159 Type* result_type =
171 Type::Constant(result_value ? isolate()->factory()->true_value() 160 Type::Constant(result_value ? isolate()->factory()->true_value()
172 : isolate()->factory()->false_value(), 161 : isolate()->factory()->false_value(),
173 main_zone()); 162 zone());
174 CHECK(result_type->Is(expected_type)); 163 EXPECT_TRUE(result_type->Is(expected_type));
175 } 164 }
176 } 165 }
177 } 166 }
178 167
179 template <class BinaryFunction> 168 template <class BinaryFunction>
180 void TestBinaryBitOp(const Operator* op, BinaryFunction opfun) { 169 void TestBinaryBitOp(const Operator* op, BinaryFunction opfun) {
181 for (int i = 0; i < 100; ++i) { 170 for (int i = 0; i < 100; ++i) {
182 Type::RangeType* r1 = RandomRange(true)->AsRange(); 171 Type::RangeType* r1 = RandomRange(true)->AsRange();
183 Type::RangeType* r2 = RandomRange(true)->AsRange(); 172 Type::RangeType* r2 = RandomRange(true)->AsRange();
184 Type* expected_type = TypeBinaryOp(op, r1, r2); 173 Type* expected_type = TypeBinaryOp(op, r1, r2);
185 for (int i = 0; i < 10; i++) { 174 for (int i = 0; i < 10; i++) {
186 int32_t x1 = static_cast<int32_t>(RandomInt(r1)); 175 int32_t x1 = static_cast<int32_t>(RandomInt(r1));
187 int32_t x2 = static_cast<int32_t>(RandomInt(r2)); 176 int32_t x2 = static_cast<int32_t>(RandomInt(r2));
188 double result_value = opfun(x1, x2); 177 double result_value = opfun(x1, x2);
189 Type* result_type = Type::Constant( 178 Type* result_type = Type::Constant(
190 isolate()->factory()->NewNumber(result_value), main_zone()); 179 isolate()->factory()->NewNumber(result_value), zone());
191 CHECK(result_type->Is(expected_type)); 180 EXPECT_TRUE(result_type->Is(expected_type));
192 } 181 }
193 } 182 }
194 } 183 }
195 184
196 Type* RandomSubtype(Type* type) { 185 Type* RandomSubtype(Type* type) {
197 Type* subtype; 186 Type* subtype;
198 do { 187 do {
199 subtype = types_.Fuzz(); 188 subtype = types_.Fuzz();
200 } while (!subtype->Is(type)); 189 } while (!subtype->Is(type));
201 return subtype; 190 return subtype;
202 } 191 }
203 192
204 void TestBinaryMonotonicity(const Operator* op) { 193 void TestBinaryMonotonicity(const Operator* op) {
205 for (int i = 0; i < 50; ++i) { 194 for (int i = 0; i < 50; ++i) {
206 Type* type1 = types_.Fuzz(); 195 Type* type1 = types_.Fuzz();
207 Type* type2 = types_.Fuzz(); 196 Type* type2 = types_.Fuzz();
208 Type* type = TypeBinaryOp(op, type1, type2); 197 Type* type = TypeBinaryOp(op, type1, type2);
209 Type* subtype1 = RandomSubtype(type1);; 198 Type* subtype1 = RandomSubtype(type1);
210 Type* subtype2 = RandomSubtype(type2);; 199 ;
200 Type* subtype2 = RandomSubtype(type2);
201 ;
211 Type* subtype = TypeBinaryOp(op, subtype1, subtype2); 202 Type* subtype = TypeBinaryOp(op, subtype1, subtype2);
212 CHECK(subtype->Is(type)); 203 EXPECT_TRUE(subtype->Is(type));
213 } 204 }
214 } 205 }
215 }; 206 };
216 207
217 208
218 static int32_t shift_left(int32_t x, int32_t y) { return x << y; } 209 namespace {
219 static int32_t shift_right(int32_t x, int32_t y) { return x >> y; } 210
220 static int32_t bit_or(int32_t x, int32_t y) { return x | y; } 211 int32_t shift_left(int32_t x, int32_t y) { return x << y; }
221 static int32_t bit_and(int32_t x, int32_t y) { return x & y; } 212 int32_t shift_right(int32_t x, int32_t y) { return x >> y; }
222 static int32_t bit_xor(int32_t x, int32_t y) { return x ^ y; } 213 int32_t bit_or(int32_t x, int32_t y) { return x | y; }
214 int32_t bit_and(int32_t x, int32_t y) { return x & y; }
215 int32_t bit_xor(int32_t x, int32_t y) { return x ^ y; }
216
217 } // namespace
223 218
224 219
225 //------------------------------------------------------------------------------ 220 //------------------------------------------------------------------------------
226 // Soundness 221 // Soundness
227 // For simplicity, we currently only test soundness on expression operators 222 // For simplicity, we currently only test soundness on expression operators
228 // that have a direct equivalent in C++. Also, testing is currently limited 223 // that have a direct equivalent in C++. Also, testing is currently limited
229 // to ranges as input types. 224 // to ranges as input types.
230 225
231 226
232 TEST(TypeJSAdd) { 227 TEST_F(TyperTest, TypeJSAdd) {
233 TyperTester t; 228 TestBinaryArithOp(javascript_.Add(), std::plus<double>());
234 t.TestBinaryArithOp(t.javascript_.Add(), std::plus<double>());
235 } 229 }
236 230
237 231
238 TEST(TypeJSSubtract) { 232 TEST_F(TyperTest, TypeJSSubtract) {
239 TyperTester t; 233 TestBinaryArithOp(javascript_.Subtract(), std::minus<double>());
240 t.TestBinaryArithOp(t.javascript_.Subtract(), std::minus<double>());
241 } 234 }
242 235
243 236
244 TEST(TypeJSMultiply) { 237 TEST_F(TyperTest, TypeJSMultiply) {
245 TyperTester t; 238 TestBinaryArithOp(javascript_.Multiply(), std::multiplies<double>());
246 t.TestBinaryArithOp(t.javascript_.Multiply(), std::multiplies<double>());
247 } 239 }
248 240
249 241
250 TEST(TypeJSDivide) { 242 TEST_F(TyperTest, TypeJSDivide) {
251 TyperTester t; 243 TestBinaryArithOp(javascript_.Divide(), std::divides<double>());
252 t.TestBinaryArithOp(t.javascript_.Divide(), std::divides<double>());
253 } 244 }
254 245
255 246
256 TEST(TypeJSModulus) { 247 TEST_F(TyperTest, TypeJSModulus) {
257 TyperTester t; 248 TestBinaryArithOp(javascript_.Modulus(), modulo);
258 t.TestBinaryArithOp(t.javascript_.Modulus(), modulo);
259 } 249 }
260 250
261 251
262 TEST(TypeJSBitwiseOr) { 252 TEST_F(TyperTest, TypeJSBitwiseOr) {
263 TyperTester t; 253 TestBinaryBitOp(javascript_.BitwiseOr(), bit_or);
264 t.TestBinaryBitOp(t.javascript_.BitwiseOr(), bit_or);
265 } 254 }
266 255
267 256
268 TEST(TypeJSBitwiseAnd) { 257 TEST_F(TyperTest, TypeJSBitwiseAnd) {
269 TyperTester t; 258 TestBinaryBitOp(javascript_.BitwiseAnd(), bit_and);
270 t.TestBinaryBitOp(t.javascript_.BitwiseAnd(), bit_and);
271 } 259 }
272 260
273 261
274 TEST(TypeJSBitwiseXor) { 262 TEST_F(TyperTest, TypeJSBitwiseXor) {
275 TyperTester t; 263 TestBinaryBitOp(javascript_.BitwiseXor(), bit_xor);
276 t.TestBinaryBitOp(t.javascript_.BitwiseXor(), bit_xor);
277 } 264 }
278 265
279 266
280 TEST(TypeJSShiftLeft) { 267 TEST_F(TyperTest, TypeJSShiftLeft) {
281 TyperTester t; 268 TestBinaryBitOp(javascript_.ShiftLeft(), shift_left);
282 t.TestBinaryBitOp(t.javascript_.ShiftLeft(), shift_left);
283 } 269 }
284 270
285 271
286 TEST(TypeJSShiftRight) { 272 TEST_F(TyperTest, TypeJSShiftRight) {
287 TyperTester t; 273 TestBinaryBitOp(javascript_.ShiftRight(), shift_right);
288 t.TestBinaryBitOp(t.javascript_.ShiftRight(), shift_right);
289 } 274 }
290 275
291 276
292 TEST(TypeJSLessThan) { 277 TEST_F(TyperTest, TypeJSLessThan) {
293 TyperTester t; 278 TestBinaryCompareOp(javascript_.LessThan(), std::less<double>());
294 t.TestBinaryCompareOp(t.javascript_.LessThan(), std::less<double>());
295 } 279 }
296 280
297 281
298 TEST(TypeJSLessThanOrEqual) { 282 TEST_F(TyperTest, TypeJSLessThanOrEqual) {
299 TyperTester t; 283 TestBinaryCompareOp(javascript_.LessThanOrEqual(), std::less_equal<double>());
300 t.TestBinaryCompareOp(
301 t.javascript_.LessThanOrEqual(), std::less_equal<double>());
302 } 284 }
303 285
304 286
305 TEST(TypeJSGreaterThan) { 287 TEST_F(TyperTest, TypeJSGreaterThan) {
306 TyperTester t; 288 TestBinaryCompareOp(javascript_.GreaterThan(), std::greater<double>());
307 t.TestBinaryCompareOp(t.javascript_.GreaterThan(), std::greater<double>());
308 } 289 }
309 290
310 291
311 TEST(TypeJSGreaterThanOrEqual) { 292 TEST_F(TyperTest, TypeJSGreaterThanOrEqual) {
312 TyperTester t; 293 TestBinaryCompareOp(javascript_.GreaterThanOrEqual(),
313 t.TestBinaryCompareOp( 294 std::greater_equal<double>());
314 t.javascript_.GreaterThanOrEqual(), std::greater_equal<double>());
315 } 295 }
316 296
317 297
318 TEST(TypeJSEqual) { 298 TEST_F(TyperTest, TypeJSEqual) {
319 TyperTester t; 299 TestBinaryCompareOp(javascript_.Equal(), std::equal_to<double>());
320 t.TestBinaryCompareOp(t.javascript_.Equal(), std::equal_to<double>());
321 } 300 }
322 301
323 302
324 TEST(TypeJSNotEqual) { 303 TEST_F(TyperTest, TypeJSNotEqual) {
325 TyperTester t; 304 TestBinaryCompareOp(javascript_.NotEqual(), std::not_equal_to<double>());
326 t.TestBinaryCompareOp(t.javascript_.NotEqual(), std::not_equal_to<double>());
327 } 305 }
328 306
329 307
330 // For numbers there's no difference between strict and non-strict equality. 308 // For numbers there's no difference between strict and non-strict equality.
331 TEST(TypeJSStrictEqual) { 309 TEST_F(TyperTest, TypeJSStrictEqual) {
332 TyperTester t; 310 TestBinaryCompareOp(javascript_.StrictEqual(), std::equal_to<double>());
333 t.TestBinaryCompareOp(t.javascript_.StrictEqual(), std::equal_to<double>());
334 } 311 }
335 312
336 313
337 TEST(TypeJSStrictNotEqual) { 314 TEST_F(TyperTest, TypeJSStrictNotEqual) {
338 TyperTester t; 315 TestBinaryCompareOp(javascript_.StrictNotEqual(),
339 t.TestBinaryCompareOp( 316 std::not_equal_to<double>());
340 t.javascript_.StrictNotEqual(), std::not_equal_to<double>());
341 } 317 }
342 318
343 319
344 //------------------------------------------------------------------------------ 320 //------------------------------------------------------------------------------
345 // Monotonicity 321 // Monotonicity
346 322
347 323
348 // List should be in sync with JS_SIMPLE_BINOP_LIST. 324 // List should be in sync with JS_SIMPLE_BINOP_LIST.
349 #define JSBINOP_LIST(V) \ 325 #define JSBINOP_LIST(V) \
350 V(Equal) \ 326 V(Equal) \
351 V(NotEqual) \ 327 V(NotEqual) \
352 V(StrictEqual) \ 328 V(StrictEqual) \
353 V(StrictNotEqual) \ 329 V(StrictNotEqual) \
354 V(LessThan) \ 330 V(LessThan) \
355 V(GreaterThan) \ 331 V(GreaterThan) \
356 V(LessThanOrEqual) \ 332 V(LessThanOrEqual) \
357 V(GreaterThanOrEqual) \ 333 V(GreaterThanOrEqual) \
358 V(BitwiseOr) \ 334 V(BitwiseOr) \
359 V(BitwiseXor) \ 335 V(BitwiseXor) \
360 V(BitwiseAnd) \ 336 V(BitwiseAnd) \
361 V(ShiftLeft) \ 337 V(ShiftLeft) \
362 V(ShiftRight) \ 338 V(ShiftRight) \
363 V(ShiftRightLogical) \ 339 V(ShiftRightLogical) \
364 V(Add) \ 340 V(Add) \
365 V(Subtract) \ 341 V(Subtract) \
366 V(Multiply) \ 342 V(Multiply) \
367 V(Divide) \ 343 V(Divide) \
368 V(Modulus) 344 V(Modulus)
369 345
370 346
371 #define TEST_FUNC(name) \ 347 #define TEST_FUNC(name) \
372 TEST(Monotonicity_##name) { \ 348 TEST_F(TyperTest, Monotonicity_##name) { \
373 TyperTester t; \ 349 TestBinaryMonotonicity(javascript_.name()); \
374 t.TestBinaryMonotonicity(t.javascript_.name()); \
375 } 350 }
376 JSBINOP_LIST(TEST_FUNC) 351 JSBINOP_LIST(TEST_FUNC)
377 #undef TEST_FUNC 352 #undef TEST_FUNC
353
354
355 //------------------------------------------------------------------------------
356 // Regression tests
357
358
359 TEST_F(TyperTest, TypeRegressInt32Constant) {
360 int values[] = {-5, 10};
361 for (auto i : values) {
362 Node* c = graph()->NewNode(common()->Int32Constant(i));
363 Type* type = NodeProperties::GetBounds(c).upper;
364 EXPECT_TRUE(type->Is(NewRange(i, i)));
365 }
366 }
OLDNEW
« no previous file with comments | « test/cctest/types-fuzz.h ('k') | test/unittests/unittests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698