| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 } | 108 } |
| 109 | 109 |
| 110 // Return the weakest (least precise) common type. | 110 // Return the weakest (least precise) common type. |
| 111 static NumberInfo Combine(NumberInfo a, NumberInfo b) { | 111 static NumberInfo Combine(NumberInfo a, NumberInfo b) { |
| 112 return NumberInfo(static_cast<Type>(a.type_ & b.type_)); | 112 return NumberInfo(static_cast<Type>(a.type_ & b.type_)); |
| 113 } | 113 } |
| 114 | 114 |
| 115 | 115 |
| 116 // Integer32 is an integer that can be represented as either a signed | 116 // Integer32 is an integer that can be represented as either a signed |
| 117 // 32-bit integer or as an unsigned 32-bit integer. It has to be | 117 // 32-bit integer or as an unsigned 32-bit integer. It has to be |
| 118 // in the range [-2^31, 2^32 - 1]. | 118 // in the range [-2^31, 2^32 - 1]. We also have to check for negative 0 |
| 119 // as it is not an Integer32. |
| 119 static inline bool IsInt32Double(double value) { | 120 static inline bool IsInt32Double(double value) { |
| 121 const DoubleRepresentation minus_zero(-0.0); |
| 122 DoubleRepresentation rep(value); |
| 123 if (rep.bits == minus_zero.bits) return false; |
| 120 if (value >= kMinInt && value <= kMaxUInt32) { | 124 if (value >= kMinInt && value <= kMaxUInt32) { |
| 121 if (value <= kMaxInt && value == static_cast<int32_t>(value)) { | 125 if (value <= kMaxInt && value == static_cast<int32_t>(value)) { |
| 122 return true; | 126 return true; |
| 123 } | 127 } |
| 124 if (value == static_cast<uint32_t>(value)) return true; | 128 if (value == static_cast<uint32_t>(value)) return true; |
| 125 } | 129 } |
| 126 return false; | 130 return false; |
| 127 } | 131 } |
| 128 | 132 |
| 129 static inline NumberInfo TypeFromValue(Handle<Object> value); | 133 static inline NumberInfo TypeFromValue(Handle<Object> value); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 } | 230 } |
| 227 | 231 |
| 228 | 232 |
| 229 NumberInfo NumberInfo::Uninitialized() { | 233 NumberInfo NumberInfo::Uninitialized() { |
| 230 return NumberInfo(kUninitializedType); | 234 return NumberInfo(kUninitializedType); |
| 231 } | 235 } |
| 232 | 236 |
| 233 } } // namespace v8::internal | 237 } } // namespace v8::internal |
| 234 | 238 |
| 235 #endif // V8_NUMBER_INFO_H_ | 239 #endif // V8_NUMBER_INFO_H_ |
| OLD | NEW |