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/bootstrapper.h" | 5 #include "src/bootstrapper.h" |
6 #include "src/compiler/graph-inl.h" | 6 #include "src/compiler/graph-inl.h" |
7 #include "src/compiler/js-operator.h" | 7 #include "src/compiler/js-operator.h" |
8 #include "src/compiler/node.h" | 8 #include "src/compiler/node.h" |
9 #include "src/compiler/node-properties-inl.h" | 9 #include "src/compiler/node-properties-inl.h" |
10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 singleton_one = Type::Range(one, one, zone); | 62 singleton_one = Type::Range(one, one, zone); |
63 zero_or_one = Type::Union(singleton_zero, singleton_one, zone); | 63 zero_or_one = Type::Union(singleton_zero, singleton_one, zone); |
64 zeroish = Type::Union(singleton_zero, nan_or_minuszero, zone); | 64 zeroish = Type::Union(singleton_zero, nan_or_minuszero, zone); |
65 signed32ish = Type::Union(signed32, truncating_to_zero, zone); | 65 signed32ish = Type::Union(signed32, truncating_to_zero, zone); |
66 unsigned32ish = Type::Union(unsigned32, truncating_to_zero, zone); | 66 unsigned32ish = Type::Union(unsigned32, truncating_to_zero, zone); |
67 falsish = Type::Union(Type::Undetectable(), | 67 falsish = Type::Union(Type::Undetectable(), |
68 Type::Union(zeroish, undefined_or_null, zone), zone); | 68 Type::Union(zeroish, undefined_or_null, zone), zone); |
69 integer = Type::Range(minusinfinity, infinity, zone); | 69 integer = Type::Range(minusinfinity, infinity, zone); |
70 weakint = Type::Union(integer, nan_or_minuszero, zone); | 70 weakint = Type::Union(integer, nan_or_minuszero, zone); |
71 | 71 |
| 72 signed8_ = Type::Range(f->NewNumber(kMinInt8), f->NewNumber(kMaxInt8), zone); |
| 73 unsigned8_ = Type::Range(zero, f->NewNumber(kMaxUInt8), zone); |
| 74 signed16_ = |
| 75 Type::Range(f->NewNumber(kMinInt16), f->NewNumber(kMaxInt16), zone); |
| 76 unsigned16_ = Type::Range(zero, f->NewNumber(kMaxUInt16), zone); |
| 77 |
72 number_fun0_ = Type::Function(number, zone); | 78 number_fun0_ = Type::Function(number, zone); |
73 number_fun1_ = Type::Function(number, number, zone); | 79 number_fun1_ = Type::Function(number, number, zone); |
74 number_fun2_ = Type::Function(number, number, number, zone); | 80 number_fun2_ = Type::Function(number, number, number, zone); |
75 weakint_fun1_ = Type::Function(weakint, number, zone); | 81 weakint_fun1_ = Type::Function(weakint, number, zone); |
76 imul_fun_ = Type::Function(signed32, integral32, integral32, zone); | 82 imul_fun_ = Type::Function(signed32, integral32, integral32, zone); |
77 clz32_fun_ = Type::Function( | 83 clz32_fun_ = Type::Function( |
78 Type::Range(zero, f->NewNumber(32), zone), number, zone); | 84 Type::Range(zero, f->NewNumber(32), zone), number, zone); |
79 random_fun_ = Type::Function(Type::Union( | 85 random_fun_ = Type::Function(Type::Union( |
80 Type::UnsignedSmall(), Type::OtherNumber(), zone), zone); | 86 Type::UnsignedSmall(), Type::OtherNumber(), zone), zone); |
81 | 87 |
82 Type* int8 = Type::Intersect( | 88 #define NATIVE_TYPE(sem, rep) Type::Intersect(sem, rep, zone) |
83 Type::Range(f->NewNumber(-0x7F), f->NewNumber(0x7F-1), zone), | 89 Type* int8 = NATIVE_TYPE(signed8_, Type::UntaggedInt8()); |
84 Type::UntaggedInt8(), zone); | 90 Type* uint8 = NATIVE_TYPE(unsigned8_, Type::UntaggedInt8()); |
85 Type* int16 = Type::Intersect( | 91 Type* int16 = NATIVE_TYPE(signed16_, Type::UntaggedInt16()); |
86 Type::Range(f->NewNumber(-0x7FFF), f->NewNumber(0x7FFF-1), zone), | 92 Type* uint16 = NATIVE_TYPE(unsigned16_, Type::UntaggedInt16()); |
87 Type::UntaggedInt16(), zone); | 93 Type* int32 = NATIVE_TYPE(Type::Signed32(), Type::UntaggedInt32()); |
88 Type* uint8 = Type::Intersect( | 94 Type* uint32 = NATIVE_TYPE(Type::Unsigned32(), Type::UntaggedInt32()); |
89 Type::Range(zero, f->NewNumber(0xFF-1), zone), | 95 Type* float32 = NATIVE_TYPE(Type::Number(), Type::UntaggedFloat32()); |
90 Type::UntaggedInt8(), zone); | 96 Type* float64 = NATIVE_TYPE(Type::Number(), Type::UntaggedFloat64()); |
91 Type* uint16 = Type::Intersect( | |
92 Type::Range(zero, f->NewNumber(0xFFFF-1), zone), | |
93 Type::UntaggedInt16(), zone); | |
94 | |
95 #define NATIVE_TYPE(sem, rep) \ | |
96 Type::Intersect(Type::sem(), Type::rep(), zone) | |
97 Type* int32 = NATIVE_TYPE(Signed32, UntaggedInt32); | |
98 Type* uint32 = NATIVE_TYPE(Unsigned32, UntaggedInt32); | |
99 Type* float32 = NATIVE_TYPE(Number, UntaggedFloat32); | |
100 Type* float64 = NATIVE_TYPE(Number, UntaggedFloat64); | |
101 #undef NATIVE_TYPE | 97 #undef NATIVE_TYPE |
102 | 98 |
103 Type* buffer = Type::Buffer(zone); | 99 Type* buffer = Type::Buffer(zone); |
104 Type* int8_array = Type::Array(int8, zone); | 100 Type* int8_array = Type::Array(int8, zone); |
105 Type* int16_array = Type::Array(int16, zone); | 101 Type* int16_array = Type::Array(int16, zone); |
106 Type* int32_array = Type::Array(int32, zone); | 102 Type* int32_array = Type::Array(int32, zone); |
107 Type* uint8_array = Type::Array(uint8, zone); | 103 Type* uint8_array = Type::Array(uint8, zone); |
108 Type* uint16_array = Type::Array(uint16, zone); | 104 Type* uint16_array = Type::Array(uint16, zone); |
109 Type* uint32_array = Type::Array(uint32, zone); | 105 Type* uint32_array = Type::Array(uint32, zone); |
110 Type* float32_array = Type::Array(float32, zone); | 106 Type* float32_array = Type::Array(float32, zone); |
(...skipping 1402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1513 ChangeRepresentation(arg.lower, Type::TaggedPtr(), zone()), | 1509 ChangeRepresentation(arg.lower, Type::TaggedPtr(), zone()), |
1514 ChangeRepresentation(arg.upper, Type::TaggedPtr(), zone())); | 1510 ChangeRepresentation(arg.upper, Type::TaggedPtr(), zone())); |
1515 } | 1511 } |
1516 | 1512 |
1517 | 1513 |
1518 Bounds Typer::Visitor::TypeLoadField(Node* node) { | 1514 Bounds Typer::Visitor::TypeLoadField(Node* node) { |
1519 return Bounds(FieldAccessOf(node->op()).type); | 1515 return Bounds(FieldAccessOf(node->op()).type); |
1520 } | 1516 } |
1521 | 1517 |
1522 | 1518 |
| 1519 Bounds Typer::Visitor::TypeLoadBuffer(Node* node) { |
| 1520 switch (BufferAccessOf(node->op()).external_array_type()) { |
| 1521 case kExternalInt8Array: |
| 1522 return Bounds(typer_->signed8_); |
| 1523 case kExternalUint8Array: |
| 1524 return Bounds(typer_->unsigned8_); |
| 1525 case kExternalInt16Array: |
| 1526 return Bounds(typer_->signed16_); |
| 1527 case kExternalUint16Array: |
| 1528 return Bounds(typer_->unsigned16_); |
| 1529 case kExternalInt32Array: |
| 1530 return Bounds(Type::Signed32()); |
| 1531 case kExternalUint32Array: |
| 1532 return Bounds(Type::Unsigned32()); |
| 1533 case kExternalFloat32Array: |
| 1534 case kExternalFloat64Array: |
| 1535 return Bounds(Type::Number()); |
| 1536 case kExternalUint8ClampedArray: |
| 1537 break; |
| 1538 } |
| 1539 UNREACHABLE(); |
| 1540 return Bounds(); |
| 1541 } |
| 1542 |
| 1543 |
1523 Bounds Typer::Visitor::TypeLoadElement(Node* node) { | 1544 Bounds Typer::Visitor::TypeLoadElement(Node* node) { |
1524 return Bounds(ElementAccessOf(node->op()).type); | 1545 return Bounds(ElementAccessOf(node->op()).type); |
1525 } | 1546 } |
1526 | 1547 |
1527 | 1548 |
1528 Bounds Typer::Visitor::TypeStoreField(Node* node) { | 1549 Bounds Typer::Visitor::TypeStoreField(Node* node) { |
1529 UNREACHABLE(); | 1550 UNREACHABLE(); |
1530 return Bounds(); | 1551 return Bounds(); |
1531 } | 1552 } |
1532 | 1553 |
1533 | 1554 |
| 1555 Bounds Typer::Visitor::TypeStoreBuffer(Node* node) { |
| 1556 UNREACHABLE(); |
| 1557 return Bounds(); |
| 1558 } |
| 1559 |
| 1560 |
1534 Bounds Typer::Visitor::TypeStoreElement(Node* node) { | 1561 Bounds Typer::Visitor::TypeStoreElement(Node* node) { |
1535 UNREACHABLE(); | 1562 UNREACHABLE(); |
1536 return Bounds(); | 1563 return Bounds(); |
1537 } | 1564 } |
1538 | 1565 |
1539 | 1566 |
1540 Bounds Typer::Visitor::TypeObjectIsSmi(Node* node) { | 1567 Bounds Typer::Visitor::TypeObjectIsSmi(Node* node) { |
1541 return Bounds(Type::Boolean()); | 1568 return Bounds(Type::Boolean()); |
1542 } | 1569 } |
1543 | 1570 |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1890 // TODO(sigurds): We could have a tighter bound here. | 1917 // TODO(sigurds): We could have a tighter bound here. |
1891 return Bounds(Type::Number()); | 1918 return Bounds(Type::Number()); |
1892 } | 1919 } |
1893 | 1920 |
1894 | 1921 |
1895 Bounds Typer::Visitor::TypeLoadStackPointer(Node* node) { | 1922 Bounds Typer::Visitor::TypeLoadStackPointer(Node* node) { |
1896 return Bounds(Type::Internal()); | 1923 return Bounds(Type::Internal()); |
1897 } | 1924 } |
1898 | 1925 |
1899 | 1926 |
| 1927 Bounds Typer::Visitor::TypeCheckedLoad(Node* node) { |
| 1928 return Bounds::Unbounded(zone()); |
| 1929 } |
| 1930 |
| 1931 |
| 1932 Bounds Typer::Visitor::TypeCheckedStore(Node* node) { |
| 1933 UNREACHABLE(); |
| 1934 return Bounds(); |
| 1935 } |
| 1936 |
| 1937 |
1900 // Heap constants. | 1938 // Heap constants. |
1901 | 1939 |
1902 | 1940 |
1903 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { | 1941 Type* Typer::Visitor::TypeConstant(Handle<Object> value) { |
1904 if (value->IsJSFunction()) { | 1942 if (value->IsJSFunction()) { |
1905 if (JSFunction::cast(*value)->shared()->HasBuiltinFunctionId()) { | 1943 if (JSFunction::cast(*value)->shared()->HasBuiltinFunctionId()) { |
1906 switch (JSFunction::cast(*value)->shared()->builtin_function_id()) { | 1944 switch (JSFunction::cast(*value)->shared()->builtin_function_id()) { |
1907 case kMathRandom: | 1945 case kMathRandom: |
1908 return typer_->random_fun_; | 1946 return typer_->random_fun_; |
1909 case kMathFloor: | 1947 case kMathFloor: |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1970 } else if (*value == native->float32_array_fun()) { | 2008 } else if (*value == native->float32_array_fun()) { |
1971 return typer_->float32_array_fun_; | 2009 return typer_->float32_array_fun_; |
1972 } else if (*value == native->float64_array_fun()) { | 2010 } else if (*value == native->float64_array_fun()) { |
1973 return typer_->float64_array_fun_; | 2011 return typer_->float64_array_fun_; |
1974 } | 2012 } |
1975 } | 2013 } |
1976 } | 2014 } |
1977 return Type::Constant(value, zone()); | 2015 return Type::Constant(value, zone()); |
1978 } | 2016 } |
1979 | 2017 |
1980 } | 2018 } // namespace compiler |
1981 } | 2019 } // namespace internal |
1982 } // namespace v8::internal::compiler | 2020 } // namespace v8 |
OLD | NEW |