Changeset 39738 in webkit for trunk/JavaScriptCore/runtime/JSImmediate.h
- Timestamp:
- Jan 9, 2009, 12:11:00 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/JSImmediate.h
r39670 r39738 83 83 */ 84 84 85 /* 86 * On 64-bit platforms, we support an alternative encoding form for immediates, if 87 * USE(ALTERNATE_JSIMMEDIATE) is defined. 88 * 89 * The top 16-bits denote the type: 90 * 91 * Pointer: 0000:PPPP:PPPP:PPPP 92 * Integer: FFFF:0000:IIII:IIII 93 * 94 * 32-bit signed integers are marked with the 16-bit tag '0xFFFF'. The tag '0x0000' 95 * denotes a pointer, or another form of tagged immediate. Boolean, null and undefined 96 * values are encoded in the same manner as the default format. 97 */ 98 85 99 class JSImmediate { 86 100 private: 87 101 friend class JIT; 88 102 89 static const int32_t TagMask = 0x3; // primary tag is 2 bits long 90 static const int32_t TagBitTypeInteger = 0x1; // bottom bit set indicates integer, this dominates the following bit 91 static const int32_t TagBitTypeOther = 0x2; // second bit set indicates immediate other than an integer 92 93 static const int32_t ExtendedTagMask = 0xC; // extended tag holds a further two bits 94 static const int32_t ExtendedTagBitBool = 0x4; 95 static const int32_t ExtendedTagBitUndefined = 0x8; 96 97 static const int32_t FullTagTypeMask = TagMask | ExtendedTagMask; 98 static const int32_t FullTagTypeBool = TagBitTypeOther | ExtendedTagBitBool; 99 static const int32_t FullTagTypeUndefined = TagBitTypeOther | ExtendedTagBitUndefined; 100 static const int32_t FullTagTypeNull = TagBitTypeOther; 101 103 #if USE(ALTERNATE_JSIMMEDIATE) 104 static const intptr_t TagTypeInteger = 0xffff000000000000ll; // bottom bit set indicates integer, this dominates the following bit 105 #else 106 static const intptr_t TagTypeInteger = 0x1; // bottom bit set indicates integer, this dominates the following bit 107 #endif 108 static const intptr_t TagBitTypeOther = 0x2; // second bit set indicates immediate other than an integer 109 static const intptr_t TagMask = TagTypeInteger | TagBitTypeOther; 110 111 static const intptr_t ExtendedTagMask = 0xC; // extended tag holds a further two bits 112 static const intptr_t ExtendedTagBitBool = 0x4; 113 static const intptr_t ExtendedTagBitUndefined = 0x8; 114 115 static const intptr_t FullTagTypeMask = TagMask | ExtendedTagMask; 116 static const intptr_t FullTagTypeBool = TagBitTypeOther | ExtendedTagBitBool; 117 static const intptr_t FullTagTypeUndefined = TagBitTypeOther | ExtendedTagBitUndefined; 118 static const intptr_t FullTagTypeNull = TagBitTypeOther; 119 120 #if USE(ALTERNATE_JSIMMEDIATE) 121 static const int32_t IntegerPayloadShift = 0; 122 #else 102 123 static const int32_t IntegerPayloadShift = 1; 124 #endif 103 125 static const int32_t ExtendedPayloadShift = 4; 104 126 105 static const int32_t ExtendedPayloadBitBoolValue = 1 << ExtendedPayloadShift; 106 107 #if USE(ALTERNATE_JSIMMEDIATE) 108 static const intptr_t signBit = 0x100000000ll; 109 #else 127 static const intptr_t ExtendedPayloadBitBoolValue = 1 << ExtendedPayloadShift; 128 110 129 static const int32_t signBit = 0x80000000; 111 #endif112 130 113 131 public: … … 119 137 static ALWAYS_INLINE bool isNumber(JSValuePtr v) 120 138 { 121 return rawValue(v) & Tag BitTypeInteger;139 return rawValue(v) & TagTypeInteger; 122 140 } 123 141 … … 125 143 { 126 144 // A single mask to check for the sign bit and the number tag all at once. 127 return (rawValue(v) & (signBit | Tag BitTypeInteger)) == TagBitTypeInteger;145 return (rawValue(v) & (signBit | TagTypeInteger)) == TagTypeInteger; 128 146 } 129 147 … … 175 193 static ALWAYS_INLINE bool areBothImmediateNumbers(JSValuePtr v1, JSValuePtr v2) 176 194 { 177 return rawValue(v1) & rawValue(v2) & Tag BitTypeInteger;195 return rawValue(v1) & rawValue(v2) & TagTypeInteger; 178 196 } 179 197 … … 187 205 { 188 206 ASSERT(areBothImmediateNumbers(v1, v2)); 189 return makeValue((rawValue(v1) ^ rawValue(v2)) | Tag BitTypeInteger);207 return makeValue((rawValue(v1) ^ rawValue(v2)) | TagTypeInteger); 190 208 } 191 209 … … 199 217 { 200 218 ASSERT(areBothImmediateNumbers(val, shift)); 201 return makeValue((rawValue(val) >> ((rawValue(shift) >> IntegerPayloadShift) & 0x1f)) | TagBitTypeInteger); 219 #if USE(ALTERNATE_JSIMMEDIATE) 220 return makeValue(static_cast<intptr_t>(static_cast<uint32_t>(static_cast<int32_t>(rawValue(val)) >> ((rawValue(shift) >> IntegerPayloadShift) & 0x1f))) | TagTypeInteger); 221 #else 222 return makeValue((rawValue(val) >> ((rawValue(shift) >> IntegerPayloadShift) & 0x1f)) | TagTypeInteger); 223 #endif 202 224 } 203 225 … … 206 228 // Number is non-negative and an operation involving two of these can't overflow. 207 229 // Checking for allowed negative numbers takes more time than it's worth on SunSpider. 208 return (rawValue(v) & (Tag BitTypeInteger + (signBit | (signBit >> 1)))) == TagBitTypeInteger;230 return (rawValue(v) & (TagTypeInteger + (signBit | (signBit >> 1)))) == TagTypeInteger; 209 231 } 210 232 … … 213 235 ASSERT(canDoFastAdditiveOperations(v1)); 214 236 ASSERT(canDoFastAdditiveOperations(v2)); 215 return makeValue(rawValue(v1) + rawValue(v2) - Tag BitTypeInteger);237 return makeValue(rawValue(v1) + rawValue(v2) - TagTypeInteger); 216 238 } 217 239 … … 220 242 ASSERT(canDoFastAdditiveOperations(v1)); 221 243 ASSERT(canDoFastAdditiveOperations(v2)); 222 return makeValue(rawValue(v1) - rawValue(v2) + Tag BitTypeInteger);244 return makeValue(rawValue(v1) - rawValue(v2) + TagTypeInteger); 223 245 } 224 246 … … 274 296 } 275 297 298 #if USE(ALTERNATE_JSIMMEDIATE) 299 static ALWAYS_INLINE JSValuePtr makeInt(uint32_t value) 300 #else 276 301 static ALWAYS_INLINE JSValuePtr makeInt(int32_t value) 277 { 278 return makeValue((static_cast<intptr_t>(value) << IntegerPayloadShift) | TagBitTypeInteger); 302 #endif 303 { 304 return makeValue((static_cast<intptr_t>(value) << IntegerPayloadShift) | TagTypeInteger); 279 305 } 280 306 … … 331 357 ASSERT(isImmediate(v)); 332 358 intptr_t bits = rawValue(v); 333 return (bits & Tag BitTypeInteger)334 ? bits != Tag BitTypeInteger // !0 ints359 return (bits & TagTypeInteger) 360 ? bits != TagTypeInteger // !0 ints 335 361 : bits == (FullTagTypeBool | ExtendedPayloadBitBoolValue); // bool true 336 362 }
Note:
See TracChangeset
for help on using the changeset viewer.