V8 Project
v8::internal::PowersOfTenCache Class Reference

#include <cached-powers.h>

+ Collaboration diagram for v8::internal::PowersOfTenCache:

Static Public Member Functions

static void GetCachedPowerForBinaryExponentRange (int min_exponent, int max_exponent, DiyFp *power, int *decimal_exponent)
 
static void GetCachedPowerForDecimalExponent (int requested_exponent, DiyFp *power, int *found_exponent)
 

Static Public Attributes

static const int kDecimalExponentDistance = 8
 
static const int kMinDecimalExponent = -348
 
static const int kMaxDecimalExponent = 340
 

Detailed Description

Definition at line 14 of file cached-powers.h.

Member Function Documentation

◆ GetCachedPowerForBinaryExponentRange()

void v8::internal::PowersOfTenCache::GetCachedPowerForBinaryExponentRange ( int  min_exponent,
int  max_exponent,
DiyFp power,
int decimal_exponent 
)
static

Definition at line 124 of file cached-powers.cc.

128  {
129  int kQ = DiyFp::kSignificandSize;
130  // Some platforms return incorrect sign on 0 result. We can ignore that here,
131  // which means we can avoid depending on platform.h.
132  double k = std::ceil((min_exponent + kQ - 1) * kD_1_LOG2_10);
133  int foo = kCachedPowersOffset;
134  int index =
135  (foo + static_cast<int>(k) - 1) / kDecimalExponentDistance + 1;
136  DCHECK(0 <= index && index < kCachedPowersLength);
137  CachedPower cached_power = kCachedPowers[index];
138  DCHECK(min_exponent <= cached_power.binary_exponent);
139  DCHECK(cached_power.binary_exponent <= max_exponent);
140  *decimal_exponent = cached_power.decimal_exponent;
141  *power = DiyFp(cached_power.significand, cached_power.binary_exponent);
142 }
static const int kSignificandSize
Definition: diy-fp.h:18
static const int kDecimalExponentDistance
Definition: cached-powers.h:18
#define DCHECK(condition)
Definition: logging.h:205
static const int kCachedPowersOffset
static const CachedPower kCachedPowers[]
static const double kD_1_LOG2_10

References v8::internal::CachedPower::binary_exponent, DCHECK, v8::internal::CachedPower::decimal_exponent, v8::internal::kCachedPowers, v8::internal::kCachedPowersOffset, v8::internal::kD_1_LOG2_10, kDecimalExponentDistance, v8::internal::DiyFp::kSignificandSize, and v8::internal::CachedPower::significand.

Referenced by v8::internal::Grisu3(), and v8::internal::Grisu3Counted().

+ Here is the caller graph for this function:

◆ GetCachedPowerForDecimalExponent()

void v8::internal::PowersOfTenCache::GetCachedPowerForDecimalExponent ( int  requested_exponent,
DiyFp power,
int found_exponent 
)
static

Definition at line 145 of file cached-powers.cc.

147  {
148  DCHECK(kMinDecimalExponent <= requested_exponent);
149  DCHECK(requested_exponent < kMaxDecimalExponent + kDecimalExponentDistance);
150  int index =
151  (requested_exponent + kCachedPowersOffset) / kDecimalExponentDistance;
152  CachedPower cached_power = kCachedPowers[index];
153  *power = DiyFp(cached_power.significand, cached_power.binary_exponent);
154  *found_exponent = cached_power.decimal_exponent;
155  DCHECK(*found_exponent <= requested_exponent);
156  DCHECK(requested_exponent < *found_exponent + kDecimalExponentDistance);
157 }
static const int kMinDecimalExponent
Definition: cached-powers.h:20
static const int kMaxDecimalExponent
Definition: cached-powers.h:21

References v8::internal::CachedPower::binary_exponent, DCHECK, v8::internal::CachedPower::decimal_exponent, v8::internal::kCachedPowers, v8::internal::kCachedPowersOffset, kDecimalExponentDistance, kMaxDecimalExponent, kMinDecimalExponent, and v8::internal::CachedPower::significand.

Referenced by v8::internal::DiyFpStrtod().

+ Here is the caller graph for this function:

Member Data Documentation

◆ kDecimalExponentDistance

const int v8::internal::PowersOfTenCache::kDecimalExponentDistance = 8
static

◆ kMaxDecimalExponent

const int v8::internal::PowersOfTenCache::kMaxDecimalExponent = 340
static

Definition at line 21 of file cached-powers.h.

Referenced by v8::internal::DiyFpStrtod(), and GetCachedPowerForDecimalExponent().

◆ kMinDecimalExponent

const int v8::internal::PowersOfTenCache::kMinDecimalExponent = -348
static

Definition at line 20 of file cached-powers.h.

Referenced by v8::internal::DiyFpStrtod(), and GetCachedPowerForDecimalExponent().


The documentation for this class was generated from the following files: