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/types.h" | 5 #include "src/types.h" |
6 | 6 |
7 #include "src/ostreams.h" | 7 #include "src/ostreams.h" |
8 #include "src/types-inl.h" | 8 #include "src/types-inl.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 return Lub(i::HeapObject::cast(value)->map()); | 267 return Lub(i::HeapObject::cast(value)->map()); |
268 } | 268 } |
269 | 269 |
270 | 270 |
271 template<class Config> | 271 template<class Config> |
272 typename TypeImpl<Config>::bitset | 272 typename TypeImpl<Config>::bitset |
273 TypeImpl<Config>::BitsetType::Lub(double value) { | 273 TypeImpl<Config>::BitsetType::Lub(double value) { |
274 DisallowHeapAllocation no_allocation; | 274 DisallowHeapAllocation no_allocation; |
275 if (i::IsMinusZero(value)) return kMinusZero; | 275 if (i::IsMinusZero(value)) return kMinusZero; |
276 if (std::isnan(value)) return kNaN; | 276 if (std::isnan(value)) return kNaN; |
277 if (IsUint32Double(value)) return Lub(FastD2UI(value)); | 277 if (IsUint32Double(value) || IsInt32Double(value)) return Lub(value, value); |
278 if (IsInt32Double(value)) return Lub(FastD2I(value)); | |
279 return kOtherNumber; | 278 return kOtherNumber; |
280 } | 279 } |
281 | 280 |
282 | 281 |
283 template<class Config> | |
284 typename TypeImpl<Config>::bitset | |
285 TypeImpl<Config>::BitsetType::Lub(int32_t value) { | |
286 DisallowHeapAllocation no_allocation; | |
287 if (value >= 0x40000000) { | |
288 return i::SmiValuesAre31Bits() ? kOtherUnsigned31 : kUnsignedSmall; | |
289 } | |
290 if (value >= 0) return kUnsignedSmall; | |
291 if (value >= -0x40000000) return kOtherSignedSmall; | |
292 return i::SmiValuesAre31Bits() ? kOtherSigned32 : kOtherSignedSmall; | |
293 } | |
294 | |
295 | |
296 template<class Config> | |
297 typename TypeImpl<Config>::bitset | |
298 TypeImpl<Config>::BitsetType::Lub(uint32_t value) { | |
299 DisallowHeapAllocation no_allocation; | |
300 if (value >= 0x80000000u) return kOtherUnsigned32; | |
301 if (value >= 0x40000000u) { | |
302 return i::SmiValuesAre31Bits() ? kOtherUnsigned31 : kUnsignedSmall; | |
303 } | |
304 return kUnsignedSmall; | |
305 } | |
306 | |
307 | |
308 // Minimum values of regular numeric bitsets when SmiValuesAre31Bits. | 282 // Minimum values of regular numeric bitsets when SmiValuesAre31Bits. |
309 template<class Config> | 283 template<class Config> |
310 const typename TypeImpl<Config>::BitsetType::BitsetMin | 284 const typename TypeImpl<Config>::BitsetType::BitsetMin |
311 TypeImpl<Config>::BitsetType::BitsetMins31[] = { | 285 TypeImpl<Config>::BitsetType::BitsetMins31[] = { |
312 {kOtherNumber, -V8_INFINITY}, | 286 {kOtherNumber, -V8_INFINITY}, |
313 {kOtherSigned32, kMinInt}, | 287 {kOtherSigned32, kMinInt}, |
314 {kOtherSignedSmall, -0x40000000}, | 288 {kOtherSignedSmall, -0x40000000}, |
315 {kUnsignedSmall, 0}, | 289 {kUnsignedSmall, 0}, |
316 {kOtherUnsigned31, 0x40000000}, | 290 {kOtherUnsigned31, 0x40000000}, |
317 {kOtherUnsigned32, 0x80000000}, | 291 {kOtherUnsigned32, 0x80000000}, |
318 {kOtherNumber, static_cast<double>(kMaxUInt32) + 1} | 292 {kOtherNumber, static_cast<double>(kMaxUInt32) + 1} |
319 }; | 293 }; |
320 | 294 |
321 | 295 |
322 // Minimum values of regular numeric bitsets when SmiValuesAre32Bits. | 296 // Minimum values of regular numeric bitsets when SmiValuesAre32Bits. |
323 // OtherSigned32 and OtherUnsigned31 are empty (see the diagrams in types.h). | 297 // OtherSigned32 and OtherUnsigned31 are empty (see the diagrams in types.h). |
324 template<class Config> | 298 template<class Config> |
325 const typename TypeImpl<Config>::BitsetType::BitsetMin | 299 const typename TypeImpl<Config>::BitsetType::BitsetMin |
326 TypeImpl<Config>::BitsetType::BitsetMins32[] = { | 300 TypeImpl<Config>::BitsetType::BitsetMins32[] = { |
327 {kOtherNumber, -V8_INFINITY}, | 301 {kOtherNumber, -V8_INFINITY}, |
328 {kOtherSignedSmall, kMinInt}, | 302 {kOtherSignedSmall, kMinInt}, |
329 {kUnsignedSmall, 0}, | 303 {kUnsignedSmall, 0}, |
330 {kOtherUnsigned32, 0x80000000}, | 304 {kOtherUnsigned32, 0x80000000}, |
331 {kOtherNumber, static_cast<double>(kMaxUInt32) + 1} | 305 {kOtherNumber, static_cast<double>(kMaxUInt32) + 1} |
332 }; | 306 }; |
333 | 307 |
334 | 308 |
335 template<class Config> | 309 template<class Config> |
336 typename TypeImpl<Config>::bitset | 310 typename TypeImpl<Config>::bitset |
337 TypeImpl<Config>::BitsetType::Lub(Limits lim) { | 311 TypeImpl<Config>::BitsetType::Lub(double min, double max) { |
338 DisallowHeapAllocation no_allocation; | 312 DisallowHeapAllocation no_allocation; |
339 double min = lim.min->Number(); | |
340 double max = lim.max->Number(); | |
341 int lub = kNone; | 313 int lub = kNone; |
342 const BitsetMin* mins = BitsetMins(); | 314 const BitsetMin* mins = BitsetMins(); |
343 | 315 |
344 for (size_t i = 1; i < BitsetMinsSize(); ++i) { | 316 for (size_t i = 1; i < BitsetMinsSize(); ++i) { |
345 if (min < mins[i].min) { | 317 if (min < mins[i].min) { |
346 lub |= mins[i-1].bits; | 318 lub |= mins[i-1].bits; |
347 if (max < mins[i].min) return lub; | 319 if (max < mins[i].min) return lub; |
348 } | 320 } |
349 } | 321 } |
350 return lub |= mins[BitsetMinsSize()-1].bits; | 322 return lub |= mins[BitsetMinsSize()-1].bits; |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>; | 1084 template class TypeImpl<HeapTypeConfig>::Iterator<i::Object>; |
1113 | 1085 |
1114 template TypeImpl<ZoneTypeConfig>::TypeHandle | 1086 template TypeImpl<ZoneTypeConfig>::TypeHandle |
1115 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( | 1087 TypeImpl<ZoneTypeConfig>::Convert<HeapType>( |
1116 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); | 1088 TypeImpl<HeapTypeConfig>::TypeHandle, TypeImpl<ZoneTypeConfig>::Region*); |
1117 template TypeImpl<HeapTypeConfig>::TypeHandle | 1089 template TypeImpl<HeapTypeConfig>::TypeHandle |
1118 TypeImpl<HeapTypeConfig>::Convert<Type>( | 1090 TypeImpl<HeapTypeConfig>::Convert<Type>( |
1119 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); | 1091 TypeImpl<ZoneTypeConfig>::TypeHandle, TypeImpl<HeapTypeConfig>::Region*); |
1120 | 1092 |
1121 } } // namespace v8::internal | 1093 } } // namespace v8::internal |
OLD | NEW |