OLD | NEW |
1 // Copyright 2015 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/operator-properties.h" | 10 #include "src/compiler/operator-properties.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 Type* expected_type = TypeBinaryOp(op, r1, r2); | 158 Type* expected_type = TypeBinaryOp(op, r1, r2); |
159 for (int i = 0; i < 10; i++) { | 159 for (int i = 0; i < 10; i++) { |
160 double x1 = RandomInt(r1->AsRange()); | 160 double x1 = RandomInt(r1->AsRange()); |
161 double x2 = RandomInt(r2->AsRange()); | 161 double x2 = RandomInt(r2->AsRange()); |
162 double result_value = opfun(x1, x2); | 162 double result_value = opfun(x1, x2); |
163 Type* result_type = Type::NewConstant( | 163 Type* result_type = Type::NewConstant( |
164 isolate()->factory()->NewNumber(result_value), zone()); | 164 isolate()->factory()->NewNumber(result_value), zone()); |
165 EXPECT_TRUE(result_type->Is(expected_type)); | 165 EXPECT_TRUE(result_type->Is(expected_type)); |
166 } | 166 } |
167 } | 167 } |
| 168 // Test extreme cases. |
| 169 double x1 = +1e-308; |
| 170 double x2 = -1e-308; |
| 171 Type* r1 = Type::NewConstant(isolate()->factory()->NewNumber(x1), zone()); |
| 172 Type* r2 = Type::NewConstant(isolate()->factory()->NewNumber(x2), zone()); |
| 173 Type* expected_type = TypeBinaryOp(op, r1, r2); |
| 174 double result_value = opfun(x1, x2); |
| 175 Type* result_type = Type::NewConstant( |
| 176 isolate()->factory()->NewNumber(result_value), zone()); |
| 177 EXPECT_TRUE(result_type->Is(expected_type)); |
168 } | 178 } |
169 | 179 |
170 template <class BinaryFunction> | 180 template <class BinaryFunction> |
171 void TestBinaryCompareOp(const Operator* op, BinaryFunction opfun) { | 181 void TestBinaryCompareOp(const Operator* op, BinaryFunction opfun) { |
172 for (int i = 0; i < 100; ++i) { | 182 for (int i = 0; i < 100; ++i) { |
173 Type* r1 = RandomRange(); | 183 Type* r1 = RandomRange(); |
174 Type* r2 = RandomRange(); | 184 Type* r2 = RandomRange(); |
175 Type* expected_type = TypeBinaryOp(op, r1, r2); | 185 Type* expected_type = TypeBinaryOp(op, r1, r2); |
176 for (int i = 0; i < 10; i++) { | 186 for (int i = 0; i < 10; i++) { |
177 double x1 = RandomInt(r1->AsRange()); | 187 double x1 = RandomInt(r1->AsRange()); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 #define TEST_BINARY_MONOTONICITY(name) \ | 394 #define TEST_BINARY_MONOTONICITY(name) \ |
385 TEST_F(TyperTest, Monotonicity_##name) { \ | 395 TEST_F(TyperTest, Monotonicity_##name) { \ |
386 TestBinaryMonotonicity(javascript_.name(BinaryOperationHint::kAny)); \ | 396 TestBinaryMonotonicity(javascript_.name(BinaryOperationHint::kAny)); \ |
387 } | 397 } |
388 TEST_BINARY_MONOTONICITY(Add) | 398 TEST_BINARY_MONOTONICITY(Add) |
389 #undef TEST_BINARY_MONOTONICITY | 399 #undef TEST_BINARY_MONOTONICITY |
390 | 400 |
391 } // namespace compiler | 401 } // namespace compiler |
392 } // namespace internal | 402 } // namespace internal |
393 } // namespace v8 | 403 } // namespace v8 |
OLD | NEW |