| 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 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1520 | 1520 |
| 1521 Type* Typer::Visitor::TypeStringEqual(Node* node) { return Type::Boolean(); } | 1521 Type* Typer::Visitor::TypeStringEqual(Node* node) { return Type::Boolean(); } |
| 1522 | 1522 |
| 1523 Type* Typer::Visitor::TypeStringLessThan(Node* node) { return Type::Boolean(); } | 1523 Type* Typer::Visitor::TypeStringLessThan(Node* node) { return Type::Boolean(); } |
| 1524 | 1524 |
| 1525 Type* Typer::Visitor::TypeStringLessThanOrEqual(Node* node) { | 1525 Type* Typer::Visitor::TypeStringLessThanOrEqual(Node* node) { |
| 1526 return Type::Boolean(); | 1526 return Type::Boolean(); |
| 1527 } | 1527 } |
| 1528 | 1528 |
| 1529 Type* Typer::Visitor::StringFromCharCodeTyper(Type* type, Typer* t) { | 1529 Type* Typer::Visitor::StringFromCharCodeTyper(Type* type, Typer* t) { |
| 1530 type = NumberToUint32(ToNumber(type, t), t); | |
| 1531 Factory* f = t->isolate()->factory(); | |
| 1532 double min = type->Min(); | |
| 1533 double max = type->Max(); | |
| 1534 if (min == max) { | |
| 1535 uint32_t code = static_cast<uint32_t>(min) & String::kMaxUtf16CodeUnitU; | |
| 1536 Handle<String> string = f->LookupSingleCharacterStringFromCode(code); | |
| 1537 return Type::HeapConstant(string, t->zone()); | |
| 1538 } | |
| 1539 return Type::String(); | 1530 return Type::String(); |
| 1540 } | 1531 } |
| 1541 | 1532 |
| 1542 Type* Typer::Visitor::StringFromCodePointTyper(Type* type, Typer* t) { | 1533 Type* Typer::Visitor::StringFromCodePointTyper(Type* type, Typer* t) { |
| 1543 type = NumberToUint32(ToNumber(type, t), t); | |
| 1544 Factory* f = t->isolate()->factory(); | |
| 1545 double min = type->Min(); | |
| 1546 double max = type->Max(); | |
| 1547 if (min == max) { | |
| 1548 uint32_t code = static_cast<uint32_t>(min) & String::kMaxUtf16CodeUnitU; | |
| 1549 Handle<String> string = f->LookupSingleCharacterStringFromCode(code); | |
| 1550 return Type::HeapConstant(string, t->zone()); | |
| 1551 } | |
| 1552 return Type::String(); | 1534 return Type::String(); |
| 1553 } | 1535 } |
| 1554 | 1536 |
| 1555 Type* Typer::Visitor::TypeStringCharCodeAt(Node* node) { | 1537 Type* Typer::Visitor::TypeStringCharCodeAt(Node* node) { |
| 1556 // TODO(bmeurer): We could do better here based on inputs. | 1538 // TODO(bmeurer): We could do better here based on inputs. |
| 1557 return Type::Range(0, kMaxUInt16, zone()); | 1539 return Type::Range(0, kMaxUInt16, zone()); |
| 1558 } | 1540 } |
| 1559 | 1541 |
| 1560 Type* Typer::Visitor::TypeStringFromCharCode(Node* node) { | 1542 Type* Typer::Visitor::TypeStringFromCharCode(Node* node) { |
| 1561 return TypeUnaryOp(node, StringFromCharCodeTyper); | 1543 return TypeUnaryOp(node, StringFromCharCodeTyper); |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1721 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { | 1703 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { |
| 1722 if (Type::IsInteger(*value)) { | 1704 if (Type::IsInteger(*value)) { |
| 1723 return Type::Range(value->Number(), value->Number(), zone()); | 1705 return Type::Range(value->Number(), value->Number(), zone()); |
| 1724 } | 1706 } |
| 1725 return Type::NewConstant(value, zone()); | 1707 return Type::NewConstant(value, zone()); |
| 1726 } | 1708 } |
| 1727 | 1709 |
| 1728 } // namespace compiler | 1710 } // namespace compiler |
| 1729 } // namespace internal | 1711 } // namespace internal |
| 1730 } // namespace v8 | 1712 } // namespace v8 |
| OLD | NEW |