Changeset 27149 in webkit for trunk/JavaScriptCore/kjs/JSImmediate.h
- Timestamp:
- Oct 27, 2007, 7:48:34 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/JSImmediate.h
r26950 r27149 25 25 #include "JSType.h" 26 26 #include <wtf/Assertions.h> 27 #include <wtf/AlwaysInline.h> 27 28 #include <stdarg.h> 28 29 #include <stdint.h> … … 60 61 class JSImmediate { 61 62 public: 62 static bool isImmediate(const JSValue* v)63 static ALWAYS_INLINE bool isImmediate(const JSValue* v) 63 64 { 64 65 return getTag(v) != 0; 65 66 } 66 67 67 static bool isNumber(const JSValue* v)68 static ALWAYS_INLINE bool isNumber(const JSValue* v) 68 69 { 69 70 return (getTag(v) == NumberType); 70 71 } 71 72 72 static bool isBoolean(const JSValue* v)73 static ALWAYS_INLINE bool isBoolean(const JSValue* v) 73 74 { 74 75 return (getTag(v) == BooleanType); … … 76 77 77 78 // Since we have room for only 3 unique tags, null and undefined have to share. 78 static bool isUndefinedOrNull(const JSValue* v)79 static ALWAYS_INLINE bool isUndefinedOrNull(const JSValue* v) 79 80 { 80 81 return (getTag(v) == UndefinedType); … … 103 104 static const uintptr_t TagMask = 3; // type tags are 2 bits long 104 105 105 static JSValue* tag(uintptr_t bits, uintptr_t tag)106 static ALWAYS_INLINE JSValue* tag(uintptr_t bits, uintptr_t tag) 106 107 { 107 108 return reinterpret_cast<JSValue*>(bits | tag); 108 109 } 109 110 110 static uintptr_t unTag(const JSValue* v)111 static ALWAYS_INLINE uintptr_t unTag(const JSValue* v) 111 112 { 112 113 return reinterpret_cast<uintptr_t>(v) & ~TagMask; 113 114 } 114 115 115 static uintptr_t getTag(const JSValue* v)116 static ALWAYS_INLINE uintptr_t getTag(const JSValue* v) 116 117 { 117 118 return reinterpret_cast<uintptr_t>(v) & TagMask; … … 146 147 static const uint32_t zeroAsBits = 0x0; 147 148 148 static JSValue* fromDouble(double d)149 static ALWAYS_INLINE JSValue* fromDouble(double d) 149 150 { 150 151 FloatUnion floatUnion; … … 164 165 } 165 166 166 static float toFloat(const JSValue* v)167 static ALWAYS_INLINE float toFloat(const JSValue* v) 167 168 { 168 169 ASSERT(isImmediate(v)); … … 173 174 } 174 175 175 static double toDouble(const JSValue* v)176 static ALWAYS_INLINE double toDouble(const JSValue* v) 176 177 { 177 178 return toFloat(v); 178 179 } 179 180 180 static bool getTruncatedInt32(const JSValue* v, int32_t& i)181 static ALWAYS_INLINE bool getTruncatedInt32(const JSValue* v, int32_t& i) 181 182 { 182 183 float f = toFloat(v); … … 187 188 } 188 189 189 static bool getTruncatedUInt32(const JSValue* v, uint32_t& i)190 static ALWAYS_INLINE bool getTruncatedUInt32(const JSValue* v, uint32_t& i) 190 191 { 191 192 float f = toFloat(v); … … 202 203 static const uint64_t zeroAsBits = 0x0; 203 204 204 static JSValue* fromDouble(double d)205 static ALWAYS_INLINE JSValue* fromDouble(double d) 205 206 { 206 207 DoubleUnion doubleUnion; … … 214 215 } 215 216 216 static double toDouble(const JSValue* v)217 static ALWAYS_INLINE double toDouble(const JSValue* v) 217 218 { 218 219 ASSERT(isImmediate(v)); … … 223 224 } 224 225 225 static bool getTruncatedInt32(const JSValue* v, int32_t& i)226 static ALWAYS_INLINE bool getTruncatedInt32(const JSValue* v, int32_t& i) 226 227 { 227 228 double d = toDouble(v); … … 232 233 } 233 234 234 static bool getTruncatedUInt32(const JSValue* v, uint32_t& i)235 static ALWAYS_INLINE bool getTruncatedUInt32(const JSValue* v, uint32_t& i) 235 236 { 236 237 double d = toDouble(v); … … 242 243 }; 243 244 244 inlineJSValue* JSImmediate::trueImmediate() { return tag(FPBitValues<is32bit, is64bit>::oneAsBits, BooleanType); }245 inlineJSValue* JSImmediate::falseImmediate() { return tag(FPBitValues<is32bit, is64bit>::zeroAsBits, BooleanType); }246 inlineJSValue* JSImmediate::NaNImmediate() { return tag(FPBitValues<is32bit, is64bit>::nanAsBits, NumberType); }247 inlineJSValue* JSImmediate::undefinedImmediate() { return tag(FPBitValues<is32bit, is64bit>::nanAsBits, UndefinedType); }248 inlineJSValue* JSImmediate::nullImmediate() { return tag(FPBitValues<is32bit, is64bit>::zeroAsBits, UndefinedType); }249 250 inlinebool JSImmediate::toBoolean(const JSValue* v)245 ALWAYS_INLINE JSValue* JSImmediate::trueImmediate() { return tag(FPBitValues<is32bit, is64bit>::oneAsBits, BooleanType); } 246 ALWAYS_INLINE JSValue* JSImmediate::falseImmediate() { return tag(FPBitValues<is32bit, is64bit>::zeroAsBits, BooleanType); } 247 ALWAYS_INLINE JSValue* JSImmediate::NaNImmediate() { return tag(FPBitValues<is32bit, is64bit>::nanAsBits, NumberType); } 248 ALWAYS_INLINE JSValue* JSImmediate::undefinedImmediate() { return tag(FPBitValues<is32bit, is64bit>::nanAsBits, UndefinedType); } 249 ALWAYS_INLINE JSValue* JSImmediate::nullImmediate() { return tag(FPBitValues<is32bit, is64bit>::zeroAsBits, UndefinedType); } 250 251 ALWAYS_INLINE bool JSImmediate::toBoolean(const JSValue* v) 251 252 { 252 253 ASSERT(isImmediate(v)); … … 259 260 } 260 261 261 inlineJSValue* JSImmediate::fromDouble(double d)262 ALWAYS_INLINE JSValue* JSImmediate::fromDouble(double d) 262 263 { 263 264 return FPBitValues<is32bit, is64bit>::fromDouble(d); 264 265 } 265 266 266 inlinedouble JSImmediate::toDouble(const JSValue* v)267 ALWAYS_INLINE double JSImmediate::toDouble(const JSValue* v) 267 268 { 268 269 return FPBitValues<is32bit, is64bit>::toDouble(v); 269 270 } 270 271 271 inlinebool JSImmediate::getUInt32(const JSValue* v, uint32_t& i)272 ALWAYS_INLINE bool JSImmediate::getUInt32(const JSValue* v, uint32_t& i) 272 273 { 273 274 double d = toDouble(v); … … 276 277 } 277 278 278 inlinebool JSImmediate::getTruncatedInt32(const JSValue* v, int32_t& i)279 ALWAYS_INLINE bool JSImmediate::getTruncatedInt32(const JSValue* v, int32_t& i) 279 280 { 280 281 return FPBitValues<is32bit, is64bit>::getTruncatedInt32(v, i); 281 282 } 282 283 283 inlinebool JSImmediate::getTruncatedUInt32(const JSValue* v, uint32_t& i)284 ALWAYS_INLINE bool JSImmediate::getTruncatedUInt32(const JSValue* v, uint32_t& i) 284 285 { 285 286 return FPBitValues<is32bit, is64bit>::getTruncatedUInt32(v, i);
Note:
See TracChangeset
for help on using the changeset viewer.