| 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(-std::numeric_limits<double>::infinity()); | 35 integers.push_back(-V8_INFINITY); |
| 36 integers.push_back(+std::numeric_limits<double>::infinity()); | 36 integers.push_back(+V8_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 == +std::numeric_limits<double>::infinity()) | 102 if (min == +V8_INFINITY) return +V8_INFINITY; |
| 103 return +std::numeric_limits<double>::infinity(); | 103 if (max == -V8_INFINITY) return -V8_INFINITY; |
| 104 if (max == -std::numeric_limits<double>::infinity()) | 104 if (min == -V8_INFINITY && max == +V8_INFINITY) { |
| 105 return -std::numeric_limits<double>::infinity(); | |
| 106 if (min == -std::numeric_limits<double>::infinity() && | |
| 107 max == +std::numeric_limits<double>::infinity()) { | |
| 108 return rng_->NextInt() * static_cast<double>(rng_->NextInt()); | 105 return rng_->NextInt() * static_cast<double>(rng_->NextInt()); |
| 109 } | 106 } |
| 110 double result = nearbyint(min + (max - min) * rng_->NextDouble()); | 107 double result = nearbyint(min + (max - min) * rng_->NextDouble()); |
| 111 if (IsMinusZero(result)) return 0; | 108 if (IsMinusZero(result)) return 0; |
| 112 if (std::isnan(result)) return rng_->NextInt(2) ? min : max; | 109 if (std::isnan(result)) return rng_->NextInt(2) ? min : max; |
| 113 DCHECK(min <= result && result <= max); | 110 DCHECK(min <= result && result <= max); |
| 114 return result; | 111 return result; |
| 115 } | 112 } |
| 116 | 113 |
| 117 double RandomInt(Type::RangeType* range) { | 114 double RandomInt(Type::RangeType* range) { |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 V(Modulus) | 370 V(Modulus) |
| 374 | 371 |
| 375 | 372 |
| 376 #define TEST_FUNC(name) \ | 373 #define TEST_FUNC(name) \ |
| 377 TEST(Monotonicity_##name) { \ | 374 TEST(Monotonicity_##name) { \ |
| 378 TyperTester t; \ | 375 TyperTester t; \ |
| 379 t.TestBinaryMonotonicity(t.javascript_.name()); \ | 376 t.TestBinaryMonotonicity(t.javascript_.name()); \ |
| 380 } | 377 } |
| 381 JSBINOP_LIST(TEST_FUNC) | 378 JSBINOP_LIST(TEST_FUNC) |
| 382 #undef TEST_FUNC | 379 #undef TEST_FUNC |
| OLD | NEW |