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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 265 |
266 #define DECLARE_METHOD(x) static Type* x##Typer(Type*, Type*, Typer*); | 266 #define DECLARE_METHOD(x) static Type* x##Typer(Type*, Type*, Typer*); |
267 JS_SIMPLE_BINOP_LIST(DECLARE_METHOD) | 267 JS_SIMPLE_BINOP_LIST(DECLARE_METHOD) |
268 #undef DECLARE_METHOD | 268 #undef DECLARE_METHOD |
269 | 269 |
270 static Type* JSTypeOfTyper(Type*, Typer*); | 270 static Type* JSTypeOfTyper(Type*, Typer*); |
271 static Type* JSLoadPropertyTyper(Type*, Type*, Typer*); | 271 static Type* JSLoadPropertyTyper(Type*, Type*, Typer*); |
272 static Type* JSCallFunctionTyper(Type*, Typer*); | 272 static Type* JSCallFunctionTyper(Type*, Typer*); |
273 | 273 |
274 static Type* ReferenceEqualTyper(Type*, Type*, Typer*); | 274 static Type* ReferenceEqualTyper(Type*, Type*, Typer*); |
| 275 static Type* StringFromCharCodeTyper(Type*, Typer*); |
275 | 276 |
276 Reduction UpdateType(Node* node, Type* current) { | 277 Reduction UpdateType(Node* node, Type* current) { |
277 if (NodeProperties::IsTyped(node)) { | 278 if (NodeProperties::IsTyped(node)) { |
278 // Widen the type of a previously typed node. | 279 // Widen the type of a previously typed node. |
279 Type* previous = NodeProperties::GetType(node); | 280 Type* previous = NodeProperties::GetType(node); |
280 if (node->opcode() == IrOpcode::kPhi) { | 281 if (node->opcode() == IrOpcode::kPhi) { |
281 // Speed up termination in the presence of range types: | 282 // Speed up termination in the presence of range types: |
282 current = Weaken(node, current, previous); | 283 current = Weaken(node, current, previous); |
283 } | 284 } |
284 | 285 |
(...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1807 } | 1808 } |
1808 | 1809 |
1809 Type* Typer::Visitor::TypeStringEqual(Node* node) { return Type::Boolean(); } | 1810 Type* Typer::Visitor::TypeStringEqual(Node* node) { return Type::Boolean(); } |
1810 | 1811 |
1811 Type* Typer::Visitor::TypeStringLessThan(Node* node) { return Type::Boolean(); } | 1812 Type* Typer::Visitor::TypeStringLessThan(Node* node) { return Type::Boolean(); } |
1812 | 1813 |
1813 Type* Typer::Visitor::TypeStringLessThanOrEqual(Node* node) { | 1814 Type* Typer::Visitor::TypeStringLessThanOrEqual(Node* node) { |
1814 return Type::Boolean(); | 1815 return Type::Boolean(); |
1815 } | 1816 } |
1816 | 1817 |
| 1818 Type* Typer::Visitor::StringFromCharCodeTyper(Type* type, Typer* t) { |
| 1819 type = NumberToUint32(ToNumber(type, t), t); |
| 1820 Factory* f = t->isolate()->factory(); |
| 1821 double min = type->Min(); |
| 1822 double max = type->Max(); |
| 1823 if (min == max) { |
| 1824 uint32_t code = static_cast<uint32_t>(min) & String::kMaxUtf16CodeUnitU; |
| 1825 Handle<String> string = f->LookupSingleCharacterStringFromCode(code); |
| 1826 return Type::Constant(string, t->zone()); |
| 1827 } |
| 1828 return Type::String(); |
| 1829 } |
| 1830 |
| 1831 Type* Typer::Visitor::TypeStringFromCharCode(Node* node) { |
| 1832 return TypeUnaryOp(node, StringFromCharCodeTyper); |
| 1833 } |
| 1834 |
1817 Type* Typer::Visitor::TypeStringToNumber(Node* node) { | 1835 Type* Typer::Visitor::TypeStringToNumber(Node* node) { |
1818 return TypeUnaryOp(node, ToNumber); | 1836 return TypeUnaryOp(node, ToNumber); |
1819 } | 1837 } |
1820 | 1838 |
1821 namespace { | 1839 namespace { |
1822 | 1840 |
1823 Type* ChangeRepresentation(Type* type, Type* rep, Zone* zone) { | 1841 Type* ChangeRepresentation(Type* type, Type* rep, Zone* zone) { |
1824 return Type::Union(Type::Semantic(type, zone), | 1842 return Type::Union(Type::Semantic(type, zone), |
1825 Type::Representation(rep, zone), zone); | 1843 Type::Representation(rep, zone), zone); |
1826 } | 1844 } |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2598 } | 2616 } |
2599 if (Type::IsInteger(*value)) { | 2617 if (Type::IsInteger(*value)) { |
2600 return Type::Range(value->Number(), value->Number(), zone()); | 2618 return Type::Range(value->Number(), value->Number(), zone()); |
2601 } | 2619 } |
2602 return Type::Constant(value, zone()); | 2620 return Type::Constant(value, zone()); |
2603 } | 2621 } |
2604 | 2622 |
2605 } // namespace compiler | 2623 } // namespace compiler |
2606 } // namespace internal | 2624 } // namespace internal |
2607 } // namespace v8 | 2625 } // namespace v8 |
OLD | NEW |