Index: src/cached-powers.h |
diff --git a/src/cached-powers.h b/src/cached-powers.h |
index 314ccca3c4539eb55f0de48522445a31934aad1b..0c7834317032aeee37ea71f301f119aca3a788e7 100644 |
--- a/src/cached-powers.h |
+++ b/src/cached-powers.h |
@@ -33,86 +33,10 @@ |
namespace v8 { |
namespace internal { |
-struct CachedPower { |
- uint64_t significand; |
- int16_t binary_exponent; |
- int16_t decimal_exponent; |
-}; |
- |
-// The following defines implement the interface between this file and the |
-// generated 'powers_ten.h'. |
-// GRISU_CACHE_NAME(1) contains all possible cached powers. |
-// GRISU_CACHE_NAME(i) contains GRISU_CACHE_NAME(1) where only every 'i'th |
-// element is kept. More formally GRISU_CACHE_NAME(i) contains the elements j*i |
-// with 0 <= j < k with k such that j*k < the size of GRISU_CACHE_NAME(1). |
-// The higher 'i' is the fewer elements we use. |
-// Given that there are less elements, the exponent-distance between two |
-// elements in the cache grows. The variable GRISU_CACHE_MAX_DISTANCE(i) stores |
-// the maximum distance between two elements. |
-#define GRISU_CACHE_STRUCT CachedPower |
-#define GRISU_CACHE_NAME(i) kCachedPowers##i |
-#define GRISU_CACHE_MAX_DISTANCE(i) kCachedPowersMaxDistance##i |
-#define GRISU_CACHE_OFFSET kCachedPowerOffset |
-#define GRISU_UINT64_C V8_2PART_UINT64_C |
-// The following include imports the precompiled cached powers. |
-#include "powers-ten.h" // NOLINT |
- |
-static const double kD_1_LOG2_10 = 0.30102999566398114; // 1 / lg(10) |
- |
-// We can't use a function since we reference variables depending on the 'i'. |
-// This way the compiler is able to see at compile time that only one |
-// cache-array variable is used and thus can remove all the others. |
-#define COMPUTE_FOR_CACHE(i) \ |
- if (!found && (gamma - alpha + 1 >= GRISU_CACHE_MAX_DISTANCE(i))) { \ |
- int kQ = DiyFp::kSignificandSize; \ |
- double k = ceiling((alpha - e + kQ - 1) * kD_1_LOG2_10); \ |
- int index = (GRISU_CACHE_OFFSET + static_cast<int>(k) - 1) / i + 1; \ |
- cached_power = GRISU_CACHE_NAME(i)[index]; \ |
- found = true; \ |
- } \ |
- |
-static void GetCachedPower(int e, int alpha, int gamma, int* mk, DiyFp* c_mk) { |
- // The following if statement should be optimized by the compiler so that only |
- // one array is referenced and the others are not included in the object file. |
- bool found = false; |
- CachedPower cached_power; |
- COMPUTE_FOR_CACHE(20); |
- COMPUTE_FOR_CACHE(19); |
- COMPUTE_FOR_CACHE(18); |
- COMPUTE_FOR_CACHE(17); |
- COMPUTE_FOR_CACHE(16); |
- COMPUTE_FOR_CACHE(15); |
- COMPUTE_FOR_CACHE(14); |
- COMPUTE_FOR_CACHE(13); |
- COMPUTE_FOR_CACHE(12); |
- COMPUTE_FOR_CACHE(11); |
- COMPUTE_FOR_CACHE(10); |
- COMPUTE_FOR_CACHE(9); |
- COMPUTE_FOR_CACHE(8); |
- COMPUTE_FOR_CACHE(7); |
- COMPUTE_FOR_CACHE(6); |
- COMPUTE_FOR_CACHE(5); |
- COMPUTE_FOR_CACHE(4); |
- COMPUTE_FOR_CACHE(3); |
- COMPUTE_FOR_CACHE(2); |
- COMPUTE_FOR_CACHE(1); |
- if (!found) { |
- UNIMPLEMENTED(); |
- // Silence compiler warnings. |
- cached_power.significand = 0; |
- cached_power.binary_exponent = 0; |
- cached_power.decimal_exponent = 0; |
- } |
- *c_mk = DiyFp(cached_power.significand, cached_power.binary_exponent); |
- *mk = cached_power.decimal_exponent; |
- ASSERT((alpha <= c_mk->e() + e) && (c_mk->e() + e <= gamma)); |
-} |
-#undef GRISU_REDUCTION |
-#undef GRISU_CACHE_STRUCT |
-#undef GRISU_CACHE_NAME |
-#undef GRISU_CACHE_MAX_DISTANCE |
-#undef GRISU_CACHE_OFFSET |
-#undef GRISU_UINT64_C |
+void GetCachedPowerForBinaryExponentRange(int min_exponent, |
+ int max_exponent, |
+ DiyFp* power, |
+ int* decimal_exponent); |
} } // namespace v8::internal |