| 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 "src/compiler/typer.h" | 5 #include "src/compiler/typer.h" |
| 6 | 6 |
| 7 #include <iomanip> | 7 #include <iomanip> |
| 8 | 8 |
| 9 #include "src/base/flags.h" | 9 #include "src/base/flags.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 return t->cache_.kIntegerOrMinusZero; | 447 return t->cache_.kIntegerOrMinusZero; |
| 448 } | 448 } |
| 449 | 449 |
| 450 | 450 |
| 451 // static | 451 // static |
| 452 Type* Typer::Visitor::ToLength(Type* type, Typer* t) { | 452 Type* Typer::Visitor::ToLength(Type* type, Typer* t) { |
| 453 // ES6 section 7.1.15 ToLength ( argument ) | 453 // ES6 section 7.1.15 ToLength ( argument ) |
| 454 type = ToInteger(type, t); | 454 type = ToInteger(type, t); |
| 455 double min = type->Min(); | 455 double min = type->Min(); |
| 456 double max = type->Max(); | 456 double max = type->Max(); |
| 457 if (max <= 0.0) { |
| 458 return Type::NewConstant(0, t->zone()); |
| 459 } |
| 460 if (min >= kMaxSafeInteger) { |
| 461 return Type::NewConstant(kMaxSafeInteger, t->zone()); |
| 462 } |
| 457 if (min <= 0.0) min = 0.0; | 463 if (min <= 0.0) min = 0.0; |
| 458 if (max > kMaxSafeInteger) max = kMaxSafeInteger; | 464 if (max >= kMaxSafeInteger) max = kMaxSafeInteger; |
| 459 if (max <= min) max = min; | |
| 460 return Type::Range(min, max, t->zone()); | 465 return Type::Range(min, max, t->zone()); |
| 461 } | 466 } |
| 462 | 467 |
| 463 | 468 |
| 464 // static | 469 // static |
| 465 Type* Typer::Visitor::ToName(Type* type, Typer* t) { | 470 Type* Typer::Visitor::ToName(Type* type, Typer* t) { |
| 466 // ES6 section 7.1.14 ToPropertyKey ( argument ) | 471 // ES6 section 7.1.14 ToPropertyKey ( argument ) |
| 467 type = ToPrimitive(type, t); | 472 type = ToPrimitive(type, t); |
| 468 if (type->Is(Type::Name())) return type; | 473 if (type->Is(Type::Name())) return type; |
| 469 if (type->Maybe(Type::Symbol())) return Type::Name(); | 474 if (type->Maybe(Type::Symbol())) return Type::Name(); |
| (...skipping 1517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1987 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { | 1992 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { |
| 1988 if (Type::IsInteger(*value)) { | 1993 if (Type::IsInteger(*value)) { |
| 1989 return Type::Range(value->Number(), value->Number(), zone()); | 1994 return Type::Range(value->Number(), value->Number(), zone()); |
| 1990 } | 1995 } |
| 1991 return Type::NewConstant(value, zone()); | 1996 return Type::NewConstant(value, zone()); |
| 1992 } | 1997 } |
| 1993 | 1998 |
| 1994 } // namespace compiler | 1999 } // namespace compiler |
| 1995 } // namespace internal | 2000 } // namespace internal |
| 1996 } // namespace v8 | 2001 } // namespace v8 |
| OLD | NEW |