Changeset 46598 in webkit for trunk/JavaScriptCore/runtime
- Timestamp:
- Jul 30, 2009, 1:57:44 PM (16 years ago)
- Location:
- trunk/JavaScriptCore/runtime
- Files:
-
- 2 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/ArgList.h
r45891 r46598 23 23 #define ArgList_h 24 24 25 #include "JSImmediate.h"26 25 #include "Register.h" 27 26 -
trunk/JavaScriptCore/runtime/Arguments.h
r44224 r46598 231 231 } 232 232 233 ALWAYS_INLINE Arguments* Register::arguments() const 234 { 235 if (jsValue() == JSValue()) 236 return 0; 237 return asArguments(jsValue()); 238 } 239 240 233 241 } // namespace JSC 234 242 -
trunk/JavaScriptCore/runtime/Collector.cpp
r46431 r46598 1183 1183 if (cell->isString()) 1184 1184 return "string"; 1185 #if USE(JSVALUE32) 1185 1186 if (cell->isNumber()) 1186 1187 return "number"; 1188 #endif 1187 1189 if (cell->isGetterSetter()) 1188 1190 return "gettersetter"; -
trunk/JavaScriptCore/runtime/Collector.h
r45891 r46598 168 168 169 169 // cell size needs to be a power of two for certain optimizations in collector.cpp 170 template<> struct CellSize<sizeof(uint32_t)> { static const size_t m_value = 32; }; // 32-bit 171 template<> struct CellSize<sizeof(uint64_t)> { static const size_t m_value = 64; }; // 64-bit 170 #if USE(JSVALUE32) 171 template<> struct CellSize<sizeof(uint32_t)> { static const size_t m_value = 32; }; 172 #else 173 template<> struct CellSize<sizeof(uint32_t)> { static const size_t m_value = 64; }; 174 #endif 175 template<> struct CellSize<sizeof(uint64_t)> { static const size_t m_value = 64; }; 176 172 177 const size_t BLOCK_SIZE = 16 * 4096; // 64k 173 178 -
trunk/JavaScriptCore/runtime/ExceptionHelpers.h
r46528 r46598 30 30 #define ExceptionHelpers_h 31 31 32 #include "JSImmediate.h"33 32 34 33 namespace JSC { -
trunk/JavaScriptCore/runtime/InitializeThreading.cpp
r44508 r46598 30 30 #include "InitializeThreading.h" 31 31 32 #include "JSImmediate.h"33 32 #include "Collector.h" 34 33 #include "dtoa.h" -
trunk/JavaScriptCore/runtime/JSArray.cpp
r46180 r46598 135 135 136 136 m_storage = static_cast<ArrayStorage*>(fastZeroedMalloc(storageSize(initialCapacity))); 137 m_storage->m_vectorLength = initialCapacity; 138 137 139 m_fastAccessCutoff = 0; 138 m_storage->m_vectorLength = initialCapacity;139 m_storage->m_length = 0;140 140 141 141 checkConsistency(); … … 147 147 unsigned initialCapacity = min(initialLength, MIN_SPARSE_ARRAY_INDEX); 148 148 149 m_storage = static_cast<ArrayStorage*>(fastZeroedMalloc(storageSize(initialCapacity))); 149 m_storage = static_cast<ArrayStorage*>(fastMalloc(storageSize(initialCapacity))); 150 m_storage->m_length = initialLength; 151 m_storage->m_vectorLength = initialCapacity; 152 m_storage->m_numValuesInVector = 0; 153 m_storage->m_sparseValueMap = 0; 154 m_storage->lazyCreationData = 0; 155 156 JSValue* vector = m_storage->m_vector; 157 for (size_t i = 0; i < initialCapacity; ++i) 158 vector[i] = JSValue(); 159 150 160 m_fastAccessCutoff = 0; 151 m_storage->m_vectorLength = initialCapacity; 152 m_storage->m_length = initialLength;161 162 checkConsistency(); 153 163 154 164 Heap::heap(this)->reportExtraMemoryCost(initialCapacity * sizeof(JSValue)); 155 156 checkConsistency();157 165 } 158 166 … … 160 168 : JSObject(structure) 161 169 { 162 unsigned length = list.size(); 163 164 m_fastAccessCutoff = length; 165 166 ArrayStorage* storage = static_cast<ArrayStorage*>(fastMalloc(storageSize(length))); 167 168 storage->m_vectorLength = length; 169 storage->m_numValuesInVector = length; 170 storage->m_sparseValueMap = 0; 171 storage->m_length = length; 170 unsigned initialCapacity = list.size(); 171 172 m_storage = static_cast<ArrayStorage*>(fastMalloc(storageSize(initialCapacity))); 173 m_storage->m_length = initialCapacity; 174 m_storage->m_vectorLength = initialCapacity; 175 m_storage->m_numValuesInVector = initialCapacity; 176 m_storage->m_sparseValueMap = 0; 172 177 173 178 size_t i = 0; 174 179 ArgList::const_iterator end = list.end(); 175 180 for (ArgList::const_iterator it = list.begin(); it != end; ++it, ++i) 176 storage->m_vector[i] = *it;177 178 m_ storage = storage;179 180 Heap::heap(this)->reportExtraMemoryCost(storageSize(length));181 182 checkConsistency();181 m_storage->m_vector[i] = *it; 182 183 m_fastAccessCutoff = initialCapacity; 184 185 checkConsistency(); 186 187 Heap::heap(this)->reportExtraMemoryCost(storageSize(initialCapacity)); 183 188 } 184 189 -
trunk/JavaScriptCore/runtime/JSCell.cpp
r43153 r46598 91 91 } 92 92 93 bool JSCell::getTruncatedInt32(int32_t&) const94 {95 return false;96 }97 98 bool JSCell::getTruncatedUInt32(uint32_t&) const99 {100 return false;101 }102 103 93 bool JSCell::getString(UString&stringValue) const 104 94 { -
trunk/JavaScriptCore/runtime/JSCell.h
r46528 r46598 41 41 friend class JSString; 42 42 friend class JSValue; 43 friend class JSAPIValueWrapper; 43 44 friend struct VPtrSet; 44 45 … … 49 50 public: 50 51 // Querying the type. 52 #if USE(JSVALUE32) 51 53 bool isNumber() const; 54 #endif 52 55 bool isString() const; 53 56 bool isObject() const; 54 57 virtual bool isGetterSetter() const; 55 58 virtual bool isObject(const ClassInfo*) const; 59 virtual bool isAPIValueWrapper() const { return false; } 56 60 57 61 Structure* structure() const; … … 69 73 // FIXME: remove these methods, can check isNumberCell in JSValue && then call asNumberCell::*. 70 74 virtual bool getUInt32(uint32_t&) const; 71 virtual bool getTruncatedInt32(int32_t&) const;72 virtual bool getTruncatedUInt32(uint32_t&) const;73 75 74 76 // Basic conversions. … … 125 127 } 126 128 129 #if USE(JSVALUE32) 127 130 inline bool JSCell::isNumber() const 128 131 { 129 132 return Heap::isNumber(const_cast<JSCell*>(this)); 130 133 } 134 #endif 131 135 132 136 inline bool JSCell::isObject() const … … 153 157 { 154 158 return Heap::markCell(this); 155 }156 157 ALWAYS_INLINE JSCell* JSValue::asCell() const158 {159 ASSERT(isCell());160 return m_ptr;161 159 } 162 160 … … 174 172 inline bool JSValue::isString() const 175 173 { 176 return !JSImmediate::isImmediate(asValue()) && asCell()->isString();174 return isCell() && asCell()->isString(); 177 175 } 178 176 179 177 inline bool JSValue::isGetterSetter() const 180 178 { 181 return !JSImmediate::isImmediate(asValue()) && asCell()->isGetterSetter();179 return isCell() && asCell()->isGetterSetter(); 182 180 } 183 181 184 182 inline bool JSValue::isObject() const 185 183 { 186 return !JSImmediate::isImmediate(asValue()) && asCell()->isObject();184 return isCell() && asCell()->isObject(); 187 185 } 188 186 189 187 inline bool JSValue::getString(UString& s) const 190 188 { 191 return !JSImmediate::isImmediate(asValue()) && asCell()->getString(s);189 return isCell() && asCell()->getString(s); 192 190 } 193 191 194 192 inline UString JSValue::getString() const 195 193 { 196 return JSImmediate::isImmediate(asValue()) ? UString() : asCell()->getString();194 return isCell() ? asCell()->getString() : UString(); 197 195 } 198 196 199 197 inline JSObject* JSValue::getObject() const 200 198 { 201 return JSImmediate::isImmediate(asValue()) ? 0 : asCell()->getObject();199 return isCell() ? asCell()->getObject() : 0; 202 200 } 203 201 204 202 inline CallType JSValue::getCallData(CallData& callData) 205 203 { 206 return JSImmediate::isImmediate(asValue()) ? CallTypeNone : asCell()->getCallData(callData);204 return isCell() ? asCell()->getCallData(callData) : CallTypeNone; 207 205 } 208 206 209 207 inline ConstructType JSValue::getConstructData(ConstructData& constructData) 210 208 { 211 return JSImmediate::isImmediate(asValue()) ? ConstructTypeNone : asCell()->getConstructData(constructData);209 return isCell() ? asCell()->getConstructData(constructData) : ConstructTypeNone; 212 210 } 213 211 214 212 ALWAYS_INLINE bool JSValue::getUInt32(uint32_t& v) const 215 213 { 216 return JSImmediate::isImmediate(asValue()) ? JSImmediate::getUInt32(asValue(), v) : asCell()->getUInt32(v);217 }218 219 ALWAYS_INLINE bool JSValue::getTruncatedInt32(int32_t& v) const220 {221 return JSImmediate::isImmediate(asValue()) ? JSImmediate::getTruncatedInt32(asValue(), v) : asCell()->getTruncatedInt32(v);222 }223 224 inline bool JSValue::getTruncatedUInt32(uint32_t& v) const225 {226 return JSImmediate::isImmediate(asValue()) ? JSImmediate::getTruncatedUInt32(asValue(), v) : asCell()->getTruncatedUInt32(v);214 if (isInt32()) { 215 int32_t i = asInt32(); 216 v = static_cast<uint32_t>(i); 217 return i >= 0; 218 } 219 if (isDouble()) { 220 double d = asDouble(); 221 v = static_cast<uint32_t>(d); 222 return v == d; 223 } 224 return false; 227 225 } 228 226 … … 234 232 inline bool JSValue::marked() const 235 233 { 236 return JSImmediate::isImmediate(asValue()) || asCell()->marked(); 237 } 234 return !isCell() || asCell()->marked(); 235 } 236 237 #if !USE(JSVALUE32_64) 238 ALWAYS_INLINE JSCell* JSValue::asCell() const 239 { 240 ASSERT(isCell()); 241 return m_ptr; 242 } 243 #endif // !USE(JSVALUE32_64) 238 244 239 245 inline JSValue JSValue::toPrimitive(ExecState* exec, PreferredPrimitiveType preferredType) const 240 246 { 241 return JSImmediate::isImmediate(asValue()) ? asValue() : asCell()->toPrimitive(exec, preferredType);247 return isCell() ? asCell()->toPrimitive(exec, preferredType) : asValue(); 242 248 } 243 249 244 250 inline bool JSValue::getPrimitiveNumber(ExecState* exec, double& number, JSValue& value) 245 251 { 246 if (JSImmediate::isImmediate(asValue())) { 247 number = JSImmediate::toDouble(asValue()); 248 value = asValue(); 249 return true; 250 } 251 return asCell()->getPrimitiveNumber(exec, number, value); 252 if (isInt32()) { 253 number = asInt32(); 254 value = *this; 255 return true; 256 } 257 if (isDouble()) { 258 number = asDouble(); 259 value = *this; 260 return true; 261 } 262 if (isCell()) 263 return asCell()->getPrimitiveNumber(exec, number, value); 264 if (isTrue()) { 265 number = 1.0; 266 value = *this; 267 return true; 268 } 269 if (isFalse() || isNull()) { 270 number = 0.0; 271 value = *this; 272 return true; 273 } 274 ASSERT(isUndefined()); 275 number = nonInlineNaN(); 276 value = *this; 277 return true; 252 278 } 253 279 254 280 inline bool JSValue::toBoolean(ExecState* exec) const 255 281 { 256 return JSImmediate::isImmediate(asValue()) ? JSImmediate::toBoolean(asValue()) : asCell()->toBoolean(exec); 282 if (isInt32()) 283 return asInt32() != 0; 284 if (isDouble()) 285 return asDouble() > 0.0 || asDouble() < 0.0; // false for NaN 286 if (isCell()) 287 return asCell()->toBoolean(exec); 288 return isTrue(); // false, null, and undefined all convert to false. 257 289 } 258 290 259 291 ALWAYS_INLINE double JSValue::toNumber(ExecState* exec) const 260 292 { 261 return JSImmediate::isImmediate(asValue()) ? JSImmediate::toDouble(asValue()) : asCell()->toNumber(exec); 293 if (isInt32()) 294 return asInt32(); 295 if (isDouble()) 296 return asDouble(); 297 if (isCell()) 298 return asCell()->toNumber(exec); 299 if (isTrue()) 300 return 1.0; 301 return isUndefined() ? nonInlineNaN() : 0; // null and false both convert to 0. 262 302 } 263 303 264 304 inline UString JSValue::toString(ExecState* exec) const 265 305 { 266 return JSImmediate::isImmediate(asValue()) ? JSImmediate::toString(asValue()) : asCell()->toString(exec); 306 if (isCell()) 307 return asCell()->toString(exec); 308 if (isInt32()) 309 return UString::from(asInt32()); 310 if (isDouble()) 311 return asDouble() == 0.0 ? "0" : UString::from(asDouble()); 312 if (isTrue()) 313 return "true"; 314 if (isFalse()) 315 return "false"; 316 if (isNull()) 317 return "null"; 318 ASSERT(isUndefined()); 319 return "undefined"; 320 } 321 322 inline bool JSValue::needsThisConversion() const 323 { 324 if (UNLIKELY(!isCell())) 325 return true; 326 return asCell()->structure()->typeInfo().needsThisConversion(); 327 } 328 329 inline UString JSValue::toThisString(ExecState* exec) const 330 { 331 return isCell() ? asCell()->toThisString(exec) : toString(exec); 332 } 333 334 inline JSValue JSValue::getJSNumber() 335 { 336 if (isInt32() || isDouble()) 337 return *this; 338 if (isCell()) 339 return asCell()->getJSNumber(); 340 return JSValue(); 267 341 } 268 342 269 343 inline JSObject* JSValue::toObject(ExecState* exec) const 270 344 { 271 return JSImmediate::isImmediate(asValue()) ? JSImmediate::toObject(asValue(), exec) : asCell()->toObject(exec);345 return isCell() ? asCell()->toObject(exec) : toObjectSlowCase(exec); 272 346 } 273 347 274 348 inline JSObject* JSValue::toThisObject(ExecState* exec) const 275 349 { 276 if (UNLIKELY(JSImmediate::isImmediate(asValue()))) 277 return JSImmediate::toThisObject(asValue(), exec); 278 return asCell()->toThisObject(exec); 279 } 280 281 inline bool JSValue::needsThisConversion() const 282 { 283 if (UNLIKELY(JSImmediate::isImmediate(asValue()))) 284 return true; 285 return asCell()->structure()->typeInfo().needsThisConversion(); 286 } 287 288 inline UString JSValue::toThisString(ExecState* exec) const 289 { 290 return JSImmediate::isImmediate(asValue()) ? JSImmediate::toString(asValue()) : asCell()->toThisString(exec); 291 } 292 293 inline JSValue JSValue::getJSNumber() 294 { 295 return JSImmediate::isNumber(asValue()) ? asValue() : JSImmediate::isImmediate(asValue()) ? JSValue() : asCell()->getJSNumber(); 350 return isCell() ? asCell()->toThisObject(exec) : toThisObjectSlowCase(exec); 296 351 } 297 352 -
trunk/JavaScriptCore/runtime/JSFunction.cpp
r44862 r46598 73 73 JSFunction::~JSFunction() 74 74 { 75 #if ENABLE(JIT)76 75 // JIT code for other functions may have had calls linked directly to the code for this function; these links 77 76 // are based on a check for the this pointer value for this JSFunction - which will no longer be valid once 78 77 // this memory is freed and may be reused (potentially for another, different JSFunction). 78 #if ENABLE(JIT_OPTIMIZE_CALL) 79 79 if (m_body && m_body->isGenerated()) 80 80 m_body->generatedBytecode().unlinkCallers(); 81 81 #endif 82 82 if (!isHostFunction()) 83 scopeChain().~ScopeChain(); 83 scopeChain().~ScopeChain(); // FIXME: Don't we need to do this in the interpreter too? 84 84 } 85 85 -
trunk/JavaScriptCore/runtime/JSGlobalData.cpp
r45553 r46598 119 119 , notAnObjectErrorStubStructure(JSNotAnObjectErrorStub::createStructure(jsNull())) 120 120 , notAnObjectStructure(JSNotAnObject::createStructure(jsNull())) 121 #if !USE(ALTERNATE_JSIMMEDIATE)121 #if USE(JSVALUE32) 122 122 , numberStructure(JSNumberCell::createStructure(jsNull())) 123 123 #endif -
trunk/JavaScriptCore/runtime/JSGlobalData.h
r46528 r46598 98 98 RefPtr<Structure> notAnObjectErrorStubStructure; 99 99 RefPtr<Structure> notAnObjectStructure; 100 #if !USE(ALTERNATE_JSIMMEDIATE)100 #if USE(JSVALUE32) 101 101 RefPtr<Structure> numberStructure; 102 102 #endif -
trunk/JavaScriptCore/runtime/JSGlobalObject.h
r45891 r46598 348 348 return m_prototype; 349 349 350 #if USE(JSVALUE32) 350 351 if (typeInfo().type() == StringType) 351 352 return exec->lexicalGlobalObject()->stringPrototype(); … … 353 354 ASSERT(typeInfo().type() == NumberType); 354 355 return exec->lexicalGlobalObject()->numberPrototype(); 356 #else 357 ASSERT(typeInfo().type() == StringType); 358 return exec->lexicalGlobalObject()->stringPrototype(); 359 #endif 355 360 } 356 361 -
trunk/JavaScriptCore/runtime/JSGlobalObjectFunctions.cpp
r44923 r46598 304 304 int32_t radix = args.at(1).toInt32(exec); 305 305 306 if (value.isNumber() && (radix == 0 || radix == 10)) { 307 if (value.isInt32Fast()) 308 return value; 309 double d = value.uncheckedGetNumber(); 306 if (radix != 0 && radix != 10) 307 return jsNumber(exec, parseInt(value.toString(exec), radix)); 308 309 if (value.isInt32()) 310 return value; 311 312 if (value.isDouble()) { 313 double d = value.asDouble(); 310 314 if (isfinite(d)) 311 315 return jsNumber(exec, (d > 0) ? floor(d) : ceil(d)); 312 316 if (isnan(d) || isinf(d)) 313 return jsNaN( &exec->globalData());317 return jsNaN(exec); 314 318 return jsNumber(exec, 0); 315 319 } -
trunk/JavaScriptCore/runtime/JSImmediate.cpp
r43122 r46598 21 21 #include "config.h" 22 22 #include "JSImmediate.h" 23 24 #if !USE(JSVALUE32_64) 23 25 24 26 #include "BooleanConstructor.h" … … 70 72 } 71 73 72 UString JSImmediate::toString(JSValue v) 73 { 74 ASSERT(isImmediate(v)); 75 if (isIntegerNumber(v)) 76 return UString::from(getTruncatedInt32(v)); 77 #if USE(ALTERNATE_JSIMMEDIATE) 78 if (isNumber(v)) { 79 ASSERT(isDoubleNumber(v)); 80 double value = doubleValue(v); 81 if (value == 0.0) // +0.0 or -0.0 82 return "0"; 83 return UString::from(value); 84 } 85 #else 86 ASSERT(!isNumber(v)); 87 #endif 88 if (jsBoolean(false) == v) 89 return "false"; 90 if (jsBoolean(true) == v) 91 return "true"; 92 if (v.isNull()) 93 return "null"; 94 ASSERT(v.isUndefined()); 95 return "undefined"; 96 } 74 } // namespace JSC 97 75 98 NEVER_INLINE double JSImmediate::nonInlineNaN() 99 { 100 return std::numeric_limits<double>::quiet_NaN(); 101 } 102 103 } // namespace JSC 76 #endif // !USE(JSVALUE32_64) -
trunk/JavaScriptCore/runtime/JSImmediate.h
r43153 r46598 23 23 #define JSImmediate_h 24 24 25 #include <wtf/Platform.h> 26 27 #if !USE(JSVALUE32_64) 28 25 29 #include <wtf/Assertions.h> 26 30 #include <wtf/AlwaysInline.h> … … 43 47 class UString; 44 48 45 #if USE( ALTERNATE_JSIMMEDIATE)49 #if USE(JSVALUE64) 46 50 inline intptr_t reinterpretDoubleToIntptr(double value) 47 51 { … … 99 103 /* 100 104 * On 64-bit platforms, we support an alternative encoding form for immediates, if 101 * USE( ALTERNATE_JSIMMEDIATE) is defined. When this format is used, double precision105 * USE(JSVALUE64) is defined. When this format is used, double precision 102 106 * floating point values may also be encoded as JSImmediates. 103 107 * … … 156 160 friend JSValue jsNumber(JSGlobalData* globalData, unsigned long long i); 157 161 158 #if USE( ALTERNATE_JSIMMEDIATE)162 #if USE(JSVALUE64) 159 163 // If all bits in the mask are set, this indicates an integer number, 160 164 // if any but not all are set this value is a double precision number. … … 178 182 static const intptr_t FullTagTypeNull = TagBitTypeOther; 179 183 180 #if USE( ALTERNATE_JSIMMEDIATE)184 #if USE(JSVALUE64) 181 185 static const int32_t IntegerPayloadShift = 0; 182 186 #else … … 201 205 static ALWAYS_INLINE bool isIntegerNumber(JSValue v) 202 206 { 203 #if USE( ALTERNATE_JSIMMEDIATE)207 #if USE(JSVALUE64) 204 208 return (rawValue(v) & TagTypeNumber) == TagTypeNumber; 205 209 #else … … 208 212 } 209 213 210 #if USE( ALTERNATE_JSIMMEDIATE)211 static ALWAYS_INLINE bool isDouble Number(JSValue v)214 #if USE(JSVALUE64) 215 static ALWAYS_INLINE bool isDouble(JSValue v) 212 216 { 213 217 return isNumber(v) && !isIntegerNumber(v); … … 257 261 static ALWAYS_INLINE bool areBothImmediateIntegerNumbers(JSValue v1, JSValue v2) 258 262 { 259 #if USE( ALTERNATE_JSIMMEDIATE)263 #if USE(JSVALUE64) 260 264 return (rawValue(v1) & rawValue(v2) & TagTypeNumber) == TagTypeNumber; 261 265 #else … … 268 272 static JSObject* toObject(JSValue, ExecState*); 269 273 static JSObject* toThisObject(JSValue, ExecState*); 270 static UString toString(JSValue);271 274 272 275 static bool getUInt32(JSValue, uint32_t&); … … 287 290 288 291 private: 289 #if USE( ALTERNATE_JSIMMEDIATE)292 #if USE(JSVALUE64) 290 293 static const int minImmediateInt = ((-INT_MAX) - 1); 291 294 static const int maxImmediateInt = INT_MAX; … … 301 304 } 302 305 303 // With USE( ALTERNATE_JSIMMEDIATE) we want the argument to be zero extended, so the306 // With USE(JSVALUE64) we want the argument to be zero extended, so the 304 307 // integer doesn't interfere with the tag bits in the upper word. In the default encoding, 305 308 // if intptr_t id larger then int32_t we sign extend the value through the upper word. 306 #if USE( ALTERNATE_JSIMMEDIATE)309 #if USE(JSVALUE64) 307 310 static ALWAYS_INLINE JSValue makeInt(uint32_t value) 308 311 #else … … 313 316 } 314 317 315 #if USE( ALTERNATE_JSIMMEDIATE)318 #if USE(JSVALUE64) 316 319 static ALWAYS_INLINE JSValue makeDouble(double value) 317 320 { … … 338 341 static JSValue fromNumberOutsideIntegerRange(T); 339 342 340 #if USE( ALTERNATE_JSIMMEDIATE)343 #if USE(JSVALUE64) 341 344 static ALWAYS_INLINE double doubleValue(JSValue v) 342 345 { … … 364 367 return v.immediateValue(); 365 368 } 366 367 static double nonInlineNaN();368 369 }; 369 370 … … 375 376 ALWAYS_INLINE JSValue JSImmediate::oneImmediate() { return makeInt(1); } 376 377 377 #if USE( ALTERNATE_JSIMMEDIATE)378 #if USE(JSVALUE64) 378 379 inline bool doubleToBoolean(double value) 379 380 { … … 402 403 } 403 404 404 #if USE( ALTERNATE_JSIMMEDIATE)405 #if USE(JSVALUE64) 405 406 template<typename T> 406 407 inline JSValue JSImmediate::fromNumberOutsideIntegerRange(T value) … … 443 444 ALWAYS_INLINE JSValue JSImmediate::from(int i) 444 445 { 445 #if !USE( ALTERNATE_JSIMMEDIATE)446 #if !USE(JSVALUE64) 446 447 if ((i < minImmediateInt) | (i > maxImmediateInt)) 447 448 return fromNumberOutsideIntegerRange(i); … … 509 510 return intValue(v); 510 511 511 #if USE( ALTERNATE_JSIMMEDIATE)512 #if USE(JSVALUE64) 512 513 if (isNumber(v)) { 513 ASSERT(isDouble Number(v));514 ASSERT(isDouble(v)); 514 515 return doubleValue(v); 515 516 } … … 542 543 } 543 544 544 // These are identical logic to the JSValue functions above, and faster than jsNumber(number).toInt32().545 int32_t toInt32(double);546 uint32_t toUInt32(double);547 int32_t toInt32SlowCase(double, bool& ok);548 uint32_t toUInt32SlowCase(double, bool& ok);549 550 545 inline JSValue::JSValue(JSNullTag) 551 546 { … … 576 571 { 577 572 return JSImmediate::isBoolean(asValue()); 573 } 574 575 inline bool JSValue::isTrue() const 576 { 577 return asValue() == JSImmediate::trueImmediate(); 578 } 579 580 inline bool JSValue::isFalse() const 581 { 582 return asValue() == JSImmediate::falseImmediate(); 578 583 } 579 584 … … 593 598 } 594 599 595 ALWAYS_INLINE int32_t JSValue::toInt32(ExecState* exec) const596 {597 int32_t i;598 if (getTruncatedInt32(i))599 return i;600 bool ignored;601 return toInt32SlowCase(toNumber(exec), ignored);602 }603 604 inline uint32_t JSValue::toUInt32(ExecState* exec) const605 {606 uint32_t i;607 if (getTruncatedUInt32(i))608 return i;609 bool ignored;610 return toUInt32SlowCase(toNumber(exec), ignored);611 }612 613 inline int32_t toInt32(double val)614 {615 if (!(val >= -2147483648.0 && val < 2147483648.0)) {616 bool ignored;617 return toInt32SlowCase(val, ignored);618 }619 return static_cast<int32_t>(val);620 }621 622 inline uint32_t toUInt32(double val)623 {624 if (!(val >= 0.0 && val < 4294967296.0)) {625 bool ignored;626 return toUInt32SlowCase(val, ignored);627 }628 return static_cast<uint32_t>(val);629 }630 631 inline int32_t JSValue::toInt32(ExecState* exec, bool& ok) const632 {633 int32_t i;634 if (getTruncatedInt32(i)) {635 ok = true;636 return i;637 }638 return toInt32SlowCase(toNumber(exec), ok);639 }640 641 inline uint32_t JSValue::toUInt32(ExecState* exec, bool& ok) const642 {643 uint32_t i;644 if (getTruncatedUInt32(i)) {645 ok = true;646 return i;647 }648 return toUInt32SlowCase(toNumber(exec), ok);649 }650 651 600 inline bool JSValue::isCell() const 652 601 { … … 654 603 } 655 604 656 inline bool JSValue::isInt32 Fast() const605 inline bool JSValue::isInt32() const 657 606 { 658 607 return JSImmediate::isIntegerNumber(asValue()); 659 608 } 660 609 661 inline int32_t JSValue:: getInt32Fast() const662 { 663 ASSERT(isInt32 Fast());610 inline int32_t JSValue::asInt32() const 611 { 612 ASSERT(isInt32()); 664 613 return JSImmediate::getTruncatedInt32(asValue()); 665 614 } 666 615 667 inline bool JSValue::isUInt32 Fast() const616 inline bool JSValue::isUInt32() const 668 617 { 669 618 return JSImmediate::isPositiveIntegerNumber(asValue()); 670 619 } 671 620 672 inline uint32_t JSValue:: getUInt32Fast() const673 { 674 ASSERT(isUInt32 Fast());621 inline uint32_t JSValue::asUInt32() const 622 { 623 ASSERT(isUInt32()); 675 624 return JSImmediate::getTruncatedUInt32(asValue()); 676 }677 678 inline JSValue JSValue::makeInt32Fast(int32_t i)679 {680 return JSImmediate::from(i);681 }682 683 inline bool JSValue::areBothInt32Fast(JSValue v1, JSValue v2)684 {685 return JSImmediate::areBothImmediateIntegerNumbers(v1, v2);686 625 } 687 626 … … 736 675 { 737 676 ASSERT(canDoFastRshift(val, shift) || canDoFastUrshift(val, shift)); 738 #if USE( ALTERNATE_JSIMMEDIATE)677 #if USE(JSVALUE64) 739 678 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); 740 679 #else … … 784 723 } // namespace JSC 785 724 725 #endif // !USE(JSVALUE32_64) 726 786 727 #endif // JSImmediate_h -
trunk/JavaScriptCore/runtime/JSNumberCell.cpp
r43165 r46598 24 24 #include "JSNumberCell.h" 25 25 26 #if USE(JSVALUE32) 27 26 28 #include "NumberObject.h" 27 29 #include "UString.h" 28 30 29 31 namespace JSC { 30 31 #if !USE(ALTERNATE_JSIMMEDIATE)32 32 33 33 JSValue JSNumberCell::toPrimitive(ExecState*, PreferredPrimitiveType) const … … 83 83 } 84 84 85 bool JSNumberCell::getTruncatedInt32(int32_t& int32) const86 {87 if (!(m_value >= -2147483648.0 && m_value < 2147483648.0))88 return false;89 int32 = static_cast<int32_t>(m_value);90 return true;91 }92 93 bool JSNumberCell::getTruncatedUInt32(uint32_t& uint32) const94 {95 if (!(m_value >= 0.0 && m_value < 4294967296.0))96 return false;97 uint32 = static_cast<uint32_t>(m_value);98 return true;99 }100 101 85 JSValue JSNumberCell::getJSNumber() 102 86 { … … 114 98 } 115 99 116 JSValue jsAPIMangledNumber(ExecState* exec, double d) 117 { 118 return new (exec) JSNumberCell(JSNumberCell::APIMangled, d); 119 } 100 } // namespace JSC 120 101 121 #else 102 #else // USE(JSVALUE32) 103 104 // Keep our exported symbols lists happy. 105 namespace JSC { 106 107 JSValue jsNumberCell(ExecState*, double); 122 108 123 109 JSValue jsNumberCell(ExecState*, double) … … 127 113 } 128 114 129 JSValue jsAPIMangledNumber(ExecState*, double) 130 { 131 ASSERT_NOT_REACHED(); 132 return JSValue(); 133 } 115 } // namespace JSC 134 116 135 #endif 136 137 } // namespace JSC 117 #endif // USE(JSVALUE32) -
trunk/JavaScriptCore/runtime/JSNumberCell.h
r43165 r46598 36 36 extern const double Inf; 37 37 38 #if USE(JSVALUE32) 38 39 JSValue jsNumberCell(ExecState*, double); 39 JSValue jsAPIMangledNumber(ExecState*, double);40 41 #if !USE(ALTERNATE_JSIMMEDIATE)42 40 43 41 class Identifier; … … 54 52 friend JSValue jsNumberCell(JSGlobalData*, double); 55 53 friend JSValue jsNumberCell(ExecState*, double); 56 friend JSValue jsAPIMangledNumber(ExecState*, double); 54 57 55 public: 58 56 double value() const { return m_value; } … … 68 66 virtual JSObject* toThisObject(ExecState*) const; 69 67 virtual JSValue getJSNumber(); 70 71 static const uintptr_t JSAPIMangledMagicNumber = 0xbbadbeef;72 bool isAPIMangledNumber() const { return m_structure == reinterpret_cast<Structure*>(JSAPIMangledMagicNumber); }73 68 74 69 void* operator new(size_t size, ExecState* exec) … … 105 100 } 106 101 107 enum APIMangledTag { APIMangled };108 JSNumberCell(APIMangledTag, double value)109 : JSCell(reinterpret_cast<Structure*>(JSAPIMangledMagicNumber))110 , m_value(value)111 {112 }113 114 102 virtual bool getUInt32(uint32_t&) const; 115 virtual bool getTruncatedInt32(int32_t&) const;116 virtual bool getTruncatedUInt32(uint32_t&) const;117 103 118 104 double m_value; … … 132 118 } 133 119 134 135 120 inline JSValue::JSValue(ExecState* exec, double d) 136 121 { … … 193 178 } 194 179 195 inline JSValue::JSValue(JSGlobalData* globalData, long i) 196 { 197 JSValue v = JSImmediate::from(i); 198 *this = v ? v : jsNumberCell(globalData, i); 199 } 200 201 inline JSValue::JSValue(JSGlobalData* globalData, unsigned long i) 202 { 203 JSValue v = JSImmediate::from(i); 204 *this = v ? v : jsNumberCell(globalData, i); 205 } 206 207 inline JSValue::JSValue(JSGlobalData* globalData, long long i) 208 { 209 JSValue v = JSImmediate::from(i); 210 *this = v ? v : jsNumberCell(globalData, static_cast<double>(i)); 211 } 212 213 inline JSValue::JSValue(JSGlobalData* globalData, unsigned long long i) 214 { 215 JSValue v = JSImmediate::from(i); 216 *this = v ? v : jsNumberCell(globalData, static_cast<double>(i)); 217 } 218 219 inline bool JSValue::isDoubleNumber() const 180 inline bool JSValue::isDouble() const 220 181 { 221 182 return isNumberCell(asValue()); 222 183 } 223 184 224 inline double JSValue:: getDoubleNumber() const185 inline double JSValue::asDouble() const 225 186 { 226 187 return asNumberCell(asValue())->value(); … … 229 190 inline bool JSValue::isNumber() const 230 191 { 231 return JSImmediate::isNumber(asValue()) || isDouble Number();192 return JSImmediate::isNumber(asValue()) || isDouble(); 232 193 } 233 194 … … 235 196 { 236 197 ASSERT(isNumber()); 237 return JSImmediate::isImmediate(asValue()) ? JSImmediate::toDouble(asValue()) : getDoubleNumber(); 238 } 239 240 inline bool JSValue::isAPIMangledNumber() 241 { 242 ASSERT(isNumber()); 243 return JSImmediate::isImmediate(asValue()) ? false : asNumberCell(asValue())->isAPIMangledNumber(); 244 } 245 246 #else 247 198 return JSImmediate::isImmediate(asValue()) ? JSImmediate::toDouble(asValue()) : asDouble(); 199 } 200 201 #endif // USE(JSVALUE32) 202 203 #if USE(JSVALUE64) 248 204 inline JSValue::JSValue(ExecState*, double d) 249 205 { … … 316 272 } 317 273 318 inline JSValue::JSValue(JSGlobalData*, long i) 319 { 320 JSValue v = JSImmediate::from(i); 321 ASSERT(v); 322 *this = v; 323 } 324 325 inline JSValue::JSValue(JSGlobalData*, unsigned long i) 326 { 327 JSValue v = JSImmediate::from(i); 328 ASSERT(v); 329 *this = v; 330 } 331 332 inline JSValue::JSValue(JSGlobalData*, long long i) 333 { 334 JSValue v = JSImmediate::from(static_cast<double>(i)); 335 ASSERT(v); 336 *this = v; 337 } 338 339 inline JSValue::JSValue(JSGlobalData*, unsigned long long i) 340 { 341 JSValue v = JSImmediate::from(static_cast<double>(i)); 342 ASSERT(v); 343 *this = v; 344 } 345 346 inline bool JSValue::isDoubleNumber() const 347 { 348 return JSImmediate::isDoubleNumber(asValue()); 349 } 350 351 inline double JSValue::getDoubleNumber() const 274 inline bool JSValue::isDouble() const 275 { 276 return JSImmediate::isDouble(asValue()); 277 } 278 279 inline double JSValue::asDouble() const 352 280 { 353 281 return JSImmediate::doubleValue(asValue()); … … 365 293 } 366 294 367 #endif 295 #endif // USE(JSVALUE64) 296 297 #if USE(JSVALUE32) || USE(JSVALUE64) 368 298 369 299 inline JSValue::JSValue(ExecState*, char i) … … 391 321 } 392 322 393 inline JSValue::JSValue(JSGlobalData*, char i)394 {395 ASSERT(JSImmediate::from(i));396 *this = JSImmediate::from(i);397 }398 399 inline JSValue::JSValue(JSGlobalData*, unsigned char i)400 {401 ASSERT(JSImmediate::from(i));402 *this = JSImmediate::from(i);403 }404 405 inline JSValue::JSValue(JSGlobalData*, short i)406 {407 ASSERT(JSImmediate::from(i));408 *this = JSImmediate::from(i);409 }410 411 inline JSValue::JSValue(JSGlobalData*, unsigned short i)412 {413 ASSERT(JSImmediate::from(i));414 *this = JSImmediate::from(i);415 }416 417 323 inline JSValue jsNaN(ExecState* exec) 418 324 { … … 434 340 inline bool JSValue::getNumber(double &result) const 435 341 { 436 if (isInt32 Fast())437 result = getInt32Fast();438 else if (LIKELY(isDouble Number()))439 result = getDoubleNumber();342 if (isInt32()) 343 result = asInt32(); 344 else if (LIKELY(isDouble())) 345 result = asDouble(); 440 346 else { 441 347 ASSERT(!isNumber()); … … 445 351 } 446 352 447 inline bool JSValue::numberToInt32(int32_t& arg) 448 { 449 if (isInt32Fast()) 450 arg = getInt32Fast(); 451 else if (LIKELY(isDoubleNumber())) 452 arg = JSC::toInt32(getDoubleNumber()); 453 else { 454 ASSERT(!isNumber()); 455 return false; 456 } 457 return true; 458 } 459 460 inline bool JSValue::numberToUInt32(uint32_t& arg) 461 { 462 if (isUInt32Fast()) 463 arg = getUInt32Fast(); 464 else if (LIKELY(isDoubleNumber())) 465 arg = JSC::toUInt32(getDoubleNumber()); 466 else if (isInt32Fast()) { 467 // FIXME: I think this case can be merged with the uint case; toUInt32SlowCase 468 // on a negative value is equivalent to simple static_casting. 469 bool ignored; 470 arg = toUInt32SlowCase(getInt32Fast(), ignored); 471 } else { 472 ASSERT(!isNumber()); 473 return false; 474 } 475 return true; 476 } 353 #endif // USE(JSVALUE32) || USE(JSVALUE64) 477 354 478 355 } // namespace JSC -
trunk/JavaScriptCore/runtime/JSObject.h
r46528 r46598 34 34 #include "Structure.h" 35 35 #include "JSGlobalData.h" 36 #include <wtf/StdLibExtras.h> 36 37 37 38 namespace JSC { … … 196 197 bool isUsingInlineStorage() const { return m_structure->isUsingInlineStorage(); } 197 198 198 static const size_t inlineStorageCapacity = 3;199 static const size_t inlineStorageCapacity = sizeof(EncodedJSValue) == 2 * sizeof(void*) ? 4 : 3; 199 200 static const size_t nonInlineBaseStorageCapacity = 16; 200 201 … … 226 227 const HashEntry* findPropertyHashEntry(ExecState*, const Identifier& propertyName) const; 227 228 Structure* createInheritorID(); 228 229 RefPtr<Structure> m_inheritorID;230 229 231 230 union { … … 233 232 EncodedJSValue m_inlineStorage[inlineStorageCapacity]; 234 233 }; 234 235 RefPtr<Structure> m_inheritorID; 235 236 }; 236 237 JSObject* asObject(JSValue); 238 239 JSObject* constructEmptyObject(ExecState*); 237 238 JSObject* constructEmptyObject(ExecState*); 240 239 241 240 inline JSObject* asObject(JSValue value) … … 252 251 ASSERT(m_structure->isEmpty()); 253 252 ASSERT(prototype().isNull() || Heap::heap(this) == Heap::heap(prototype())); 253 #if USE(JSVALUE64) || USE(JSVALUE32_64) 254 ASSERT(OBJECT_OFFSETOF(JSObject, m_inlineStorage) % sizeof(double) == 0); 255 #endif 254 256 } 255 257 … … 543 545 { 544 546 if (UNLIKELY(!isCell())) { 545 JSObject* prototype = JSImmediate::prototype(asValue(),exec);547 JSObject* prototype = synthesizePrototype(exec); 546 548 if (propertyName == exec->propertyNames().underscoreProto) 547 549 return prototype; … … 571 573 { 572 574 if (UNLIKELY(!isCell())) { 573 JSObject* prototype = JSImmediate::prototype(asValue(),exec);575 JSObject* prototype = synthesizePrototype(exec); 574 576 if (!prototype->getPropertySlot(exec, propertyName, slot)) 575 577 return jsUndefined(); … … 591 593 { 592 594 if (UNLIKELY(!isCell())) { 593 JSImmediate::toObject(asValue(),exec)->put(exec, propertyName, value, slot);595 synthesizeObject(exec)->put(exec, propertyName, value, slot); 594 596 return; 595 597 } … … 600 602 { 601 603 if (UNLIKELY(!isCell())) { 602 JSImmediate::toObject(asValue(),exec)->put(exec, propertyName, value);604 synthesizeObject(exec)->put(exec, propertyName, value); 603 605 return; 604 606 } -
trunk/JavaScriptCore/runtime/JSString.h
r46528 r46598 24 24 #define JSString_h 25 25 26 #include "CallFrame.h" 26 27 #include "CommonIdentifiers.h" 27 #include "CallFrame.h"28 28 #include "Identifier.h" 29 29 #include "JSNumberCell.h" … … 209 209 inline JSString* JSValue::toThisJSString(ExecState* exec) 210 210 { 211 return JSImmediate::isImmediate(asValue()) ? jsString(exec, JSImmediate::toString(asValue())) : asCell()->toThisJSString(exec);211 return isCell() ? asCell()->toThisJSString(exec) : jsString(exec, toString(exec)); 212 212 } 213 213 -
trunk/JavaScriptCore/runtime/JSValue.cpp
r43122 r46598 24 24 #include "JSValue.h" 25 25 26 #include "BooleanConstructor.h" 27 #include "BooleanPrototype.h" 28 #include "ExceptionHelpers.h" 29 #include "JSGlobalObject.h" 26 30 #include "JSFunction.h" 31 #include "JSNotAnObject.h" 32 #include "NumberObject.h" 27 33 #include <wtf/MathExtras.h> 34 #include <wtf/StringExtras.h> 28 35 29 36 namespace JSC { … … 34 41 double JSValue::toInteger(ExecState* exec) const 35 42 { 36 if (isInt32 Fast())37 return getInt32Fast();43 if (isInt32()) 44 return asInt32(); 38 45 double d = toNumber(exec); 39 46 return isnan(d) ? 0.0 : trunc(d); … … 42 49 double JSValue::toIntegerPreserveNaN(ExecState* exec) const 43 50 { 44 if (isInt32 Fast())45 return getInt32Fast();51 if (isInt32()) 52 return asInt32(); 46 53 return trunc(toNumber(exec)); 47 54 } 55 56 JSObject* JSValue::toObjectSlowCase(ExecState* exec) const 57 { 58 ASSERT(!isCell()); 59 60 if (isInt32() || isDouble()) 61 return constructNumber(exec, asValue()); 62 if (isTrue() || isFalse()) 63 return constructBooleanFromImmediateBoolean(exec, asValue()); 64 ASSERT(isUndefinedOrNull()); 65 JSNotAnObjectErrorStub* exception = createNotAnObjectErrorStub(exec, isNull()); 66 exec->setException(exception); 67 return new (exec) JSNotAnObject(exec, exception); 68 } 69 70 JSObject* JSValue::toThisObjectSlowCase(ExecState* exec) const 71 { 72 ASSERT(!isCell()); 73 74 if (isInt32() || isDouble()) 75 return constructNumber(exec, asValue()); 76 if (isTrue() || isFalse()) 77 return constructBooleanFromImmediateBoolean(exec, asValue()); 78 ASSERT(isUndefinedOrNull()); 79 return exec->globalThisValue(); 80 } 81 82 JSObject* JSValue::synthesizeObject(ExecState* exec) const 83 { 84 ASSERT(!isCell()); 85 if (isNumber()) 86 return constructNumber(exec, asValue()); 87 if (isBoolean()) 88 return constructBooleanFromImmediateBoolean(exec, asValue()); 89 90 JSNotAnObjectErrorStub* exception = createNotAnObjectErrorStub(exec, isNull()); 91 exec->setException(exception); 92 return new (exec) JSNotAnObject(exec, exception); 93 } 94 95 JSObject* JSValue::synthesizePrototype(ExecState* exec) const 96 { 97 ASSERT(!isCell()); 98 if (isNumber()) 99 return exec->lexicalGlobalObject()->numberPrototype(); 100 if (isBoolean()) 101 return exec->lexicalGlobalObject()->booleanPrototype(); 102 103 JSNotAnObjectErrorStub* exception = createNotAnObjectErrorStub(exec, isNull()); 104 exec->setException(exception); 105 return new (exec) JSNotAnObject(exec, exception); 106 } 107 108 #ifndef NDEBUG 109 char* JSValue::description() 110 { 111 static const size_t size = 32; 112 static char description[size]; 113 if (isInt32()) 114 snprintf(description, size, "Int32: %d", asInt32()); 115 else if (isDouble()) 116 snprintf(description, size, "Double: %lf", asDouble()); 117 else if (isCell()) 118 snprintf(description, size, "Cell: %p", asCell()); 119 else if (isTrue()) 120 snprintf(description, size, "True"); 121 else if (isFalse()) 122 snprintf(description, size, "False"); 123 else if (isNull()) 124 snprintf(description, size, "Null"); 125 else { 126 ASSERT(isUndefined()); 127 snprintf(description, size, "Undefined"); 128 } 129 130 return description; 131 } 132 #endif 48 133 49 134 int32_t toInt32SlowCase(double d, bool& ok) … … 85 170 } 86 171 172 NEVER_INLINE double nonInlineNaN() 173 { 174 return std::numeric_limits<double>::quiet_NaN(); 175 } 176 87 177 } // namespace JSC -
trunk/JavaScriptCore/runtime/JSValue.h
r43160 r46598 29 29 #include "CallData.h" 30 30 #include "ConstructData.h" 31 #include <math.h> 32 #include <wtf/AlwaysInline.h> 33 #include <wtf/Assertions.h> 31 34 #include <wtf/HashTraits.h> 32 #include <wtf/ AlwaysInline.h>35 #include <wtf/MathExtras.h> 33 36 34 37 namespace JSC { … … 49 52 enum PreferredPrimitiveType { NoPreference, PreferNumber, PreferString }; 50 53 54 #if USE(JSVALUE32_64) 55 typedef int64_t EncodedJSValue; 56 #else 51 57 typedef void* EncodedJSValue; 58 #endif 59 60 double nonInlineNaN(); 61 int32_t toInt32SlowCase(double, bool& ok); 62 uint32_t toUInt32SlowCase(double, bool& ok); 52 63 53 64 class JSValue { 54 65 friend class JSImmediate; 55 friend struct JSValueHashTraits; 56 57 static JSValue makeImmediate(intptr_t value) 58 { 59 return JSValue(reinterpret_cast<JSCell*>(value)); 60 } 61 62 intptr_t immediateValue() 63 { 64 return reinterpret_cast<intptr_t>(m_ptr); 65 } 66 66 friend struct EncodedJSValueHashTraits; 67 friend class JIT; 68 friend class JITStubs; 69 friend class JITStubCall; 70 67 71 public: 72 static EncodedJSValue encode(JSValue value); 73 static JSValue decode(EncodedJSValue ptr); 74 #if !USE(JSVALUE32_64) 75 private: 76 static JSValue makeImmediate(intptr_t value); 77 intptr_t immediateValue(); 78 public: 79 #endif 68 80 enum JSNullTag { JSNull }; 69 81 enum JSUndefinedTag { JSUndefined }; 70 82 enum JSTrueTag { JSTrue }; 71 83 enum JSFalseTag { JSFalse }; 72 73 static EncodedJSValue encode(JSValue value);74 static JSValue decode(EncodedJSValue ptr);75 84 76 85 JSValue(); … … 95 104 JSValue(ExecState*, unsigned long long); 96 105 JSValue(JSGlobalData*, double); 97 JSValue(JSGlobalData*, char);98 JSValue(JSGlobalData*, unsigned char);99 JSValue(JSGlobalData*, short);100 JSValue(JSGlobalData*, unsigned short);101 106 JSValue(JSGlobalData*, int); 102 107 JSValue(JSGlobalData*, unsigned); 103 JSValue(JSGlobalData*, long);104 JSValue(JSGlobalData*, unsigned long);105 JSValue(JSGlobalData*, long long);106 JSValue(JSGlobalData*, unsigned long long);107 108 108 109 operator bool() const; 109 bool operator==(const JSValue other) const; 110 bool operator!=(const JSValue other) const; 110 bool operator==(const JSValue& other) const; 111 bool operator!=(const JSValue& other) const; 112 113 bool isInt32() const; 114 bool isUInt32() const; 115 bool isDouble() const; 116 bool isTrue() const; 117 bool isFalse() const; 118 119 int32_t asInt32() const; 120 uint32_t asUInt32() const; 121 double asDouble() const; 111 122 112 123 // Querying the type. … … 135 146 // Extracting integer values. 136 147 bool getUInt32(uint32_t&) const; 137 bool getTruncatedInt32(int32_t&) const;138 bool getTruncatedUInt32(uint32_t&) const;139 148 140 149 // Basic conversions. … … 152 161 153 162 // Integer conversions. 154 // 'x.numberToInt32(output)' is equivalent to 'x.isNumber() && x.toInt32(output)'155 163 double toInteger(ExecState*) const; 156 164 double toIntegerPreserveNaN(ExecState*) const; 157 165 int32_t toInt32(ExecState*) const; 158 166 int32_t toInt32(ExecState*, bool& ok) const; 159 bool numberToInt32(int32_t& arg);160 167 uint32_t toUInt32(ExecState*) const; 161 168 uint32_t toUInt32(ExecState*, bool& ok) const; 162 bool numberToUInt32(uint32_t& arg);163 164 // Fast integer operations; these values return results where the value is trivially available165 // in a convenient form, for use in optimizations. No assumptions should be made based on the166 // results of these operations, for example !isInt32Fast() does not necessarily indicate the167 // result of getNumber will not be 0.168 bool isInt32Fast() const;169 int32_t getInt32Fast() const;170 bool isUInt32Fast() const;171 uint32_t getUInt32Fast() const;172 static JSValue makeInt32Fast(int32_t);173 static bool areBothInt32Fast(JSValue, JSValue);174 169 175 170 // Floating point conversions (this is a convenience method for webcore; 176 171 // signle precision float is not a representation used in JS or JSC). 177 172 float toFloat(ExecState* exec) const { return static_cast<float>(toNumber(exec)); } 178 179 // API Mangled Numbers180 bool isAPIMangledNumber();181 173 182 174 // Garbage collection. … … 209 201 JSCell* asCell() const; 210 202 203 #ifndef NDEBUG 204 char* description(); 205 #endif 206 211 207 private: 212 208 enum HashTableDeletedValueTag { HashTableDeletedValue }; … … 214 210 215 211 inline const JSValue asValue() const { return *this; } 216 217 bool isDoubleNumber() const; 218 double getDoubleNumber() const; 219 212 JSObject* toObjectSlowCase(ExecState*) const; 213 JSObject* toThisObjectSlowCase(ExecState*) const; 214 215 enum { Int32Tag = 0xffffffff }; 216 enum { CellTag = 0xfffffffe }; 217 enum { TrueTag = 0xfffffffd }; 218 enum { FalseTag = 0xfffffffc }; 219 enum { NullTag = 0xfffffffb }; 220 enum { UndefinedTag = 0xfffffffa }; 221 enum { DeletedValueTag = 0xfffffff9 }; 222 223 enum { LowestTag = DeletedValueTag }; 224 225 uint32_t tag() const; 226 int32_t payload() const; 227 228 JSObject* synthesizePrototype(ExecState*) const; 229 JSObject* synthesizeObject(ExecState*) const; 230 231 #if USE(JSVALUE32_64) 232 union { 233 EncodedJSValue asEncodedJSValue; 234 double asDouble; 235 #if PLATFORM(BIG_ENDIAN) 236 struct { 237 int32_t tag; 238 int32_t payload; 239 } asBits; 240 #else 241 struct { 242 int32_t payload; 243 int32_t tag; 244 } asBits; 245 #endif 246 } u; 247 #else // USE(JSVALUE32_64) 220 248 JSCell* m_ptr; 249 #endif // USE(JSVALUE32_64) 221 250 }; 222 251 223 struct JSValueHashTraits : HashTraits<EncodedJSValue> { 252 #if USE(JSVALUE32_64) 253 typedef IntHash<EncodedJSValue> EncodedJSValueHash; 254 255 struct EncodedJSValueHashTraits : HashTraits<EncodedJSValue> { 256 static const bool emptyValueIsZero = false; 257 static EncodedJSValue emptyValue() { return JSValue::encode(JSValue()); } 224 258 static void constructDeletedValue(EncodedJSValue& slot) { slot = JSValue::encode(JSValue(JSValue::HashTableDeletedValue)); } 225 259 static bool isDeletedValue(EncodedJSValue value) { return value == JSValue::encode(JSValue(JSValue::HashTableDeletedValue)); } 226 260 }; 261 #else 262 typedef PtrHash<EncodedJSValue> EncodedJSValueHash; 263 264 struct EncodedJSValueHashTraits : HashTraits<EncodedJSValue> { 265 static void constructDeletedValue(EncodedJSValue& slot) { slot = JSValue::encode(JSValue(JSValue::HashTableDeletedValue)); } 266 static bool isDeletedValue(EncodedJSValue value) { return value == JSValue::encode(JSValue(JSValue::HashTableDeletedValue)); } 267 }; 268 #endif 227 269 228 270 // Stand-alone helper functions. … … 302 344 } 303 345 304 ALWAYS_INLINE JSValue jsNumber(JSGlobalData* globalData, chari)346 ALWAYS_INLINE JSValue jsNumber(JSGlobalData* globalData, int i) 305 347 { 306 348 return JSValue(globalData, i); 307 349 } 308 350 309 ALWAYS_INLINE JSValue jsNumber(JSGlobalData* globalData, unsigned char i)310 {311 return JSValue(globalData, i);312 }313 314 ALWAYS_INLINE JSValue jsNumber(JSGlobalData* globalData, short i)315 {316 return JSValue(globalData, i);317 }318 319 ALWAYS_INLINE JSValue jsNumber(JSGlobalData* globalData, unsigned short i)320 {321 return JSValue(globalData, i);322 }323 324 ALWAYS_INLINE JSValue jsNumber(JSGlobalData* globalData, int i)325 {326 return JSValue(globalData, i);327 }328 329 351 ALWAYS_INLINE JSValue jsNumber(JSGlobalData* globalData, unsigned i) 330 {331 return JSValue(globalData, i);332 }333 334 ALWAYS_INLINE JSValue jsNumber(JSGlobalData* globalData, long i)335 {336 return JSValue(globalData, i);337 }338 339 ALWAYS_INLINE JSValue jsNumber(JSGlobalData* globalData, unsigned long i)340 {341 return JSValue(globalData, i);342 }343 344 ALWAYS_INLINE JSValue jsNumber(JSGlobalData* globalData, long long i)345 {346 return JSValue(globalData, i);347 }348 349 ALWAYS_INLINE JSValue jsNumber(JSGlobalData* globalData, unsigned long long i)350 352 { 351 353 return JSValue(globalData, i); … … 358 360 inline bool operator!=(const JSCell* a, const JSValue b) { return JSValue(a) != b; } 359 361 362 inline int32_t toInt32(double val) 363 { 364 if (!(val >= -2147483648.0 && val < 2147483648.0)) { 365 bool ignored; 366 return toInt32SlowCase(val, ignored); 367 } 368 return static_cast<int32_t>(val); 369 } 370 371 inline uint32_t toUInt32(double val) 372 { 373 if (!(val >= 0.0 && val < 4294967296.0)) { 374 bool ignored; 375 return toUInt32SlowCase(val, ignored); 376 } 377 return static_cast<uint32_t>(val); 378 } 379 380 ALWAYS_INLINE int32_t JSValue::toInt32(ExecState* exec) const 381 { 382 if (isInt32()) 383 return asInt32(); 384 bool ignored; 385 return toInt32SlowCase(toNumber(exec), ignored); 386 } 387 388 inline uint32_t JSValue::toUInt32(ExecState* exec) const 389 { 390 if (isUInt32()) 391 return asInt32(); 392 bool ignored; 393 return toUInt32SlowCase(toNumber(exec), ignored); 394 } 395 396 inline int32_t JSValue::toInt32(ExecState* exec, bool& ok) const 397 { 398 if (isInt32()) { 399 ok = true; 400 return asInt32(); 401 } 402 return toInt32SlowCase(toNumber(exec), ok); 403 } 404 405 inline uint32_t JSValue::toUInt32(ExecState* exec, bool& ok) const 406 { 407 if (isUInt32()) { 408 ok = true; 409 return asInt32(); 410 } 411 return toUInt32SlowCase(toNumber(exec), ok); 412 } 413 414 #if USE(JSVALUE32_64) 415 inline JSValue jsNaN(ExecState* exec) 416 { 417 return JSValue(exec, nonInlineNaN()); 418 } 419 360 420 // JSValue member functions. 361 421 inline EncodedJSValue JSValue::encode(JSValue value) 362 422 { 423 return value.u.asEncodedJSValue; 424 } 425 426 inline JSValue JSValue::decode(EncodedJSValue encodedJSValue) 427 { 428 JSValue v; 429 v.u.asEncodedJSValue = encodedJSValue; 430 return v; 431 } 432 433 inline JSValue::JSValue() 434 { 435 u.asBits.tag = CellTag; 436 u.asBits.payload = 0; 437 } 438 439 inline JSValue::JSValue(JSNullTag) 440 { 441 u.asBits.tag = NullTag; 442 u.asBits.payload = 0; 443 } 444 445 inline JSValue::JSValue(JSUndefinedTag) 446 { 447 u.asBits.tag = UndefinedTag; 448 u.asBits.payload = 0; 449 } 450 451 inline JSValue::JSValue(JSTrueTag) 452 { 453 u.asBits.tag = TrueTag; 454 u.asBits.payload = 0; 455 } 456 457 inline JSValue::JSValue(JSFalseTag) 458 { 459 u.asBits.tag = FalseTag; 460 u.asBits.payload = 0; 461 } 462 463 inline JSValue::JSValue(HashTableDeletedValueTag) 464 { 465 u.asBits.tag = DeletedValueTag; 466 u.asBits.payload = 0; 467 } 468 469 inline JSValue::JSValue(JSCell* ptr) 470 { 471 u.asBits.tag = CellTag; 472 u.asBits.payload = reinterpret_cast<int32_t>(ptr); 473 } 474 475 inline JSValue::JSValue(const JSCell* ptr) 476 { 477 u.asBits.tag = CellTag; 478 u.asBits.payload = reinterpret_cast<int32_t>(const_cast<JSCell*>(ptr)); 479 } 480 481 inline JSValue::operator bool() const 482 { 483 return u.asBits.payload || tag() != CellTag; 484 } 485 486 inline bool JSValue::operator==(const JSValue& other) const 487 { 488 return u.asEncodedJSValue == other.u.asEncodedJSValue; 489 } 490 491 inline bool JSValue::operator!=(const JSValue& other) const 492 { 493 return u.asEncodedJSValue != other.u.asEncodedJSValue; 494 } 495 496 inline bool JSValue::isUndefined() const 497 { 498 return tag() == UndefinedTag; 499 } 500 501 inline bool JSValue::isNull() const 502 { 503 return tag() == NullTag; 504 } 505 506 inline bool JSValue::isUndefinedOrNull() const 507 { 508 return isUndefined() || isNull(); 509 } 510 511 inline bool JSValue::isCell() const 512 { 513 return tag() == CellTag; 514 } 515 516 inline bool JSValue::isInt32() const 517 { 518 return tag() == Int32Tag; 519 } 520 521 inline bool JSValue::isUInt32() const 522 { 523 return tag() == Int32Tag && asInt32() > -1; 524 } 525 526 inline bool JSValue::isDouble() const 527 { 528 return tag() < LowestTag; 529 } 530 531 inline bool JSValue::isTrue() const 532 { 533 return tag() == TrueTag; 534 } 535 536 inline bool JSValue::isFalse() const 537 { 538 return tag() == FalseTag; 539 } 540 541 inline uint32_t JSValue::tag() const 542 { 543 return u.asBits.tag; 544 } 545 546 inline int32_t JSValue::payload() const 547 { 548 return u.asBits.payload; 549 } 550 551 inline int32_t JSValue::asInt32() const 552 { 553 ASSERT(isInt32()); 554 return u.asBits.payload; 555 } 556 557 inline uint32_t JSValue::asUInt32() const 558 { 559 ASSERT(isUInt32()); 560 return u.asBits.payload; 561 } 562 563 inline double JSValue::asDouble() const 564 { 565 ASSERT(isDouble()); 566 return u.asDouble; 567 } 568 569 ALWAYS_INLINE JSCell* JSValue::asCell() const 570 { 571 ASSERT(isCell()); 572 return reinterpret_cast<JSCell*>(u.asBits.payload); 573 } 574 575 inline JSValue::JSValue(ExecState* exec, double d) 576 { 577 const int32_t asInt32 = static_cast<int32_t>(d); 578 if (asInt32 != d || (!asInt32 && signbit(d))) { // true for -0.0 579 u.asDouble = d; 580 return; 581 } 582 *this = JSValue(exec, static_cast<int32_t>(d)); 583 } 584 585 inline JSValue::JSValue(ExecState* exec, char i) 586 { 587 *this = JSValue(exec, static_cast<int32_t>(i)); 588 } 589 590 inline JSValue::JSValue(ExecState* exec, unsigned char i) 591 { 592 *this = JSValue(exec, static_cast<int32_t>(i)); 593 } 594 595 inline JSValue::JSValue(ExecState* exec, short i) 596 { 597 *this = JSValue(exec, static_cast<int32_t>(i)); 598 } 599 600 inline JSValue::JSValue(ExecState* exec, unsigned short i) 601 { 602 *this = JSValue(exec, static_cast<int32_t>(i)); 603 } 604 605 inline JSValue::JSValue(ExecState*, int i) 606 { 607 u.asBits.tag = Int32Tag; 608 u.asBits.payload = i; 609 } 610 611 inline JSValue::JSValue(ExecState* exec, unsigned i) 612 { 613 if (static_cast<int32_t>(i) < 0) { 614 *this = JSValue(exec, static_cast<double>(i)); 615 return; 616 } 617 *this = JSValue(exec, static_cast<int32_t>(i)); 618 } 619 620 inline JSValue::JSValue(ExecState* exec, long i) 621 { 622 if (static_cast<int32_t>(i) != i) { 623 *this = JSValue(exec, static_cast<double>(i)); 624 return; 625 } 626 *this = JSValue(exec, static_cast<int32_t>(i)); 627 } 628 629 inline JSValue::JSValue(ExecState* exec, unsigned long i) 630 { 631 if (static_cast<uint32_t>(i) != i) { 632 *this = JSValue(exec, static_cast<double>(i)); 633 return; 634 } 635 *this = JSValue(exec, static_cast<uint32_t>(i)); 636 } 637 638 inline JSValue::JSValue(ExecState* exec, long long i) 639 { 640 if (static_cast<int32_t>(i) != i) { 641 *this = JSValue(exec, static_cast<double>(i)); 642 return; 643 } 644 *this = JSValue(exec, static_cast<int32_t>(i)); 645 } 646 647 inline JSValue::JSValue(ExecState* exec, unsigned long long i) 648 { 649 if (static_cast<uint32_t>(i) != i) { 650 *this = JSValue(exec, static_cast<double>(i)); 651 return; 652 } 653 *this = JSValue(exec, static_cast<uint32_t>(i)); 654 } 655 656 inline JSValue::JSValue(JSGlobalData* globalData, double d) 657 { 658 const int32_t asInt32 = static_cast<int32_t>(d); 659 if (asInt32 != d || (!asInt32 && signbit(d))) { // true for -0.0 660 u.asDouble = d; 661 return; 662 } 663 *this = JSValue(globalData, static_cast<int32_t>(d)); 664 } 665 666 inline JSValue::JSValue(JSGlobalData*, int i) 667 { 668 u.asBits.tag = Int32Tag; 669 u.asBits.payload = i; 670 } 671 672 inline JSValue::JSValue(JSGlobalData* globalData, unsigned i) 673 { 674 if (static_cast<int32_t>(i) < 0) { 675 *this = JSValue(globalData, static_cast<double>(i)); 676 return; 677 } 678 *this = JSValue(globalData, static_cast<int32_t>(i)); 679 } 680 681 inline bool JSValue::isNumber() const 682 { 683 return isInt32() || isDouble(); 684 } 685 686 inline bool JSValue::isBoolean() const 687 { 688 return isTrue() || isFalse(); 689 } 690 691 inline bool JSValue::getBoolean(bool& v) const 692 { 693 if (isTrue()) { 694 v = true; 695 return true; 696 } 697 if (isFalse()) { 698 v = false; 699 return true; 700 } 701 702 return false; 703 } 704 705 inline bool JSValue::getBoolean() const 706 { 707 ASSERT(isBoolean()); 708 return tag() == TrueTag; 709 } 710 711 inline double JSValue::uncheckedGetNumber() const 712 { 713 ASSERT(isNumber()); 714 return isInt32() ? asInt32() : asDouble(); 715 } 716 717 ALWAYS_INLINE JSValue JSValue::toJSNumber(ExecState* exec) const 718 { 719 return isNumber() ? asValue() : jsNumber(exec, this->toNumber(exec)); 720 } 721 722 inline bool JSValue::getNumber(double& result) const 723 { 724 if (isInt32()) { 725 result = asInt32(); 726 return true; 727 } 728 if (isDouble()) { 729 result = asDouble(); 730 return true; 731 } 732 return false; 733 } 734 735 #else // USE(JSVALUE32_64) 736 737 // JSValue member functions. 738 inline EncodedJSValue JSValue::encode(JSValue value) 739 { 363 740 return reinterpret_cast<EncodedJSValue>(value.m_ptr); 364 741 } … … 369 746 } 370 747 748 inline JSValue JSValue::makeImmediate(intptr_t value) 749 { 750 return JSValue(reinterpret_cast<JSCell*>(value)); 751 } 752 753 inline intptr_t JSValue::immediateValue() 754 { 755 return reinterpret_cast<intptr_t>(m_ptr); 756 } 757 371 758 // 0x0 can never occur naturally because it has a tag of 00, indicating a pointer value, but a payload of 0x0, which is in the (invalid) zero page. 372 759 inline JSValue::JSValue() … … 396 783 } 397 784 398 inline bool JSValue::operator==(const JSValue other) const785 inline bool JSValue::operator==(const JSValue& other) const 399 786 { 400 787 return m_ptr == other.m_ptr; 401 788 } 402 789 403 inline bool JSValue::operator!=(const JSValue other) const790 inline bool JSValue::operator!=(const JSValue& other) const 404 791 { 405 792 return m_ptr != other.m_ptr; … … 415 802 return asValue() == jsNull(); 416 803 } 804 #endif // USE(JSVALUE32_64) 417 805 418 806 } // namespace JSC -
trunk/JavaScriptCore/runtime/Operations.h
r44224 r46598 39 39 inline bool JSValue::equal(ExecState* exec, JSValue v1, JSValue v2) 40 40 { 41 if ( JSImmediate::areBothImmediateIntegerNumbers(v1, v2))41 if (v1.isInt32() && v2.isInt32()) 42 42 return v1 == v2; 43 43 … … 47 47 ALWAYS_INLINE bool JSValue::equalSlowCaseInline(ExecState* exec, JSValue v1, JSValue v2) 48 48 { 49 ASSERT(!JSImmediate::areBothImmediateIntegerNumbers(v1, v2));50 51 49 do { 52 50 if (v1.isNumber() && v2.isNumber()) … … 61 59 if (v2.isUndefinedOrNull()) 62 60 return true; 63 if ( JSImmediate::isImmediate(v2))61 if (!v2.isCell()) 64 62 return false; 65 63 return v2.asCell()->structure()->typeInfo().masqueradesAsUndefined(); … … 67 65 68 66 if (v2.isUndefinedOrNull()) { 69 if ( JSImmediate::isImmediate(v1))67 if (!v1.isCell()) 70 68 return false; 71 69 return v1.asCell()->structure()->typeInfo().masqueradesAsUndefined(); … … 79 77 return false; 80 78 v1 = p1; 81 if ( JSImmediate::areBothImmediateIntegerNumbers(v1, v2))79 if (v1.isInt32() && v2.isInt32()) 82 80 return v1 == v2; 83 81 continue; … … 89 87 return false; 90 88 v2 = p2; 91 if ( JSImmediate::areBothImmediateIntegerNumbers(v1, v2))89 if (v1.isInt32() && v2.isInt32()) 92 90 return v1 == v2; 93 91 continue; … … 115 113 ALWAYS_INLINE bool JSValue::strictEqualSlowCaseInline(JSValue v1, JSValue v2) 116 114 { 117 ASSERT( !JSImmediate::isEitherImmediate(v1, v2));115 ASSERT(v1.isCell() && v2.isCell()); 118 116 119 117 if (v1.asCell()->isString() && v2.asCell()->isString()) … … 125 123 inline bool JSValue::strictEqual(JSValue v1, JSValue v2) 126 124 { 127 if ( JSImmediate::areBothImmediateIntegerNumbers(v1, v2))125 if (v1.isInt32() && v2.isInt32()) 128 126 return v1 == v2; 129 127 … … 131 129 return v1.uncheckedGetNumber() == v2.uncheckedGetNumber(); 132 130 133 if ( JSImmediate::isEitherImmediate(v1, v2))131 if (!v1.isCell() || !v2.isCell()) 134 132 return v1 == v2; 135 133 … … 139 137 inline bool jsLess(CallFrame* callFrame, JSValue v1, JSValue v2) 140 138 { 141 if ( JSValue::areBothInt32Fast(v1, v2))142 return v1. getInt32Fast() < v2.getInt32Fast();139 if (v1.isInt32() && v2.isInt32()) 140 return v1.asInt32() < v2.asInt32(); 143 141 144 142 double n1; … … 164 162 inline bool jsLessEq(CallFrame* callFrame, JSValue v1, JSValue v2) 165 163 { 166 if ( JSValue::areBothInt32Fast(v1, v2))167 return v1. getInt32Fast() <= v2.getInt32Fast();164 if (v1.isInt32() && v2.isInt32()) 165 return v1.asInt32() <= v2.asInt32(); 168 166 169 167 double n1; … … 214 212 215 213 if (rightIsNumber & leftIsString) { 216 RefPtr<UString::Rep> value = v2.isInt32 Fast() ?217 concatenate(asString(v1)->value().rep(), v2. getInt32Fast()) :214 RefPtr<UString::Rep> value = v2.isInt32() ? 215 concatenate(asString(v1)->value().rep(), v2.asInt32()) : 218 216 concatenate(asString(v1)->value().rep(), right); 219 217 … … 316 314 if (LIKELY(v.isString())) 317 315 result.append(asString(v)->value()); 318 else if (v.isInt32 Fast())319 result.appendNumeric(v. getInt32Fast());316 else if (v.isInt32()) 317 result.appendNumeric(v.asInt32()); 320 318 else { 321 319 double d; -
trunk/JavaScriptCore/runtime/PropertySlot.h
r44757 r46598 24 24 #include "Identifier.h" 25 25 #include "JSValue.h" 26 #include "JSImmediate.h"27 26 #include "Register.h" 28 27 #include <wtf/Assertions.h> … … 40 39 public: 41 40 PropertySlot() 42 : m_offset(WTF::notFound)43 {44 clear Base();41 { 42 clearBase(); 43 clearOffset(); 45 44 clearValue(); 46 45 } … … 48 47 explicit PropertySlot(const JSValue base) 49 48 : m_slotBase(base) 50 , m_offset(WTF::notFound)51 {49 { 50 clearOffset(); 52 51 clearValue(); 53 52 } … … 83 82 { 84 83 ASSERT(valueSlot); 85 m_getValue = JSC_VALUE_SLOT_MARKER; 86 clearBase(); 84 clearBase(); 85 clearOffset(); 86 m_getValue = JSC_VALUE_SLOT_MARKER; 87 87 m_data.valueSlot = valueSlot; 88 88 } … … 108 108 { 109 109 ASSERT(value); 110 m_getValue = JSC_VALUE_SLOT_MARKER; 111 clearBase(); 110 clearBase(); 111 clearOffset(); 112 m_getValue = JSC_VALUE_SLOT_MARKER; 112 113 m_value = value; 113 114 m_data.valueSlot = &m_value; … … 117 118 { 118 119 ASSERT(registerSlot); 120 clearBase(); 121 clearOffset(); 119 122 m_getValue = JSC_REGISTER_SLOT_MARKER; 120 clearBase();121 123 m_data.registerSlot = registerSlot; 122 124 } … … 148 150 void setUndefined() 149 151 { 150 clearBase();151 152 setValue(jsUndefined()); 152 153 } … … 154 155 JSValue slotBase() const 155 156 { 156 ASSERT(m_slotBase);157 157 return m_slotBase; 158 158 } … … 177 177 m_value = JSValue(); 178 178 #endif 179 } 180 181 void clearOffset() 182 { 183 // Clear offset even in release builds, in case this PropertySlot has been used before. 184 // (For other data members, we don't need to clear anything because reuse would meaningfully overwrite them.) 185 m_offset = WTF::notFound; 179 186 } 180 187 -
trunk/JavaScriptCore/runtime/StringPrototype.cpp
r46180 r46598 377 377 unsigned len = s.size(); 378 378 JSValue a0 = args.at(0); 379 if (a0.isUInt32 Fast()) {380 uint32_t i = a0. getUInt32Fast();379 if (a0.isUInt32()) { 380 uint32_t i = a0.asUInt32(); 381 381 if (i < len) 382 382 return jsSingleCharacterSubstring(exec, s, i); … … 394 394 unsigned len = s.size(); 395 395 JSValue a0 = args.at(0); 396 if (a0.isUInt32 Fast()) {397 uint32_t i = a0. getUInt32Fast();396 if (a0.isUInt32()) { 397 uint32_t i = a0.asUInt32(); 398 398 if (i < len) 399 399 return jsNumber(exec, s.data()[i]); … … 427 427 if (a1.isUndefined()) 428 428 pos = 0; 429 else if (a1.isUInt32 Fast())430 pos = min<uint32_t>(a1. getUInt32Fast(), len);429 else if (a1.isUInt32()) 430 pos = min<uint32_t>(a1.asUInt32(), len); 431 431 else { 432 432 double dpos = a1.toInteger(exec);
Note:
See TracChangeset
for help on using the changeset viewer.