| Index: src/objects.h
|
| ===================================================================
|
| --- src/objects.h (revision 3405)
|
| +++ src/objects.h (working copy)
|
| @@ -1064,22 +1064,39 @@
|
| void HeapNumberVerify();
|
| #endif
|
|
|
| - // Layout description.
|
| - static const int kValueOffset = HeapObject::kHeaderSize;
|
| + // Layout description. The value offset has a strange name to remind users
|
| + // that the offset varies depending on the alignment of the HeapNumber.
|
| + static const int kValueMinimumOffset = HeapObject::kHeaderSize;
|
| // IEEE doubles are two 32 bit words. The first is just mantissa, the second
|
| // is a mixture of sign, exponent and mantissa. Our current platforms are all
|
| // little endian apart from non-EABI arm which is little endian with big
|
| // endian floating point word ordering!
|
| #if !defined(V8_HOST_ARCH_ARM) || defined(USE_ARM_EABI)
|
| - static const int kMantissaOffset = kValueOffset;
|
| - static const int kExponentOffset = kValueOffset + 4;
|
| + static const int kMantissaRelativeOffset = 0;
|
| + static const int kExponentRelativeOffset = 4;
|
| #else
|
| - static const int kMantissaOffset = kValueOffset + 4;
|
| - static const int kExponentOffset = kValueOffset;
|
| + static const int kMantissaRelativeOffset = 4;
|
| + static const int kExponentRelativeOffset = 0;
|
| # define BIG_ENDIAN_FLOATING_POINT 1
|
| #endif
|
| - static const int kSize = kValueOffset + kDoubleSize;
|
| + // The double precision floating point number takes 8 bytes, but if the object
|
| + // alignment is only 4 then the size is increased by 4 so the double precision
|
| + // value can always be stored at an aligned address.
|
| + static const int kSize =
|
| + kValueMinimumOffset + ((kObjectAlignment == 4) ? 12 : 8);
|
|
|
| + // The double inside the heap number has to be adjusted so it is always
|
| + // aligned when the object moves.
|
| + static inline bool NeedsSpecialCopying(int size,
|
| + Address new_address,
|
| + Address old_address) {
|
| + return kObjectAlignment == 4 &&
|
| + size == kSize &&
|
| + ((reinterpret_cast<intptr_t>(new_address) & 7) !=
|
| + (reinterpret_cast<intptr_t>(old_address) & 7)) &&
|
| + HeapObject::FromAddress(old_address)->IsHeapNumber();
|
| + }
|
| +
|
| static const uint32_t kSignMask = 0x80000000u;
|
| static const uint32_t kExponentMask = 0x7ff00000u;
|
| static const uint32_t kMantissaMask = 0xfffffu;
|
| @@ -1088,6 +1105,11 @@
|
| static const int kMantissaBitsInTopWord = 20;
|
| static const int kNonMantissaBitsInTopWord = 12;
|
|
|
| + void CopyBodyTo(HeapObject* destination) {
|
| + double v = value();
|
| + reinterpret_cast<HeapNumber*>(destination)->set_value(v);
|
| + }
|
| +
|
| private:
|
| DISALLOW_IMPLICIT_CONSTRUCTORS(HeapNumber);
|
| };
|
|
|