OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 t == kNonPrimitive); | 113 t == kNonPrimitive); |
114 return TypeInfo(t); | 114 return TypeInfo(t); |
115 } | 115 } |
116 | 116 |
117 // Return the weakest (least precise) common type. | 117 // Return the weakest (least precise) common type. |
118 static TypeInfo Combine(TypeInfo a, TypeInfo b) { | 118 static TypeInfo Combine(TypeInfo a, TypeInfo b) { |
119 return TypeInfo(static_cast<Type>(a.type_ & b.type_)); | 119 return TypeInfo(static_cast<Type>(a.type_ & b.type_)); |
120 } | 120 } |
121 | 121 |
122 | 122 |
123 // Integer32 is an integer that can be represented as either a signed | 123 // Integer32 is an integer that can be represented as a signed |
124 // 32-bit integer or as an unsigned 32-bit integer. It has to be | 124 // 32-bit integer. It has to be |
125 // in the range [-2^31, 2^32 - 1]. We also have to check for negative 0 | 125 // in the range [-2^31, 2^31 - 1]. We also have to check for negative 0 |
126 // as it is not an Integer32. | 126 // as it is not an Integer32. |
127 static inline bool IsInt32Double(double value) { | 127 static inline bool IsInt32Double(double value) { |
128 const DoubleRepresentation minus_zero(-0.0); | 128 const DoubleRepresentation minus_zero(-0.0); |
129 DoubleRepresentation rep(value); | 129 DoubleRepresentation rep(value); |
130 if (rep.bits == minus_zero.bits) return false; | 130 if (rep.bits == minus_zero.bits) return false; |
131 if (value >= kMinInt && value <= kMaxInt && | 131 if (value >= kMinInt && value <= kMaxInt && |
132 value == static_cast<int32_t>(value)) { | 132 value == static_cast<int32_t>(value)) { |
133 return true; | 133 return true; |
134 } | 134 } |
135 return false; | 135 return false; |
136 } | 136 } |
137 | 137 |
| 138 static inline bool IsSmiDouble(double value) { |
| 139 const DoubleRepresentation minus_zero(-0.0); |
| 140 DoubleRepresentation rep(value); |
| 141 if (rep.bits == minus_zero.bits) return false; |
| 142 if (value >= Smi::kMinValue && value <= Smi::kMaxValue && |
| 143 value == static_cast<int32_t>(value)) { |
| 144 return true; |
| 145 } |
| 146 return false; |
| 147 } |
| 148 |
| 149 |
| 150 |
138 static TypeInfo TypeFromValue(Handle<Object> value); | 151 static TypeInfo TypeFromValue(Handle<Object> value); |
139 | 152 |
140 bool Equals(const TypeInfo& other) { | 153 bool Equals(const TypeInfo& other) { |
141 return type_ == other.type_; | 154 return type_ == other.type_; |
142 } | 155 } |
143 | 156 |
144 inline bool IsUnknown() { | 157 inline bool IsUnknown() { |
145 ASSERT(type_ != kUninitialized); | 158 ASSERT(type_ != kUninitialized); |
146 return type_ == kUnknown; | 159 return type_ == kUnknown; |
147 } | 160 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 | 287 |
275 Handle<Context> global_context_; | 288 Handle<Context> global_context_; |
276 Handle<JSObject> map_; | 289 Handle<JSObject> map_; |
277 | 290 |
278 DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle); | 291 DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle); |
279 }; | 292 }; |
280 | 293 |
281 } } // namespace v8::internal | 294 } } // namespace v8::internal |
282 | 295 |
283 #endif // V8_TYPE_INFO_H_ | 296 #endif // V8_TYPE_INFO_H_ |
OLD | NEW |