| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 44     int32s.push_back(+1); | 44     int32s.push_back(+1); | 
| 45     int32s.push_back(kMinInt); | 45     int32s.push_back(kMinInt); | 
| 46     int32s.push_back(kMaxInt); | 46     int32s.push_back(kMaxInt); | 
| 47     for (int i = 0; i < 10; ++i) { | 47     for (int i = 0; i < 10; ++i) { | 
| 48       int32s.push_back(rng_->NextInt()); | 48       int32s.push_back(rng_->NextInt()); | 
| 49     } | 49     } | 
| 50   } | 50   } | 
| 51 | 51 | 
| 52   Types types_; | 52   Types types_; | 
| 53   JSOperatorBuilder javascript_; | 53   JSOperatorBuilder javascript_; | 
| 54   BinaryOperationHints const hints_ = BinaryOperationHints::Any(); | 54   BinaryOperationHint const hints_ = BinaryOperationHint::kAny; | 
| 55   Node* context_node_; | 55   Node* context_node_; | 
| 56   v8::base::RandomNumberGenerator* rng_; | 56   v8::base::RandomNumberGenerator* rng_; | 
| 57   std::vector<double> integers; | 57   std::vector<double> integers; | 
| 58   std::vector<double> int32s; | 58   std::vector<double> int32s; | 
| 59 | 59 | 
| 60   Type* TypeBinaryOp(const Operator* op, Type* lhs, Type* rhs) { | 60   Type* TypeBinaryOp(const Operator* op, Type* lhs, Type* rhs) { | 
| 61     Node* p0 = Parameter(0); | 61     Node* p0 = Parameter(0); | 
| 62     Node* p1 = Parameter(1); | 62     Node* p1 = Parameter(1); | 
| 63     NodeProperties::SetType(p0, lhs); | 63     NodeProperties::SetType(p0, lhs); | 
| 64     NodeProperties::SetType(p1, rhs); | 64     NodeProperties::SetType(p1, rhs); | 
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 283   TestBinaryBitOp(javascript_.ShiftLeft(hints_), shift_left); | 283   TestBinaryBitOp(javascript_.ShiftLeft(hints_), shift_left); | 
| 284 } | 284 } | 
| 285 | 285 | 
| 286 | 286 | 
| 287 TEST_F(TyperTest, TypeJSShiftRight) { | 287 TEST_F(TyperTest, TypeJSShiftRight) { | 
| 288   TestBinaryBitOp(javascript_.ShiftRight(hints_), shift_right); | 288   TestBinaryBitOp(javascript_.ShiftRight(hints_), shift_right); | 
| 289 } | 289 } | 
| 290 | 290 | 
| 291 | 291 | 
| 292 TEST_F(TyperTest, TypeJSLessThan) { | 292 TEST_F(TyperTest, TypeJSLessThan) { | 
| 293   TestBinaryCompareOp(javascript_.LessThan(CompareOperationHints::Any()), | 293   TestBinaryCompareOp(javascript_.LessThan(CompareOperationHint::kAny), | 
| 294                       std::less<double>()); | 294                       std::less<double>()); | 
| 295 } | 295 } | 
| 296 | 296 | 
| 297 | 297 | 
| 298 TEST_F(TyperTest, TypeJSLessThanOrEqual) { | 298 TEST_F(TyperTest, TypeJSLessThanOrEqual) { | 
| 299   TestBinaryCompareOp(javascript_.LessThanOrEqual(CompareOperationHints::Any()), | 299   TestBinaryCompareOp(javascript_.LessThanOrEqual(CompareOperationHint::kAny), | 
| 300                       std::less_equal<double>()); | 300                       std::less_equal<double>()); | 
| 301 } | 301 } | 
| 302 | 302 | 
| 303 | 303 | 
| 304 TEST_F(TyperTest, TypeJSGreaterThan) { | 304 TEST_F(TyperTest, TypeJSGreaterThan) { | 
| 305   TestBinaryCompareOp(javascript_.GreaterThan(CompareOperationHints::Any()), | 305   TestBinaryCompareOp(javascript_.GreaterThan(CompareOperationHint::kAny), | 
| 306                       std::greater<double>()); | 306                       std::greater<double>()); | 
| 307 } | 307 } | 
| 308 | 308 | 
| 309 | 309 | 
| 310 TEST_F(TyperTest, TypeJSGreaterThanOrEqual) { | 310 TEST_F(TyperTest, TypeJSGreaterThanOrEqual) { | 
| 311   TestBinaryCompareOp( | 311   TestBinaryCompareOp( | 
| 312       javascript_.GreaterThanOrEqual(CompareOperationHints::Any()), | 312       javascript_.GreaterThanOrEqual(CompareOperationHint::kAny), | 
| 313       std::greater_equal<double>()); | 313       std::greater_equal<double>()); | 
| 314 } | 314 } | 
| 315 | 315 | 
| 316 | 316 | 
| 317 TEST_F(TyperTest, TypeJSEqual) { | 317 TEST_F(TyperTest, TypeJSEqual) { | 
| 318   TestBinaryCompareOp(javascript_.Equal(CompareOperationHints::Any()), | 318   TestBinaryCompareOp(javascript_.Equal(CompareOperationHint::kAny), | 
| 319                       std::equal_to<double>()); | 319                       std::equal_to<double>()); | 
| 320 } | 320 } | 
| 321 | 321 | 
| 322 | 322 | 
| 323 TEST_F(TyperTest, TypeJSNotEqual) { | 323 TEST_F(TyperTest, TypeJSNotEqual) { | 
| 324   TestBinaryCompareOp(javascript_.NotEqual(CompareOperationHints::Any()), | 324   TestBinaryCompareOp(javascript_.NotEqual(CompareOperationHint::kAny), | 
| 325                       std::not_equal_to<double>()); | 325                       std::not_equal_to<double>()); | 
| 326 } | 326 } | 
| 327 | 327 | 
| 328 | 328 | 
| 329 // For numbers there's no difference between strict and non-strict equality. | 329 // For numbers there's no difference between strict and non-strict equality. | 
| 330 TEST_F(TyperTest, TypeJSStrictEqual) { | 330 TEST_F(TyperTest, TypeJSStrictEqual) { | 
| 331   TestBinaryCompareOp(javascript_.StrictEqual(CompareOperationHints::Any()), | 331   TestBinaryCompareOp(javascript_.StrictEqual(CompareOperationHint::kAny), | 
| 332                       std::equal_to<double>()); | 332                       std::equal_to<double>()); | 
| 333 } | 333 } | 
| 334 | 334 | 
| 335 | 335 | 
| 336 TEST_F(TyperTest, TypeJSStrictNotEqual) { | 336 TEST_F(TyperTest, TypeJSStrictNotEqual) { | 
| 337   TestBinaryCompareOp(javascript_.StrictNotEqual(CompareOperationHints::Any()), | 337   TestBinaryCompareOp(javascript_.StrictNotEqual(CompareOperationHint::kAny), | 
| 338                       std::not_equal_to<double>()); | 338                       std::not_equal_to<double>()); | 
| 339 } | 339 } | 
| 340 | 340 | 
| 341 | 341 | 
| 342 //------------------------------------------------------------------------------ | 342 //------------------------------------------------------------------------------ | 
| 343 // Monotonicity | 343 // Monotonicity | 
| 344 | 344 | 
| 345 #define TEST_BINARY_MONOTONICITY(name)                                      \ | 345 #define TEST_BINARY_MONOTONICITY(name)                                    \ | 
| 346   TEST_F(TyperTest, Monotonicity_##name) {                                  \ | 346   TEST_F(TyperTest, Monotonicity_##name) {                                \ | 
| 347     TestBinaryMonotonicity(javascript_.name(CompareOperationHints::Any())); \ | 347     TestBinaryMonotonicity(javascript_.name(CompareOperationHint::kAny)); \ | 
| 348   } | 348   } | 
| 349 TEST_BINARY_MONOTONICITY(Equal) | 349 TEST_BINARY_MONOTONICITY(Equal) | 
| 350 TEST_BINARY_MONOTONICITY(NotEqual) | 350 TEST_BINARY_MONOTONICITY(NotEqual) | 
| 351 TEST_BINARY_MONOTONICITY(StrictEqual) | 351 TEST_BINARY_MONOTONICITY(StrictEqual) | 
| 352 TEST_BINARY_MONOTONICITY(StrictNotEqual) | 352 TEST_BINARY_MONOTONICITY(StrictNotEqual) | 
| 353 TEST_BINARY_MONOTONICITY(LessThan) | 353 TEST_BINARY_MONOTONICITY(LessThan) | 
| 354 TEST_BINARY_MONOTONICITY(GreaterThan) | 354 TEST_BINARY_MONOTONICITY(GreaterThan) | 
| 355 TEST_BINARY_MONOTONICITY(LessThanOrEqual) | 355 TEST_BINARY_MONOTONICITY(LessThanOrEqual) | 
| 356 TEST_BINARY_MONOTONICITY(GreaterThanOrEqual) | 356 TEST_BINARY_MONOTONICITY(GreaterThanOrEqual) | 
| 357 #undef TEST_BINARY_MONOTONICITY | 357 #undef TEST_BINARY_MONOTONICITY | 
| 358 | 358 | 
| 359 #define TEST_BINARY_MONOTONICITY(name)                                     \ | 359 #define TEST_BINARY_MONOTONICITY(name)                                   \ | 
| 360   TEST_F(TyperTest, Monotonicity_##name) {                                 \ | 360   TEST_F(TyperTest, Monotonicity_##name) {                               \ | 
| 361     TestBinaryMonotonicity(javascript_.name(BinaryOperationHints::Any())); \ | 361     TestBinaryMonotonicity(javascript_.name(BinaryOperationHint::kAny)); \ | 
| 362   } | 362   } | 
| 363 TEST_BINARY_MONOTONICITY(BitwiseOr) | 363 TEST_BINARY_MONOTONICITY(BitwiseOr) | 
| 364 TEST_BINARY_MONOTONICITY(BitwiseXor) | 364 TEST_BINARY_MONOTONICITY(BitwiseXor) | 
| 365 TEST_BINARY_MONOTONICITY(BitwiseAnd) | 365 TEST_BINARY_MONOTONICITY(BitwiseAnd) | 
| 366 TEST_BINARY_MONOTONICITY(ShiftLeft) | 366 TEST_BINARY_MONOTONICITY(ShiftLeft) | 
| 367 TEST_BINARY_MONOTONICITY(ShiftRight) | 367 TEST_BINARY_MONOTONICITY(ShiftRight) | 
| 368 TEST_BINARY_MONOTONICITY(ShiftRightLogical) | 368 TEST_BINARY_MONOTONICITY(ShiftRightLogical) | 
| 369 TEST_BINARY_MONOTONICITY(Add) | 369 TEST_BINARY_MONOTONICITY(Add) | 
| 370 TEST_BINARY_MONOTONICITY(Subtract) | 370 TEST_BINARY_MONOTONICITY(Subtract) | 
| 371 TEST_BINARY_MONOTONICITY(Multiply) | 371 TEST_BINARY_MONOTONICITY(Multiply) | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
| 383   for (auto i : values) { | 383   for (auto i : values) { | 
| 384     Node* c = graph()->NewNode(common()->Int32Constant(i)); | 384     Node* c = graph()->NewNode(common()->Int32Constant(i)); | 
| 385     Type* type = NodeProperties::GetType(c); | 385     Type* type = NodeProperties::GetType(c); | 
| 386     EXPECT_TRUE(type->Is(NewRange(i, i))); | 386     EXPECT_TRUE(type->Is(NewRange(i, i))); | 
| 387   } | 387   } | 
| 388 } | 388 } | 
| 389 | 389 | 
| 390 }  // namespace compiler | 390 }  // namespace compiler | 
| 391 }  // namespace internal | 391 }  // namespace internal | 
| 392 }  // namespace v8 | 392 }  // namespace v8 | 
| OLD | NEW | 
|---|