V8 Project
v8::internal::UInt128 Class Reference
+ Collaboration diagram for v8::internal::UInt128:

Public Member Functions

 UInt128 ()
 
 UInt128 (uint64_t high, uint64_t low)
 
void Multiply (uint32_t multiplicand)
 
void Shift (int shift_amount)
 
int DivModPowerOf2 (int power)
 
bool IsZero () const
 
int BitAt (int position)
 

Private Attributes

uint64_t high_bits_
 
uint64_t low_bits_
 

Static Private Attributes

static const uint64_t kMask32 = 0xFFFFFFFF
 

Detailed Description

Definition at line 19 of file fixed-dtoa.cc.

Constructor & Destructor Documentation

◆ UInt128() [1/2]

v8::internal::UInt128::UInt128 ( )
inline

Definition at line 21 of file fixed-dtoa.cc.

21 : high_bits_(0), low_bits_(0) { }

◆ UInt128() [2/2]

v8::internal::UInt128::UInt128 ( uint64_t  high,
uint64_t  low 
)
inline

Definition at line 22 of file fixed-dtoa.cc.

22 : high_bits_(high), low_bits_(low) { }

Member Function Documentation

◆ BitAt()

int v8::internal::UInt128::BitAt ( int  position)
inline

Definition at line 83 of file fixed-dtoa.cc.

83  {
84  if (position >= 64) {
85  return static_cast<int>(high_bits_ >> (position - 64)) & 1;
86  } else {
87  return static_cast<int>(low_bits_ >> position) & 1;
88  }
89  }

References high_bits_, and low_bits_.

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

+ Here is the caller graph for this function:

◆ DivModPowerOf2()

int v8::internal::UInt128::DivModPowerOf2 ( int  power)
inline

Definition at line 64 of file fixed-dtoa.cc.

64  {
65  if (power >= 64) {
66  int result = static_cast<int>(high_bits_ >> (power - 64));
67  high_bits_ -= static_cast<uint64_t>(result) << (power - 64);
68  return result;
69  } else {
70  uint64_t part_low = low_bits_ >> power;
71  uint64_t part_high = high_bits_ << (64 - power);
72  int result = static_cast<int>(part_low + part_high);
73  high_bits_ = 0;
74  low_bits_ -= part_low << power;
75  return result;
76  }
77  }

References high_bits_, and low_bits_.

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

+ Here is the caller graph for this function:

◆ IsZero()

bool v8::internal::UInt128::IsZero ( ) const
inline

Definition at line 79 of file fixed-dtoa.cc.

79  {
80  return high_bits_ == 0 && low_bits_ == 0;
81  }

References high_bits_, and low_bits_.

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

+ Here is the caller graph for this function:

◆ Multiply()

void v8::internal::UInt128::Multiply ( uint32_t  multiplicand)
inline

Definition at line 24 of file fixed-dtoa.cc.

24  {
25  uint64_t accumulator;
26 
27  accumulator = (low_bits_ & kMask32) * multiplicand;
28  uint32_t part = static_cast<uint32_t>(accumulator & kMask32);
29  accumulator >>= 32;
30  accumulator = accumulator + (low_bits_ >> 32) * multiplicand;
31  low_bits_ = (accumulator << 32) + part;
32  accumulator >>= 32;
33  accumulator = accumulator + (high_bits_ & kMask32) * multiplicand;
34  part = static_cast<uint32_t>(accumulator & kMask32);
35  accumulator >>= 32;
36  accumulator = accumulator + (high_bits_ >> 32) * multiplicand;
37  high_bits_ = (accumulator << 32) + part;
38  DCHECK((accumulator >> 32) == 0);
39  }
static const uint64_t kMask32
Definition: fixed-dtoa.cc:92
#define DCHECK(condition)
Definition: logging.h:205

References DCHECK, high_bits_, kMask32, and low_bits_.

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

+ Here is the caller graph for this function:

◆ Shift()

void v8::internal::UInt128::Shift ( int  shift_amount)
inline

Definition at line 41 of file fixed-dtoa.cc.

41  {
42  DCHECK(-64 <= shift_amount && shift_amount <= 64);
43  if (shift_amount == 0) {
44  return;
45  } else if (shift_amount == -64) {
47  low_bits_ = 0;
48  } else if (shift_amount == 64) {
50  high_bits_ = 0;
51  } else if (shift_amount <= 0) {
52  high_bits_ <<= -shift_amount;
53  high_bits_ += low_bits_ >> (64 + shift_amount);
54  low_bits_ <<= -shift_amount;
55  } else {
56  low_bits_ >>= shift_amount;
57  low_bits_ += high_bits_ << (64 - shift_amount);
58  high_bits_ >>= shift_amount;
59  }
60  }

References DCHECK, high_bits_, and low_bits_.

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

+ Here is the caller graph for this function:

Member Data Documentation

◆ high_bits_

uint64_t v8::internal::UInt128::high_bits_
private

Definition at line 94 of file fixed-dtoa.cc.

Referenced by BitAt(), DivModPowerOf2(), IsZero(), Multiply(), and Shift().

◆ kMask32

const uint64_t v8::internal::UInt128::kMask32 = 0xFFFFFFFF
staticprivate

Definition at line 92 of file fixed-dtoa.cc.

Referenced by Multiply().

◆ low_bits_

uint64_t v8::internal::UInt128::low_bits_
private

Definition at line 95 of file fixed-dtoa.cc.

Referenced by BitAt(), DivModPowerOf2(), IsZero(), Multiply(), and Shift().


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