Changeset 70111 in webkit for trunk/JavaScriptCore/runtime/JSImmediate.h
- Timestamp:
- Oct 19, 2010, 4:55:08 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/JSImmediate.h
r62419 r70111 23 23 #define JSImmediate_h 24 24 25 #if !USE(JSVALUE32_64)25 #if USE(JSVALUE64) 26 26 27 27 #include <wtf/Assertions.h> … … 45 45 class UString; 46 46 47 #if USE(JSVALUE64)48 47 inline intptr_t reinterpretDoubleToIntptr(double value) 49 48 { … … 55 54 return WTF::bitwise_cast<double>(value); 56 55 } 57 #endif58 56 59 57 /* … … 160 158 friend JSValue jsNumber(JSGlobalData* globalData, unsigned long long i); 161 159 162 #if USE(JSVALUE64)163 160 // If all bits in the mask are set, this indicates an integer number, 164 161 // if any but not all are set this value is a double precision number. … … 167 164 // with a 16-bit pattern within the range 0x0001..0xFFFE. 168 165 static const intptr_t DoubleEncodeOffset = 0x1000000000000ll; 169 #elif USE(JSVALUE32)170 static const intptr_t TagTypeNumber = 0x1; // bottom bit set indicates integer, this dominates the following bit171 #endif172 166 static const intptr_t TagBitTypeOther = 0x2; // second bit set indicates immediate other than an integer 173 167 static const intptr_t TagMask = TagTypeNumber | TagBitTypeOther; … … 182 176 static const intptr_t FullTagTypeNull = TagBitTypeOther; 183 177 184 #if USE(JSVALUE64)185 178 static const int32_t IntegerPayloadShift = 0; 186 #else187 static const int32_t IntegerPayloadShift = 1;188 #endif189 179 static const int32_t ExtendedPayloadShift = 4; 190 180 … … 205 195 static ALWAYS_INLINE bool isIntegerNumber(JSValue v) 206 196 { 207 #if USE(JSVALUE64)208 197 return (rawValue(v) & TagTypeNumber) == TagTypeNumber; 209 #else 210 return isNumber(v); 211 #endif 212 } 213 214 #if USE(JSVALUE64) 198 } 199 215 200 static ALWAYS_INLINE bool isDouble(JSValue v) 216 201 { 217 202 return isNumber(v) && !isIntegerNumber(v); 218 203 } 219 #endif220 204 221 205 static ALWAYS_INLINE bool isPositiveIntegerNumber(JSValue v) … … 261 245 static ALWAYS_INLINE bool areBothImmediateIntegerNumbers(JSValue v1, JSValue v2) 262 246 { 263 #if USE(JSVALUE64)264 247 return (rawValue(v1) & rawValue(v2) & TagTypeNumber) == TagTypeNumber; 265 #else266 return rawValue(v1) & rawValue(v2) & TagTypeNumber;267 #endif268 248 } 269 249 … … 286 266 287 267 private: 288 #if USE(JSVALUE64)289 268 static const int minImmediateInt = ((-INT_MAX) - 1); 290 269 static const int maxImmediateInt = INT_MAX; 291 #else292 static const int minImmediateInt = ((-INT_MAX) - 1) >> IntegerPayloadShift;293 static const int maxImmediateInt = INT_MAX >> IntegerPayloadShift;294 #endif295 270 static const unsigned maxImmediateUInt = maxImmediateInt; 296 271 … … 303 278 // integer doesn't interfere with the tag bits in the upper word. In the default encoding, 304 279 // if intptr_t id larger then int32_t we sign extend the value through the upper word. 305 #if USE(JSVALUE64)306 280 static ALWAYS_INLINE JSValue makeInt(uint32_t value) 307 #else308 static ALWAYS_INLINE JSValue makeInt(int32_t value)309 #endif310 281 { 311 282 return makeValue((static_cast<intptr_t>(value) << IntegerPayloadShift) | TagTypeNumber); 312 283 } 313 284 314 #if USE(JSVALUE64)315 285 static ALWAYS_INLINE JSValue makeDouble(double value) 316 286 { 317 287 return makeValue(reinterpretDoubleToIntptr(value) + DoubleEncodeOffset); 318 288 } 319 #endif320 289 321 290 static ALWAYS_INLINE JSValue makeBool(bool b) … … 337 306 static JSValue fromNumberOutsideIntegerRange(T); 338 307 339 #if USE(JSVALUE64)340 308 static ALWAYS_INLINE double doubleValue(JSValue v) 341 309 { 342 310 return reinterpretIntptrToDouble(rawValue(v) - DoubleEncodeOffset); 343 311 } 344 #endif345 312 346 313 static ALWAYS_INLINE int32_t intValue(JSValue v) … … 372 339 ALWAYS_INLINE JSValue JSImmediate::oneImmediate() { return makeInt(1); } 373 340 374 #if USE(JSVALUE64)375 341 inline bool doubleToBoolean(double value) 376 342 { … … 384 350 : doubleToBoolean(doubleValue(v)) : v == trueImmediate(); 385 351 } 386 #else387 ALWAYS_INLINE bool JSImmediate::toBoolean(JSValue v)388 {389 ASSERT(isImmediate(v));390 return isIntegerNumber(v) ? v != zeroImmediate() : v == trueImmediate();391 }392 #endif393 352 394 353 ALWAYS_INLINE uint32_t JSImmediate::getTruncatedUInt32(JSValue v) … … 399 358 } 400 359 401 #if USE(JSVALUE64)402 360 template<typename T> 403 361 inline JSValue JSImmediate::fromNumberOutsideIntegerRange(T value) … … 405 363 return makeDouble(static_cast<double>(value)); 406 364 } 407 #else408 template<typename T>409 inline JSValue JSImmediate::fromNumberOutsideIntegerRange(T)410 {411 return JSValue();412 }413 #endif414 365 415 366 ALWAYS_INLINE JSValue JSImmediate::from(char i) … … 440 391 ALWAYS_INLINE JSValue JSImmediate::from(int i) 441 392 { 442 #if !USE(JSVALUE64)443 if ((i < minImmediateInt) | (i > maxImmediateInt))444 return fromNumberOutsideIntegerRange(i);445 #endif446 393 return makeInt(i); 447 394 } … … 506 453 return intValue(v); 507 454 508 #if USE(JSVALUE64)509 455 if (isNumber(v)) { 510 456 ASSERT(isDouble(v)); 511 457 return doubleValue(v); 512 458 } 513 #else514 ASSERT(!isNumber(v));515 #endif516 459 517 460 if (rawValue(v) == FullTagTypeUndefined) … … 671 614 { 672 615 ASSERT(canDoFastRshift(val, shift) || canDoFastUrshift(val, shift)); 673 #if USE(JSVALUE64)674 616 return JSImmediate::makeValue(static_cast<intptr_t>(static_cast<uint32_t>(static_cast<int32_t>(JSImmediate::rawValue(val)) >> ((JSImmediate::rawValue(shift) >> JSImmediate::IntegerPayloadShift) & 0x1f))) | JSImmediate::TagTypeNumber); 675 #else676 return JSImmediate::makeValue((JSImmediate::rawValue(val) >> ((JSImmediate::rawValue(shift) >> JSImmediate::IntegerPayloadShift) & 0x1f)) | JSImmediate::TagTypeNumber);677 #endif678 617 } 679 618 … … 719 658 } // namespace JSC 720 659 721 #endif // !USE(JSVALUE32_64)660 #endif // USE(JSVALUE64) 722 661 723 662 #endif // JSImmediate_h
Note:
See TracChangeset
for help on using the changeset viewer.