OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 static inline HeapNumber* cast(Object* obj); | 1057 static inline HeapNumber* cast(Object* obj); |
1058 | 1058 |
1059 // Dispatched behavior. | 1059 // Dispatched behavior. |
1060 Object* HeapNumberToBoolean(); | 1060 Object* HeapNumberToBoolean(); |
1061 void HeapNumberPrint(); | 1061 void HeapNumberPrint(); |
1062 void HeapNumberPrint(StringStream* accumulator); | 1062 void HeapNumberPrint(StringStream* accumulator); |
1063 #ifdef DEBUG | 1063 #ifdef DEBUG |
1064 void HeapNumberVerify(); | 1064 void HeapNumberVerify(); |
1065 #endif | 1065 #endif |
1066 | 1066 |
1067 // Layout description. | 1067 // Layout description. The value offset has a strange name to remind users |
1068 static const int kValueOffset = HeapObject::kHeaderSize; | 1068 // that the offset varies depending on the alignment of the HeapNumber. |
| 1069 static const int kValueMinimumOffset = HeapObject::kHeaderSize; |
1069 // IEEE doubles are two 32 bit words. The first is just mantissa, the second | 1070 // IEEE doubles are two 32 bit words. The first is just mantissa, the second |
1070 // is a mixture of sign, exponent and mantissa. Our current platforms are all | 1071 // is a mixture of sign, exponent and mantissa. Our current platforms are all |
1071 // little endian apart from non-EABI arm which is little endian with big | 1072 // little endian apart from non-EABI arm which is little endian with big |
1072 // endian floating point word ordering! | 1073 // endian floating point word ordering! |
1073 #if !defined(V8_HOST_ARCH_ARM) || defined(USE_ARM_EABI) | 1074 #if !defined(V8_HOST_ARCH_ARM) || defined(USE_ARM_EABI) |
1074 static const int kMantissaOffset = kValueOffset; | 1075 static const int kMantissaRelativeOffset = 0; |
1075 static const int kExponentOffset = kValueOffset + 4; | 1076 static const int kExponentRelativeOffset = 4; |
1076 #else | 1077 #else |
1077 static const int kMantissaOffset = kValueOffset + 4; | 1078 static const int kMantissaRelativeOffset = 4; |
1078 static const int kExponentOffset = kValueOffset; | 1079 static const int kExponentRelativeOffset = 0; |
1079 # define BIG_ENDIAN_FLOATING_POINT 1 | 1080 # define BIG_ENDIAN_FLOATING_POINT 1 |
1080 #endif | 1081 #endif |
1081 static const int kSize = kValueOffset + kDoubleSize; | 1082 // The double precision floating point number takes 8 bytes, but if the object |
| 1083 // alignment is only 4 then the size is increased by 4 so the double precision |
| 1084 // value can always be stored at an aligned address. |
| 1085 static const int kSize = |
| 1086 kValueMinimumOffset + ((kObjectAlignment == 4) ? 12 : 8); |
| 1087 |
| 1088 // The double inside the heap number has to be adjusted so it is always |
| 1089 // aligned when the object moves. |
| 1090 static inline bool NeedsSpecialCopying(int size, |
| 1091 Address new_address, |
| 1092 Address old_address) { |
| 1093 return kObjectAlignment == 4 && |
| 1094 size == kSize && |
| 1095 ((reinterpret_cast<intptr_t>(new_address) & 7) != |
| 1096 (reinterpret_cast<intptr_t>(old_address) & 7)) && |
| 1097 HeapObject::FromAddress(old_address)->IsHeapNumber(); |
| 1098 } |
1082 | 1099 |
1083 static const uint32_t kSignMask = 0x80000000u; | 1100 static const uint32_t kSignMask = 0x80000000u; |
1084 static const uint32_t kExponentMask = 0x7ff00000u; | 1101 static const uint32_t kExponentMask = 0x7ff00000u; |
1085 static const uint32_t kMantissaMask = 0xfffffu; | 1102 static const uint32_t kMantissaMask = 0xfffffu; |
1086 static const int kExponentBias = 1023; | 1103 static const int kExponentBias = 1023; |
1087 static const int kExponentShift = 20; | 1104 static const int kExponentShift = 20; |
1088 static const int kMantissaBitsInTopWord = 20; | 1105 static const int kMantissaBitsInTopWord = 20; |
1089 static const int kNonMantissaBitsInTopWord = 12; | 1106 static const int kNonMantissaBitsInTopWord = 12; |
1090 | 1107 |
| 1108 void CopyBodyTo(HeapObject* destination) { |
| 1109 double v = value(); |
| 1110 reinterpret_cast<HeapNumber*>(destination)->set_value(v); |
| 1111 } |
| 1112 |
1091 private: | 1113 private: |
1092 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapNumber); | 1114 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapNumber); |
1093 }; | 1115 }; |
1094 | 1116 |
1095 | 1117 |
1096 // The JSObject describes real heap allocated JavaScript objects with | 1118 // The JSObject describes real heap allocated JavaScript objects with |
1097 // properties. | 1119 // properties. |
1098 // Note that the map of JSObject changes during execution to enable inline | 1120 // Note that the map of JSObject changes during execution to enable inline |
1099 // caching. | 1121 // caching. |
1100 class JSObject: public HeapObject { | 1122 class JSObject: public HeapObject { |
(...skipping 3762 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4863 } else { | 4885 } else { |
4864 value &= ~(1 << bit_position); | 4886 value &= ~(1 << bit_position); |
4865 } | 4887 } |
4866 return value; | 4888 return value; |
4867 } | 4889 } |
4868 }; | 4890 }; |
4869 | 4891 |
4870 } } // namespace v8::internal | 4892 } } // namespace v8::internal |
4871 | 4893 |
4872 #endif // V8_OBJECTS_H_ | 4894 #endif // V8_OBJECTS_H_ |
OLD | NEW |