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 <functional> | 5 #include <functional> |
6 | 6 |
7 #include "src/codegen.h" | 7 #include "src/codegen.h" |
8 #include "src/compiler/node-properties-inl.h" | 8 #include "src/compiler/node-properties-inl.h" |
9 #include "src/compiler/typer.h" | 9 #include "src/compiler/typer.h" |
10 #include "test/cctest/cctest.h" | 10 #include "test/cctest/cctest.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 javascript_(main_zone()) { | 25 javascript_(main_zone()) { |
26 Node* s = graph()->NewNode(common()->Start(3)); | 26 Node* s = graph()->NewNode(common()->Start(3)); |
27 graph()->SetStart(s); | 27 graph()->SetStart(s); |
28 context_node_ = graph()->NewNode(common()->Parameter(2), graph()->start()); | 28 context_node_ = graph()->NewNode(common()->Parameter(2), graph()->start()); |
29 rng_ = isolate()->random_number_generator(); | 29 rng_ = isolate()->random_number_generator(); |
30 | 30 |
31 integers.push_back(0); | 31 integers.push_back(0); |
32 integers.push_back(0); | 32 integers.push_back(0); |
33 integers.push_back(-1); | 33 integers.push_back(-1); |
34 integers.push_back(+1); | 34 integers.push_back(+1); |
35 integers.push_back(-V8_INFINITY); | 35 integers.push_back(-std::numeric_limits<double>::infinity()); |
36 integers.push_back(+V8_INFINITY); | 36 integers.push_back(+std::numeric_limits<double>::infinity()); |
37 for (int i = 0; i < 5; ++i) { | 37 for (int i = 0; i < 5; ++i) { |
38 double x = rng_->NextInt(); | 38 double x = rng_->NextInt(); |
39 integers.push_back(x); | 39 integers.push_back(x); |
40 x *= rng_->NextInt(); | 40 x *= rng_->NextInt(); |
41 if (!IsMinusZero(x)) integers.push_back(x); | 41 if (!IsMinusZero(x)) integers.push_back(x); |
42 } | 42 } |
43 | 43 |
44 int32s.push_back(0); | 44 int32s.push_back(0); |
45 int32s.push_back(0); | 45 int32s.push_back(0); |
46 int32s.push_back(-1); | 46 int32s.push_back(-1); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 if (min->Number() > max->Number()) std::swap(min, max); | 92 if (min->Number() > max->Number()) std::swap(min, max); |
93 return Type::Range(min, max, main_zone()); | 93 return Type::Range(min, max, main_zone()); |
94 } | 94 } |
95 | 95 |
96 double RandomInt(double min, double max) { | 96 double RandomInt(double min, double max) { |
97 switch (rng_->NextInt(4)) { | 97 switch (rng_->NextInt(4)) { |
98 case 0: return min; | 98 case 0: return min; |
99 case 1: return max; | 99 case 1: return max; |
100 default: break; | 100 default: break; |
101 } | 101 } |
102 if (min == +V8_INFINITY) return +V8_INFINITY; | 102 if (min == +std::numeric_limits<double>::infinity()) |
103 if (max == -V8_INFINITY) return -V8_INFINITY; | 103 return +std::numeric_limits<double>::infinity(); |
104 if (min == -V8_INFINITY && max == +V8_INFINITY) { | 104 if (max == -std::numeric_limits<double>::infinity()) |
| 105 return -std::numeric_limits<double>::infinity(); |
| 106 if (min == -std::numeric_limits<double>::infinity() && |
| 107 max == +std::numeric_limits<double>::infinity()) { |
105 return rng_->NextInt() * static_cast<double>(rng_->NextInt()); | 108 return rng_->NextInt() * static_cast<double>(rng_->NextInt()); |
106 } | 109 } |
107 double result = nearbyint(min + (max - min) * rng_->NextDouble()); | 110 double result = nearbyint(min + (max - min) * rng_->NextDouble()); |
108 if (IsMinusZero(result)) return 0; | 111 if (IsMinusZero(result)) return 0; |
109 if (std::isnan(result)) return rng_->NextInt(2) ? min : max; | 112 if (std::isnan(result)) return rng_->NextInt(2) ? min : max; |
110 DCHECK(min <= result && result <= max); | 113 DCHECK(min <= result && result <= max); |
111 return result; | 114 return result; |
112 } | 115 } |
113 | 116 |
114 double RandomInt(Type::RangeType* range) { | 117 double RandomInt(Type::RangeType* range) { |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 V(Modulus) | 373 V(Modulus) |
371 | 374 |
372 | 375 |
373 #define TEST_FUNC(name) \ | 376 #define TEST_FUNC(name) \ |
374 TEST(Monotonicity_##name) { \ | 377 TEST(Monotonicity_##name) { \ |
375 TyperTester t; \ | 378 TyperTester t; \ |
376 t.TestBinaryMonotonicity(t.javascript_.name()); \ | 379 t.TestBinaryMonotonicity(t.javascript_.name()); \ |
377 } | 380 } |
378 JSBINOP_LIST(TEST_FUNC) | 381 JSBINOP_LIST(TEST_FUNC) |
379 #undef TEST_FUNC | 382 #undef TEST_FUNC |
OLD | NEW |