Changeset 26899 in webkit for trunk/JavaScriptCore
- Timestamp:
- Oct 22, 2007, 4:36:36 PM (18 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r26897 r26899 1 2007-10-22 Darin Adler <[email protected]> 2 3 Reviewed by Geoff. 4 5 - fix http://bugs.webkit.org/show_bug.cgi?id=15632 6 js1_5/Array/array-001.js test failing 7 8 One of the JavaScriptCore tests was failing; it failed because of 9 my change to NumberImp::getUInt32. The incorrect code I copied was 10 from JSImmediate::getUInt32, and was a pre-existing bug. 11 12 This patch fixes correctness, but will surely slow down SunSpider. 13 We may be able to code this tighter and get the speed back. 14 15 * kjs/JSImmediate.h: 16 (KJS::JSImmediate::getInt32): Renamed from toInt32 to more accurately 17 reflect the fact that this function only returns true if the value is 18 accurate (no fractional part, etc.). Changed code so that it returns 19 false when the value has a fraction. 20 (KJS::JSImmediate::getUInt32): Ditto. 21 22 * kjs/internal.cpp: 23 (KJS::NumberImp::getInt32): Changed code so that it returns false when 24 the value has a fraction. Restores the old behavior. 25 (KJS::NumberImp::getUInt32): Ditto. 26 27 * kjs/value.h: 28 (KJS::JSValue::getInt32): Updated for name change. 29 (KJS::JSValue::getUInt32): Ditto. 30 (KJS::JSValue::toInt32): Ditto. 31 (KJS::JSValue::toUInt32): Ditto. 32 1 33 2007-10-22 Darin Adler <[email protected]> 2 34 -
trunk/JavaScriptCore/kjs/JSImmediate.h
r26893 r26899 88 88 static JSType type(const JSValue*); 89 89 90 static bool toInt32(const JSValue*, int32_t&);91 static bool toUInt32(const JSValue*, uint32_t&);90 static bool getInt32(const JSValue*, int32_t&); 91 static bool getUInt32(const JSValue*, uint32_t&); 92 92 93 93 // It would nice just to use fromDouble() to create these values, but that would prevent them from … … 172 172 } 173 173 174 static bool toInt32(const JSValue* v, int32_t& i)174 static bool getInt32(const JSValue* v, int32_t& i) 175 175 { 176 176 ASSERT(isImmediate(v)); … … 179 179 floatUnion.asBits = static_cast<uint32_t>(unTag(v)); 180 180 float f = floatUnion.asFloat; 181 if (!(f >= -2147483648.0F && f < 2147483648.0F))182 return false;183 181 i = static_cast<int32_t>(f); 184 return isNumber(v) ;185 } 186 187 static bool toUInt32(const JSValue* v, uint32_t& i)182 return isNumber(v) && i == f; 183 } 184 185 static bool getUInt32(const JSValue* v, uint32_t& i) 188 186 { 189 187 ASSERT(isImmediate(v)); … … 192 190 floatUnion.asBits = static_cast<uint32_t>(unTag(v)); 193 191 float f = floatUnion.asFloat; 194 if (!(f >= 0.0F && f < 4294967296.0F))195 return false;196 192 i = static_cast<uint32_t>(f); 197 return isNumber(v) ;193 return isNumber(v) && i == f; 198 194 } 199 195 }; … … 225 221 } 226 222 227 static bool toInt32(const JSValue* v, int32_t& i)223 static bool getInt32(const JSValue* v, int32_t& i) 228 224 { 229 225 double d = toDouble(v); 230 if (!(d >= -2147483648.0 && d < 2147483648.0))231 return false;232 226 i = static_cast<int32_t>(d); 233 return isNumber(v) ;234 } 235 236 static bool toUInt32(const JSValue* v, uint32_t& i)227 return isNumber(v) && i == d; 228 } 229 230 static bool getUInt32(const JSValue* v, uint32_t& i) 237 231 { 238 232 double d = toDouble(v); 239 if (!(d >= 0.0 && d < 4294967296.0))240 return false;241 233 i = static_cast<uint32_t>(d); 242 return isNumber(v) ;234 return isNumber(v) && i == d; 243 235 } 244 236 }; … … 271 263 } 272 264 273 inline bool JSImmediate:: toInt32(const JSValue* v, int32_t& i)274 { 275 return FPBitValues<is32bit, is64bit>:: toInt32(v, i);276 } 277 278 inline bool JSImmediate:: toUInt32(const JSValue* v, uint32_t& i)279 { 280 return FPBitValues<is32bit, is64bit>:: toUInt32(v, i);265 inline bool JSImmediate::getInt32(const JSValue* v, int32_t& i) 266 { 267 return FPBitValues<is32bit, is64bit>::getInt32(v, i); 268 } 269 270 inline bool JSImmediate::getUInt32(const JSValue* v, uint32_t& i) 271 { 272 return FPBitValues<is32bit, is64bit>::getUInt32(v, i); 281 273 } 282 274 -
trunk/JavaScriptCore/kjs/internal.cpp
r26892 r26899 114 114 bool NumberImp::getInt32(int32_t& int32) const 115 115 { 116 if (!(val >= -2147483648.0 && val < 2147483648.0))117 return false;118 116 int32 = static_cast<int32_t>(val); 119 return true;117 return int32 == val; 120 118 } 121 119 122 120 bool NumberImp::getUInt32(uint32_t& uint32) const 123 121 { 124 if (!(val >= 0.0 && val < 4294967296.0))125 return false;126 122 uint32 = static_cast<uint32_t>(val); 127 return true;123 return uint32 == val; 128 124 } 129 125 -
trunk/JavaScriptCore/kjs/value.h
r26892 r26899 335 335 inline bool JSValue::getInt32(int32_t& v) const 336 336 { 337 return JSImmediate::isImmediate(this) ? JSImmediate:: toInt32(this, v) : asCell()->getInt32(v);337 return JSImmediate::isImmediate(this) ? JSImmediate::getInt32(this, v) : asCell()->getInt32(v); 338 338 } 339 339 340 340 inline bool JSValue::getUInt32(uint32_t& v) const 341 341 { 342 return JSImmediate::isImmediate(this) ? JSImmediate:: toUInt32(this, v) : asCell()->getUInt32(v);342 return JSImmediate::isImmediate(this) ? JSImmediate::getUInt32(this, v) : asCell()->getUInt32(v); 343 343 } 344 344 … … 387 387 { 388 388 int32_t i; 389 if (JSImmediate::isImmediate(this) && JSImmediate:: toInt32(this, i))389 if (JSImmediate::isImmediate(this) && JSImmediate::getInt32(this, i)) 390 390 return i; 391 391 bool ok; … … 396 396 { 397 397 uint32_t i; 398 if (JSImmediate::isImmediate(this) && JSImmediate:: toUInt32(this, i))398 if (JSImmediate::isImmediate(this) && JSImmediate::getUInt32(this, i)) 399 399 return i; 400 400 bool ok; … … 405 405 { 406 406 int32_t i; 407 if (JSImmediate::isImmediate(this) && JSImmediate:: toInt32(this, i)) {407 if (JSImmediate::isImmediate(this) && JSImmediate::getInt32(this, i)) { 408 408 ok = true; 409 409 return i; … … 415 415 { 416 416 uint32_t i; 417 if (JSImmediate::isImmediate(this) && JSImmediate:: toUInt32(this, i)) {417 if (JSImmediate::isImmediate(this) && JSImmediate::getUInt32(this, i)) { 418 418 ok = true; 419 419 return i;
Note:
See TracChangeset
for help on using the changeset viewer.