Changeset 35830 in webkit for trunk/JavaScriptCore/VM/Machine.cpp
- Timestamp:
- Aug 18, 2008, 9:39:04 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/VM/Machine.cpp
r35812 r35830 99 99 } 100 100 101 static bool fastIsNumber(JSValue* value, double& arg) { 101 // FIXME: This operation should be called "getNumber", not "isNumber" (as it is in JSValue.h). 102 // FIXME: There's no need to have a "slow" version of this. All versions should be fast. 103 static bool fastIsNumber(JSValue* value, double& arg) 104 { 102 105 if (JSImmediate::isNumber(value)) 103 106 arg = JSImmediate::getTruncatedInt32(value); 104 else if (Heap:: fastIsNumber(static_cast<JSCell*>(value)))107 else if (Heap::isNumber(static_cast<JSCell*>(value))) 105 108 arg = static_cast<JSNumberCell*>(value)->value(); 106 109 else … … 109 112 } 110 113 111 static bool fastToInt32(JSValue* value, int32_t& arg) { 114 // FIXME: Why doesn't JSValue::toInt32 have the Heap::isNumber optimization? 115 static bool fastToInt32(JSValue* value, int32_t& arg) 116 { 112 117 if (JSImmediate::isNumber(value)) 113 118 arg = JSImmediate::getTruncatedInt32(value); 114 else if (Heap:: fastIsNumber(static_cast<JSCell*>(value)))115 arg = static_cast<JSNumberCell*>(value)-> fastToInt32();119 else if (Heap::isNumber(static_cast<JSCell*>(value))) 120 arg = static_cast<JSNumberCell*>(value)->toInt32(); 116 121 else 117 122 return false; … … 119 124 } 120 125 121 static ALWAYS_INLINE bool fastToUInt32(JSValue* value, uint32_t& arg) { 126 static ALWAYS_INLINE bool fastToUInt32(JSValue* value, uint32_t& arg) 127 { 122 128 if (JSImmediate::isNumber(value)) { 123 129 if (JSImmediate::getTruncatedUInt32(value, arg)) … … 126 132 arg = JSValue::toUInt32SlowCase(JSImmediate::getTruncatedInt32(value), scratch); 127 133 return true; 128 } else if (Heap:: fastIsNumber(static_cast<JSCell*>(value)))129 arg = static_cast<JSNumberCell*>(value)-> fastToUInt32();134 } else if (Heap::isNumber(static_cast<JSCell*>(value))) 135 arg = static_cast<JSNumberCell*>(value)->toUInt32(); 130 136 else 131 137 return false; … … 178 184 { 179 185 // exception for the Date exception in defaultValue() 180 JSValue* p1 = v1->toPrimitive(exec , UnspecifiedType);181 JSValue* p2 = v2->toPrimitive(exec , UnspecifiedType);186 JSValue* p1 = v1->toPrimitive(exec); 187 JSValue* p2 = v2->toPrimitive(exec); 182 188 183 189 if (p1->isString() || p2->isString()) { … … 204 210 double left; 205 211 double right; 206 207 212 if (fastIsNumber(v1, left) && fastIsNumber(v2, right)) 208 213 return jsNumber(exec, left + right); 209 214 210 JSType t1 = v1->type(); 211 JSType t2 = v2->type(); 212 const unsigned bothTypes = (t1 << 3) | t2; 213 ASSERT(bothTypes != ((NumberType << 3) | NumberType)); 214 if (bothTypes == ((StringType << 3) | StringType)) { 215 if (v1->isString() && v2->isString()) { 215 216 UString value = static_cast<JSString*>(v1)->value() + static_cast<JSString*>(v2)->value(); 216 217 if (value.isNull()) … … 225 226 static JSValue* jsTypeStringForValue(ExecState* exec, JSValue* v) 226 227 { 227 switch (v->type()) { 228 case UndefinedType: 228 if (v->isUndefined()) 229 return jsString(exec, "undefined"); 230 if (v->isBoolean()) 231 return jsString(exec, "boolean"); 232 if (v->isNumber()) 233 return jsString(exec, "number"); 234 if (v->isString()) 235 return jsString(exec, "string"); 236 if (v->isObject()) { 237 // Return "undefined" for objects that should be treated 238 // as null when doing comparisons. 239 if (static_cast<JSObject*>(v)->masqueradeAsUndefined()) 229 240 return jsString(exec, "undefined"); 230 case NullType: 231 return jsString(exec, "object"); 232 case BooleanType: 233 return jsString(exec, "boolean"); 234 case NumberType: 235 return jsString(exec, "number"); 236 case StringType: 237 return jsString(exec, "string"); 238 default: 239 if (v->isObject()) { 240 // Return "undefined" for objects that should be treated 241 // as null when doing comparisons. 242 if (static_cast<JSObject*>(v)->masqueradeAsUndefined()) 243 return jsString(exec, "undefined"); 244 CallData callData; 245 if (static_cast<JSObject*>(v)->getCallData(callData) != CallTypeNone) 246 return jsString(exec, "function"); 247 } 248 249 return jsString(exec, "object"); 250 } 241 CallData callData; 242 if (static_cast<JSObject*>(v)->getCallData(callData) != CallTypeNone) 243 return jsString(exec, "function"); 244 } 245 return jsString(exec, "object"); 251 246 } 252 247 … … 1554 1549 uint32_t right; 1555 1550 if (JSImmediate::areBothImmediateNumbers(val, shift)) 1556 r[dst] = jsNumber(exec, JSImmediate::getTruncatedInt32(val) << (JSImmediate:: toTruncatedUInt32(shift) & 0x1f));1551 r[dst] = jsNumber(exec, JSImmediate::getTruncatedInt32(val) << (JSImmediate::getTruncatedUInt32(shift) & 0x1f)); 1557 1552 else if (fastToInt32(val, left) && fastToUInt32(shift, right)) 1558 1553 r[dst] = jsNumber(exec, left << (right & 0x1f)); … … 2272 2267 int defaultOffset = (++vPC)->u.operand; 2273 2268 JSValue* scrutinee = r[(++vPC)->u.operand].jsValue(exec); 2274 if ( scrutinee->type() != StringType)2269 if (!scrutinee->isString()) 2275 2270 vPC += defaultOffset; 2276 2271 else { … … 2295 2290 int defaultOffset = (++vPC)->u.operand; 2296 2291 JSValue* scrutinee = r[(++vPC)->u.operand].jsValue(exec); 2297 if ( scrutinee->type() != StringType)2292 if (!scrutinee->isString()) 2298 2293 vPC += defaultOffset; 2299 2294 else
Note:
See TracChangeset
for help on using the changeset viewer.