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 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1803 return TypeUnaryOp(node, StringFromCodePointTyper); | 1803 return TypeUnaryOp(node, StringFromCodePointTyper); |
1804 } | 1804 } |
1805 | 1805 |
1806 Type* Typer::Visitor::TypeStringIndexOf(Node* node) { | 1806 Type* Typer::Visitor::TypeStringIndexOf(Node* node) { |
1807 return Type::Range(-1.0, String::kMaxLength - 1.0, zone()); | 1807 return Type::Range(-1.0, String::kMaxLength - 1.0, zone()); |
1808 } | 1808 } |
1809 | 1809 |
1810 Type* Typer::Visitor::TypeCheckBounds(Node* node) { | 1810 Type* Typer::Visitor::TypeCheckBounds(Node* node) { |
1811 Type* index = Operand(node, 0); | 1811 Type* index = Operand(node, 0); |
1812 Type* length = Operand(node, 1); | 1812 Type* length = Operand(node, 1); |
| 1813 if (index->Maybe(Type::MinusZero())) { |
| 1814 index = Type::Union(index, typer_->cache_.kSingletonZero, zone()); |
| 1815 } |
1813 index = Type::Intersect(index, Type::Integral32(), zone()); | 1816 index = Type::Intersect(index, Type::Integral32(), zone()); |
1814 if (!index->IsInhabited() || !length->IsInhabited()) return Type::None(); | 1817 if (!index->IsInhabited() || !length->IsInhabited()) return Type::None(); |
1815 double min = std::max(index->Min(), 0.0); | 1818 double min = std::max(index->Min(), 0.0); |
1816 double max = std::min(index->Max(), length->Max() - 1); | 1819 double max = std::min(index->Max(), length->Max() - 1); |
1817 if (max < min) return Type::None(); | 1820 if (max < min) return Type::None(); |
1818 return Type::Range(min, max, zone()); | 1821 return Type::Range(min, max, zone()); |
1819 } | 1822 } |
1820 | 1823 |
1821 Type* Typer::Visitor::TypeCheckHeapObject(Node* node) { | 1824 Type* Typer::Visitor::TypeCheckHeapObject(Node* node) { |
1822 Type* type = Operand(node, 0); | 1825 Type* type = Operand(node, 0); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1997 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { | 2000 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { |
1998 if (Type::IsInteger(*value)) { | 2001 if (Type::IsInteger(*value)) { |
1999 return Type::Range(value->Number(), value->Number(), zone()); | 2002 return Type::Range(value->Number(), value->Number(), zone()); |
2000 } | 2003 } |
2001 return Type::NewConstant(value, zone()); | 2004 return Type::NewConstant(value, zone()); |
2002 } | 2005 } |
2003 | 2006 |
2004 } // namespace compiler | 2007 } // namespace compiler |
2005 } // namespace internal | 2008 } // namespace internal |
2006 } // namespace v8 | 2009 } // namespace v8 |
OLD | NEW |