| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 15 matching lines...) Expand all Loading... |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "config.h" | 28 #include "config.h" |
| 29 | 29 |
| 30 #include <stdarg.h> | 30 #include <stdarg.h> |
| 31 #include <limits.h> | 31 #include <limits.h> |
| 32 #include <math.h> | 32 #include <math.h> |
| 33 | 33 |
| 34 #include "cached-powers.h" | 34 #include "cached-powers.h" |
| 35 #include "utils.h" | 35 #include "utils.h" |
| 36 #include "wtf/UnusedParam.h" | |
| 37 | 36 |
| 38 namespace WTF { | 37 namespace WTF { |
| 39 | 38 |
| 40 namespace double_conversion { | 39 namespace double_conversion { |
| 41 | 40 |
| 42 struct CachedPower { | 41 struct CachedPower { |
| 43 uint64_t significand; | 42 uint64_t significand; |
| 44 int16_t binary_exponent; | 43 int16_t binary_exponent; |
| 45 int16_t decimal_exponent; | 44 int16_t decimal_exponent; |
| 46 }; | 45 }; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 ASSERT(PowersOfTenCache::kMinDecimalExponent == kCachedPowers[0].decimal
_exponent); | 152 ASSERT(PowersOfTenCache::kMinDecimalExponent == kCachedPowers[0].decimal
_exponent); |
| 154 ASSERT(PowersOfTenCache::kMaxDecimalExponent == kCachedPowers[kCachedPow
ersLength - 1].decimal_exponent); | 153 ASSERT(PowersOfTenCache::kMaxDecimalExponent == kCachedPowers[kCachedPow
ersLength - 1].decimal_exponent); |
| 155 } | 154 } |
| 156 #endif | 155 #endif |
| 157 | 156 |
| 158 void PowersOfTenCache::GetCachedPowerForBinaryExponentRange( | 157 void PowersOfTenCache::GetCachedPowerForBinaryExponentRange( |
| 159 int min_exponent
, | 158 int min_exponent
, |
| 160 int max_exponent
, | 159 int max_exponent
, |
| 161 DiyFp* power, | 160 DiyFp* power, |
| 162 int* decimal_exp
onent) { | 161 int* decimal_exp
onent) { |
| 163 UNUSED_PARAM(max_exponent); | |
| 164 #ifndef NDEBUG | 162 #ifndef NDEBUG |
| 165 validateStaticConstants(); | 163 validateStaticConstants(); |
| 166 #endif | 164 #endif |
| 167 int kQ = DiyFp::kSignificandSize; | 165 int kQ = DiyFp::kSignificandSize; |
| 168 double k = ceil((min_exponent + kQ - 1) * kD_1_LOG2_10); | 166 double k = ceil((min_exponent + kQ - 1) * kD_1_LOG2_10); |
| 169 int foo = kCachedPowersOffset; | 167 int foo = kCachedPowersOffset; |
| 170 int index = | 168 int index = |
| 171 (foo + static_cast<int>(k) - 1) / kDecimalExponentDistance + 1; | 169 (foo + static_cast<int>(k) - 1) / kDecimalExponentDistance + 1; |
| 172 ASSERT(0 <= index && index < kCachedPowersLength); | 170 ASSERT(0 <= index && index < kCachedPowersLength); |
| 173 CachedPower cached_power = kCachedPowers[index]; | 171 CachedPower cached_power = kCachedPowers[index]; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 191 CachedPower cached_power = kCachedPowers[index]; | 189 CachedPower cached_power = kCachedPowers[index]; |
| 192 *power = DiyFp(cached_power.significand, cached_power.binary_exponent); | 190 *power = DiyFp(cached_power.significand, cached_power.binary_exponent); |
| 193 *found_exponent = cached_power.decimal_exponent; | 191 *found_exponent = cached_power.decimal_exponent; |
| 194 ASSERT(*found_exponent <= requested_exponent); | 192 ASSERT(*found_exponent <= requested_exponent); |
| 195 ASSERT(requested_exponent < *found_exponent + kDecimalExponentDistance); | 193 ASSERT(requested_exponent < *found_exponent + kDecimalExponentDistance); |
| 196 } | 194 } |
| 197 | 195 |
| 198 } // namespace double_conversion | 196 } // namespace double_conversion |
| 199 | 197 |
| 200 } // namespace WTF | 198 } // namespace WTF |
| OLD | NEW |