Changeset 39540 in webkit for trunk/JavaScriptCore/runtime/JSImmediate.h
- Timestamp:
- Jan 1, 2009, 7:06:10 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/JSImmediate.h
r39342 r39540 89 89 friend class JIT; 90 90 91 static const uint32_t TagMask = 0x3u; // primary tag is 2 bits long 92 static const uint32_t TagBitTypeInteger = 0x1u; // bottom bit set indicates integer, this dominates the following bit 93 static const uint32_t TagBitTypeOther = 0x2u; // second bit set indicates immediate other than an integer 94 95 static const uint32_t ExtendedTagMask = 0xCu; // extended tag holds a further two bits 96 static const uint32_t ExtendedTagBitBool = 0x4u; 97 static const uint32_t ExtendedTagBitUndefined = 0x8u; 98 99 static const uint32_t FullTagTypeMask = TagMask | ExtendedTagMask; 100 static const uint32_t FullTagTypeBool = TagBitTypeOther | ExtendedTagBitBool; 101 static const uint32_t FullTagTypeUndefined = TagBitTypeOther | ExtendedTagBitUndefined; 102 static const uint32_t FullTagTypeNull = TagBitTypeOther; 103 104 static const uint32_t IntegerPayloadShift = 1u; 105 static const uint32_t ExtendedPayloadShift = 4u; 106 107 static const uint32_t ExtendedPayloadBitBoolValue = 1 << ExtendedPayloadShift; 91 static const int32_t TagMask = 0x3; // primary tag is 2 bits long 92 static const int32_t TagBitTypeInteger = 0x1; // bottom bit set indicates integer, this dominates the following bit 93 static const int32_t TagBitTypeOther = 0x2; // second bit set indicates immediate other than an integer 94 95 static const int32_t ExtendedTagMask = 0xC; // extended tag holds a further two bits 96 static const int32_t ExtendedTagBitBool = 0x4; 97 static const int32_t ExtendedTagBitUndefined = 0x8; 98 99 static const int32_t FullTagTypeMask = TagMask | ExtendedTagMask; 100 static const int32_t FullTagTypeBool = TagBitTypeOther | ExtendedTagBitBool; 101 static const int32_t FullTagTypeUndefined = TagBitTypeOther | ExtendedTagBitUndefined; 102 static const int32_t FullTagTypeNull = TagBitTypeOther; 103 104 static const int32_t IntegerPayloadShift = 1; 105 static const int32_t ExtendedPayloadShift = 4; 106 107 static const int32_t ExtendedPayloadBitBoolValue = 1 << ExtendedPayloadShift; 108 109 #if USE(ALTERNATE_JSIMMEDIATE) 110 static const intptr_t signBit = 0x100000000ll; 111 #else 112 static const int32_t signBit = 0x80000000; 113 #endif 108 114 109 115 public: … … 121 127 { 122 128 // A single mask to check for the sign bit and the number tag all at once. 123 return (rawValue(v) & ( 0x80000000| TagBitTypeInteger)) == TagBitTypeInteger;129 return (rawValue(v) & (signBit | TagBitTypeInteger)) == TagBitTypeInteger; 124 130 } 125 131 … … 138 144 { 139 145 ASSERT(isNumber(v)); 140 return rawValue(v) & 0x80000000;146 return rawValue(v) & signBit; 141 147 } 142 148 … … 195 201 { 196 202 ASSERT(areBothImmediateNumbers(val, shift)); 197 return makeValue(( static_cast<intptr_t>(rawValue(val)) >> ((rawValue(shift) >> IntegerPayloadShift) & 0x1f)) | TagBitTypeInteger);203 return makeValue((rawValue(val) >> ((rawValue(shift) >> IntegerPayloadShift) & 0x1f)) | TagBitTypeInteger); 198 204 } 199 205 … … 202 208 // Number is non-negative and an operation involving two of these can't overflow. 203 209 // Checking for allowed negative numbers takes more time than it's worth on SunSpider. 204 return (rawValue(v) & (TagBitTypeInteger + ( 3u << 30))) == TagBitTypeInteger;210 return (rawValue(v) & (TagBitTypeInteger + (signBit | (signBit >> 1)))) == TagBitTypeInteger; 205 211 } 206 212 … … 256 262 257 263 private: 264 #if USE(ALTERNATE_JSIMMEDIATE) 265 static const int minImmediateInt = ((-INT_MAX) - 1); 266 static const int maxImmediateInt = INT_MAX; 267 #else 258 268 static const int minImmediateInt = ((-INT_MAX) - 1) >> IntegerPayloadShift; 259 269 static const int maxImmediateInt = INT_MAX >> IntegerPayloadShift; 270 #endif 260 271 static const unsigned maxImmediateUInt = maxImmediateInt; 261 272 262 static ALWAYS_INLINE JSValue* makeValue( uintptr_t integer)273 static ALWAYS_INLINE JSValue* makeValue(intptr_t integer) 263 274 { 264 275 return reinterpret_cast<JSValue*>(integer); … … 267 278 static ALWAYS_INLINE JSValue* makeInt(int32_t value) 268 279 { 269 // FIXME: Why does the result of this need be a 64-bit value? 270 // Integer immediates are still only 31-bit on x86-64. 271 return makeValue((value << IntegerPayloadShift) | static_cast<uintptr_t>(TagBitTypeInteger)); 280 return makeValue((static_cast<intptr_t>(value) << IntegerPayloadShift) | TagBitTypeInteger); 272 281 } 273 282 274 283 static ALWAYS_INLINE JSValue* makeBool(bool b) 275 284 { 276 return makeValue((static_cast< uintptr_t>(b) << ExtendedPayloadShift) | FullTagTypeBool);285 return makeValue((static_cast<intptr_t>(b) << ExtendedPayloadShift) | FullTagTypeBool); 277 286 } 278 287 … … 289 298 static ALWAYS_INLINE int32_t intValue(JSValue* v) 290 299 { 291 return static_cast<int32_t>( static_cast<intptr_t>(rawValue(v)) >> IntegerPayloadShift);300 return static_cast<int32_t>(rawValue(v) >> IntegerPayloadShift); 292 301 } 293 302 … … 302 311 } 303 312 304 static ALWAYS_INLINE uintptr_t rawValue(JSValue* v)305 { 306 return reinterpret_cast< uintptr_t>(v);313 static ALWAYS_INLINE intptr_t rawValue(JSValue* v) 314 { 315 return reinterpret_cast<intptr_t>(v); 307 316 } 308 317 … … 323 332 { 324 333 ASSERT(isImmediate(v)); 325 uintptr_t bits = rawValue(v);334 intptr_t bits = rawValue(v); 326 335 return (bits & TagBitTypeInteger) 327 336 ? bits != TagBitTypeInteger // !0 ints … … 392 401 if ((i < minImmediateInt) | (i > maxImmediateInt)) 393 402 return noValue(); 394 return makeInt(static_cast< uintptr_t>(i));403 return makeInt(static_cast<intptr_t>(i)); 395 404 } 396 405 … … 399 408 if (i > maxImmediateUInt) 400 409 return noValue(); 401 return makeInt(static_cast< uintptr_t>(i));410 return makeInt(static_cast<intptr_t>(i)); 402 411 } 403 412
Note:
See TracChangeset
for help on using the changeset viewer.