| 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 "src/base/flags.h" | 7 #include "src/base/flags.h" |
| 8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
| 9 #include "src/compilation-dependencies.h" | 9 #include "src/compilation-dependencies.h" |
| 10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 static Type* Rangify(Type*, Typer*); | 233 static Type* Rangify(Type*, Typer*); |
| 234 | 234 |
| 235 static Type* ToPrimitive(Type*, Typer*); | 235 static Type* ToPrimitive(Type*, Typer*); |
| 236 static Type* ToBoolean(Type*, Typer*); | 236 static Type* ToBoolean(Type*, Typer*); |
| 237 static Type* ToInteger(Type*, Typer*); | 237 static Type* ToInteger(Type*, Typer*); |
| 238 static Type* ToLength(Type*, Typer*); | 238 static Type* ToLength(Type*, Typer*); |
| 239 static Type* ToName(Type*, Typer*); | 239 static Type* ToName(Type*, Typer*); |
| 240 static Type* ToNumber(Type*, Typer*); | 240 static Type* ToNumber(Type*, Typer*); |
| 241 static Type* ToObject(Type*, Typer*); | 241 static Type* ToObject(Type*, Typer*); |
| 242 static Type* ToString(Type*, Typer*); | 242 static Type* ToString(Type*, Typer*); |
| 243 static Type* NumberFloor(Type*, Typer*); |
| 243 static Type* NumberToInt32(Type*, Typer*); | 244 static Type* NumberToInt32(Type*, Typer*); |
| 244 static Type* NumberToUint32(Type*, Typer*); | 245 static Type* NumberToUint32(Type*, Typer*); |
| 245 | 246 |
| 246 static Type* ObjectIsNumber(Type*, Typer*); | 247 static Type* ObjectIsNumber(Type*, Typer*); |
| 247 static Type* ObjectIsReceiver(Type*, Typer*); | 248 static Type* ObjectIsReceiver(Type*, Typer*); |
| 248 static Type* ObjectIsSmi(Type*, Typer*); | 249 static Type* ObjectIsSmi(Type*, Typer*); |
| 249 static Type* ObjectIsUndetectable(Type*, Typer*); | 250 static Type* ObjectIsUndetectable(Type*, Typer*); |
| 250 | 251 |
| 251 static Type* JSAddRanger(RangeType*, RangeType*, Typer*); | 252 static Type* JSAddRanger(RangeType*, RangeType*, Typer*); |
| 252 static Type* JSSubtractRanger(RangeType*, RangeType*, Typer*); | 253 static Type* JSSubtractRanger(RangeType*, RangeType*, Typer*); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 | 481 |
| 481 | 482 |
| 482 // static | 483 // static |
| 483 Type* Typer::Visitor::ToString(Type* type, Typer* t) { | 484 Type* Typer::Visitor::ToString(Type* type, Typer* t) { |
| 484 // ES6 section 7.1.12 ToString ( argument ) | 485 // ES6 section 7.1.12 ToString ( argument ) |
| 485 type = ToPrimitive(type, t); | 486 type = ToPrimitive(type, t); |
| 486 if (type->Is(Type::String())) return type; | 487 if (type->Is(Type::String())) return type; |
| 487 return Type::String(); | 488 return Type::String(); |
| 488 } | 489 } |
| 489 | 490 |
| 491 // static |
| 492 Type* Typer::Visitor::NumberFloor(Type* type, Typer* t) { |
| 493 DCHECK(type->Is(Type::Number())); |
| 494 if (type->Is(t->cache_.kIntegerOrMinusZeroOrNaN)) return type; |
| 495 return t->cache_.kIntegerOrMinusZeroOrNaN; |
| 496 } |
| 490 | 497 |
| 491 Type* Typer::Visitor::NumberToInt32(Type* type, Typer* t) { | 498 Type* Typer::Visitor::NumberToInt32(Type* type, Typer* t) { |
| 492 // TODO(neis): DCHECK(type->Is(Type::Number())); | 499 // TODO(neis): DCHECK(type->Is(Type::Number())); |
| 493 if (type->Is(Type::Signed32())) return type; | 500 if (type->Is(Type::Signed32())) return type; |
| 494 if (type->Is(t->cache_.kZeroish)) return t->cache_.kSingletonZero; | 501 if (type->Is(t->cache_.kZeroish)) return t->cache_.kSingletonZero; |
| 495 if (type->Is(t->signed32ish_)) { | 502 if (type->Is(t->signed32ish_)) { |
| 496 return Type::Intersect( | 503 return Type::Intersect( |
| 497 Type::Union(type, t->cache_.kSingletonZero, t->zone()), | 504 Type::Union(type, t->cache_.kSingletonZero, t->zone()), |
| 498 Type::Signed32(), t->zone()); | 505 Type::Signed32(), t->zone()); |
| 499 } | 506 } |
| (...skipping 1208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1708 | 1715 |
| 1709 Type* Typer::Visitor::TypeNumberShiftRight(Node* node) { | 1716 Type* Typer::Visitor::TypeNumberShiftRight(Node* node) { |
| 1710 return Type::Signed32(); | 1717 return Type::Signed32(); |
| 1711 } | 1718 } |
| 1712 | 1719 |
| 1713 | 1720 |
| 1714 Type* Typer::Visitor::TypeNumberShiftRightLogical(Node* node) { | 1721 Type* Typer::Visitor::TypeNumberShiftRightLogical(Node* node) { |
| 1715 return Type::Unsigned32(); | 1722 return Type::Unsigned32(); |
| 1716 } | 1723 } |
| 1717 | 1724 |
| 1725 Type* Typer::Visitor::TypeNumberFloor(Node* node) { |
| 1726 return TypeUnaryOp(node, NumberFloor); |
| 1727 } |
| 1718 | 1728 |
| 1719 Type* Typer::Visitor::TypeNumberToInt32(Node* node) { | 1729 Type* Typer::Visitor::TypeNumberToInt32(Node* node) { |
| 1720 return TypeUnaryOp(node, NumberToInt32); | 1730 return TypeUnaryOp(node, NumberToInt32); |
| 1721 } | 1731 } |
| 1722 | 1732 |
| 1723 | 1733 |
| 1724 Type* Typer::Visitor::TypeNumberToUint32(Node* node) { | 1734 Type* Typer::Visitor::TypeNumberToUint32(Node* node) { |
| 1725 return TypeUnaryOp(node, NumberToUint32); | 1735 return TypeUnaryOp(node, NumberToUint32); |
| 1726 } | 1736 } |
| 1727 | 1737 |
| (...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2467 } | 2477 } |
| 2468 if (Type::IsInteger(*value)) { | 2478 if (Type::IsInteger(*value)) { |
| 2469 return Type::Range(value->Number(), value->Number(), zone()); | 2479 return Type::Range(value->Number(), value->Number(), zone()); |
| 2470 } | 2480 } |
| 2471 return Type::Constant(value, zone()); | 2481 return Type::Constant(value, zone()); |
| 2472 } | 2482 } |
| 2473 | 2483 |
| 2474 } // namespace compiler | 2484 } // namespace compiler |
| 2475 } // namespace internal | 2485 } // namespace internal |
| 2476 } // namespace v8 | 2486 } // namespace v8 |
| OLD | NEW |