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

Side by Side Diff: test/cctest/compiler/test-typer.cc

Issue 882063002: [turbofan] Use unboxed doubles in range types. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Make tests less fragile. 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/compiler/test-simplified-lowering.cc ('k') | test/cctest/test-types.cc » ('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 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/js-operator.h" 8 #include "src/compiler/js-operator.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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 } 80 }
81 81
82 Type* RandomRange(bool int32 = false) { 82 Type* RandomRange(bool int32 = false) {
83 std::vector<double>& numbers = int32 ? int32s : integers; 83 std::vector<double>& numbers = int32 ? int32s : integers;
84 double i = numbers[rng_->NextInt(static_cast<int>(numbers.size()))]; 84 double i = numbers[rng_->NextInt(static_cast<int>(numbers.size()))];
85 double j = numbers[rng_->NextInt(static_cast<int>(numbers.size()))]; 85 double j = numbers[rng_->NextInt(static_cast<int>(numbers.size()))];
86 return NewRange(i, j); 86 return NewRange(i, j);
87 } 87 }
88 88
89 Type* NewRange(double i, double j) { 89 Type* NewRange(double i, double j) {
90 Factory* f = isolate()->factory(); 90 if (i > j) std::swap(i, j);
91 i::Handle<i::Object> min = f->NewNumber(i); 91 return Type::Range(i, j, main_zone());
92 i::Handle<i::Object> max = f->NewNumber(j);
93 if (min->Number() > max->Number()) std::swap(min, max);
94 return Type::Range(min, max, main_zone());
95 } 92 }
96 93
97 double RandomInt(double min, double max) { 94 double RandomInt(double min, double max) {
98 switch (rng_->NextInt(4)) { 95 switch (rng_->NextInt(4)) {
99 case 0: return min; 96 case 0: return min;
100 case 1: return max; 97 case 1: return max;
101 default: break; 98 default: break;
102 } 99 }
103 if (min == +V8_INFINITY) return +V8_INFINITY; 100 if (min == +V8_INFINITY) return +V8_INFINITY;
104 if (max == -V8_INFINITY) return -V8_INFINITY; 101 if (max == -V8_INFINITY) return -V8_INFINITY;
105 if (min == -V8_INFINITY && max == +V8_INFINITY) { 102 if (min == -V8_INFINITY && max == +V8_INFINITY) {
106 return rng_->NextInt() * static_cast<double>(rng_->NextInt()); 103 return rng_->NextInt() * static_cast<double>(rng_->NextInt());
107 } 104 }
108 double result = nearbyint(min + (max - min) * rng_->NextDouble()); 105 double result = nearbyint(min + (max - min) * rng_->NextDouble());
109 if (IsMinusZero(result)) return 0; 106 if (IsMinusZero(result)) return 0;
110 if (std::isnan(result)) return rng_->NextInt(2) ? min : max; 107 if (std::isnan(result)) return rng_->NextInt(2) ? min : max;
111 DCHECK(min <= result && result <= max); 108 DCHECK(min <= result && result <= max);
112 return result; 109 return result;
113 } 110 }
114 111
115 double RandomInt(Type::RangeType* range) { 112 double RandomInt(Type::RangeType* range) {
116 return RandomInt(range->Min()->Number(), range->Max()->Number()); 113 return RandomInt(range->Min(), range->Max());
117 } 114 }
118 115
119 // Careful, this function runs O(max_width^5) trials. 116 // Careful, this function runs O(max_width^5) trials.
120 template <class BinaryFunction> 117 template <class BinaryFunction>
121 void TestBinaryArithOpCloseToZero(const Operator* op, BinaryFunction opfun, 118 void TestBinaryArithOpCloseToZero(const Operator* op, BinaryFunction opfun,
122 int max_width) { 119 int max_width) {
123 const int min_min = -2 - max_width / 2; 120 const int min_min = -2 - max_width / 2;
124 const int max_min = 2 + max_width / 2; 121 const int max_min = 2 + max_width / 2;
125 for (int width = 0; width < max_width; width++) { 122 for (int width = 0; width < max_width; width++) {
126 for (int lmin = min_min; lmin <= max_min; lmin++) { 123 for (int lmin = min_min; lmin <= max_min; lmin++) {
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 V(Modulus) 368 V(Modulus)
372 369
373 370
374 #define TEST_FUNC(name) \ 371 #define TEST_FUNC(name) \
375 TEST(Monotonicity_##name) { \ 372 TEST(Monotonicity_##name) { \
376 TyperTester t; \ 373 TyperTester t; \
377 t.TestBinaryMonotonicity(t.javascript_.name()); \ 374 t.TestBinaryMonotonicity(t.javascript_.name()); \
378 } 375 }
379 JSBINOP_LIST(TEST_FUNC) 376 JSBINOP_LIST(TEST_FUNC)
380 #undef TEST_FUNC 377 #undef TEST_FUNC
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-simplified-lowering.cc ('k') | test/cctest/test-types.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698