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 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 UNREACHABLE(); | 1227 UNREACHABLE(); |
1228 return nullptr; | 1228 return nullptr; |
1229 } | 1229 } |
1230 | 1230 |
1231 | 1231 |
1232 Type* Typer::Visitor::WrapContextTypeForInput(Node* node) { | 1232 Type* Typer::Visitor::WrapContextTypeForInput(Node* node) { |
1233 Type* outer = TypeOrNone(NodeProperties::GetContextInput(node)); | 1233 Type* outer = TypeOrNone(NodeProperties::GetContextInput(node)); |
1234 if (outer->Is(Type::None())) { | 1234 if (outer->Is(Type::None())) { |
1235 return Type::None(); | 1235 return Type::None(); |
1236 } else { | 1236 } else { |
1237 DCHECK(outer->Maybe(Type::Internal())); | 1237 DCHECK(outer->Maybe(Type::OtherInternal())); |
1238 return Type::Context(outer, zone()); | 1238 return Type::Context(outer, zone()); |
1239 } | 1239 } |
1240 } | 1240 } |
1241 | 1241 |
1242 | 1242 |
1243 Type* Typer::Visitor::TypeJSCreateFunctionContext(Node* node) { | 1243 Type* Typer::Visitor::TypeJSCreateFunctionContext(Node* node) { |
1244 return WrapContextTypeForInput(node); | 1244 return WrapContextTypeForInput(node); |
1245 } | 1245 } |
1246 | 1246 |
1247 | 1247 |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1576 Type* arg = Operand(node, 0); | 1576 Type* arg = Operand(node, 0); |
1577 return Type::Intersect(arg, typer_->cache_.kSmi, zone()); | 1577 return Type::Intersect(arg, typer_->cache_.kSmi, zone()); |
1578 } | 1578 } |
1579 | 1579 |
1580 Type* Typer::Visitor::TypeCheckFloat64Hole(Node* node) { | 1580 Type* Typer::Visitor::TypeCheckFloat64Hole(Node* node) { |
1581 Type* type = Operand(node, 0); | 1581 Type* type = Operand(node, 0); |
1582 return type; | 1582 return type; |
1583 } | 1583 } |
1584 | 1584 |
1585 Type* Typer::Visitor::TypeCheckTaggedHole(Node* node) { | 1585 Type* Typer::Visitor::TypeCheckTaggedHole(Node* node) { |
1586 CheckTaggedHoleMode mode = CheckTaggedHoleModeOf(node->op()); | |
1587 Type* type = Operand(node, 0); | 1586 Type* type = Operand(node, 0); |
1588 type = Type::Intersect(type, Type::NonInternal(), zone()); | 1587 type = Type::Intersect(type, Type::NonInternal(), zone()); |
1589 switch (mode) { | 1588 return type; |
1590 case CheckTaggedHoleMode::kConvertHoleToUndefined: { | 1589 } |
1591 // The hole is turned into undefined. | 1590 |
1592 type = Type::Union(type, Type::Undefined(), zone()); | 1591 Type* Typer::Visitor::TypeConvertTaggedHoleToUndefined(Node* node) { |
1593 break; | 1592 Type* type = Operand(node, 0); |
1594 } | 1593 if (type->Maybe(Type::Hole())) { |
1595 case CheckTaggedHoleMode::kNeverReturnHole: { | 1594 // Turn "the hole" into undefined. |
1596 // We deoptimize in case of the hole. | 1595 type = Type::Intersect(type, Type::NonInternal(), zone()); |
1597 break; | 1596 type = Type::Union(type, Type::Undefined(), zone()); |
1598 } | |
1599 } | 1597 } |
1600 return type; | 1598 return type; |
1601 } | 1599 } |
1602 | 1600 |
1603 Type* Typer::Visitor::TypeAllocate(Node* node) { return Type::TaggedPointer(); } | 1601 Type* Typer::Visitor::TypeAllocate(Node* node) { return Type::TaggedPointer(); } |
1604 | 1602 |
1605 Type* Typer::Visitor::TypeLoadField(Node* node) { | 1603 Type* Typer::Visitor::TypeLoadField(Node* node) { |
1606 return FieldAccessOf(node->op()).type; | 1604 return FieldAccessOf(node->op()).type; |
1607 } | 1605 } |
1608 | 1606 |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2330 } | 2328 } |
2331 if (Type::IsInteger(*value)) { | 2329 if (Type::IsInteger(*value)) { |
2332 return Type::Range(value->Number(), value->Number(), zone()); | 2330 return Type::Range(value->Number(), value->Number(), zone()); |
2333 } | 2331 } |
2334 return Type::Constant(value, zone()); | 2332 return Type::Constant(value, zone()); |
2335 } | 2333 } |
2336 | 2334 |
2337 } // namespace compiler | 2335 } // namespace compiler |
2338 } // namespace internal | 2336 } // namespace internal |
2339 } // namespace v8 | 2337 } // namespace v8 |
OLD | NEW |