Commit db0811fe authored by ahaas's avatar ahaas Committed by Commit bot

Remove DoubleRepresentation from globals.h

The implementation of DoubleRepresentation was based on undefined
behavior, and it can be replaced by bit_casts.

BUG=chromium:623168
R=titzer@chromium.org

Review-Url: https://codereview.chromium.org/2105683006
Cr-Commit-Position: refs/heads/master@{#37390}
parent 89c9fc73
...@@ -1004,13 +1004,11 @@ void MacroAssembler::VFPCompareAndLoadFlags(const DwVfpRegister src1, ...@@ -1004,13 +1004,11 @@ void MacroAssembler::VFPCompareAndLoadFlags(const DwVfpRegister src1,
void MacroAssembler::Vmov(const DwVfpRegister dst, void MacroAssembler::Vmov(const DwVfpRegister dst,
const double imm, const double imm,
const Register scratch) { const Register scratch) {
static const DoubleRepresentation minus_zero(-0.0); int64_t imm_bits = bit_cast<int64_t>(imm);
static const DoubleRepresentation zero(0.0);
DoubleRepresentation value_rep(imm);
// Handle special values first. // Handle special values first.
if (value_rep == zero) { if (imm_bits == bit_cast<int64_t>(0.0)) {
vmov(dst, kDoubleRegZero); vmov(dst, kDoubleRegZero);
} else if (value_rep == minus_zero) { } else if (imm_bits == bit_cast<int64_t>(-0.0)) {
vneg(dst, kDoubleRegZero); vneg(dst, kDoubleRegZero);
} else { } else {
vmov(dst, imm, scratch); vmov(dst, imm, scratch);
......
...@@ -149,8 +149,7 @@ char* DoubleToRadixCString(double value, int radix); ...@@ -149,8 +149,7 @@ char* DoubleToRadixCString(double value, int radix);
static inline bool IsMinusZero(double value) { static inline bool IsMinusZero(double value) {
static const DoubleRepresentation minus_zero(-0.0); return bit_cast<int64_t>(value) == bit_cast<int64_t>(-0.0);
return DoubleRepresentation(value) == minus_zero;
} }
......
...@@ -2161,9 +2161,8 @@ static inline int NumberCacheHash(Handle<FixedArray> cache, ...@@ -2161,9 +2161,8 @@ static inline int NumberCacheHash(Handle<FixedArray> cache,
if (number->IsSmi()) { if (number->IsSmi()) {
return Handle<Smi>::cast(number)->value() & mask; return Handle<Smi>::cast(number)->value() & mask;
} else { } else {
DoubleRepresentation rep(number->Number()); int64_t bits = bit_cast<int64_t>(number->Number());
return return (static_cast<int>(bits) ^ static_cast<int>(bits >> 32)) & mask;
(static_cast<int>(rep.bits) ^ static_cast<int>(rep.bits >> 32)) & mask;
} }
} }
......
...@@ -633,18 +633,6 @@ typedef void (*StoreBufferCallback)(Heap* heap, ...@@ -633,18 +633,6 @@ typedef void (*StoreBufferCallback)(Heap* heap,
MemoryChunk* page, MemoryChunk* page,
StoreBufferEvent event); StoreBufferEvent event);
// Union used for fast testing of specific double values.
union DoubleRepresentation {
double value;
int64_t bits;
DoubleRepresentation(double x) { value = x; }
bool operator==(const DoubleRepresentation& other) const {
return bits == other.bits;
}
};
// Union used for customized checking of the IEEE double types // Union used for customized checking of the IEEE double types
// inlined within v8 runtime, rather than going to the underlying // inlined within v8 runtime, rather than going to the underlying
// platform headers and libraries // platform headers and libraries
......
...@@ -2304,13 +2304,11 @@ void MacroAssembler::Move(FPURegister dst, float imm) { ...@@ -2304,13 +2304,11 @@ void MacroAssembler::Move(FPURegister dst, float imm) {
void MacroAssembler::Move(FPURegister dst, double imm) { void MacroAssembler::Move(FPURegister dst, double imm) {
static const DoubleRepresentation minus_zero(-0.0); int64_t imm_bits = bit_cast<int64_t>(imm);
static const DoubleRepresentation zero(0.0);
DoubleRepresentation value_rep(imm);
// Handle special values first. // Handle special values first.
if (value_rep == zero && has_double_zero_reg_set_) { if (imm_bits == bit_cast<int64_t>(0.0) && has_double_zero_reg_set_) {
mov_d(dst, kDoubleRegZero); mov_d(dst, kDoubleRegZero);
} else if (value_rep == minus_zero && has_double_zero_reg_set_) { } else if (imm_bits == bit_cast<int64_t>(-0.0) && has_double_zero_reg_set_) {
neg_d(dst, kDoubleRegZero); neg_d(dst, kDoubleRegZero);
} else { } else {
uint32_t lo, hi; uint32_t lo, hi;
......
...@@ -2509,13 +2509,11 @@ void MacroAssembler::Move(FPURegister dst, float imm) { ...@@ -2509,13 +2509,11 @@ void MacroAssembler::Move(FPURegister dst, float imm) {
void MacroAssembler::Move(FPURegister dst, double imm) { void MacroAssembler::Move(FPURegister dst, double imm) {
static const DoubleRepresentation minus_zero(-0.0); int64_t imm_bits = bit_cast<int64_t>(imm);
static const DoubleRepresentation zero(0.0);
DoubleRepresentation value_rep(imm);
// Handle special values first. // Handle special values first.
if (value_rep == zero && has_double_zero_reg_set_) { if (imm_bits == bit_cast<int64_t>(0.0) && has_double_zero_reg_set_) {
mov_d(dst, kDoubleRegZero); mov_d(dst, kDoubleRegZero);
} else if (value_rep == minus_zero && has_double_zero_reg_set_) { } else if (imm_bits == bit_cast<int64_t>(-0.0) && has_double_zero_reg_set_) {
neg_d(dst, kDoubleRegZero); neg_d(dst, kDoubleRegZero);
} else { } else {
uint32_t lo, hi; uint32_t lo, hi;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment