Changeset 95167 in webkit
- Timestamp:
- Sep 14, 2011 10:15:16 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r95163 r95167 1 2011-09-14 Mark Hahnenberg <mhahnenberg@apple.com> 2 3 Make JSCell::toBoolean non-virtual 4 https://bugs.webkit.org/show_bug.cgi?id=67727 5 6 Reviewed by Sam Weinig. 7 8 JSCell::toBoolean now manually performs the toBoolean check for objects and strings (where 9 before it was simply virtual and would crash if its implementation was called). 10 Its descendants in JSObject and JSString have also been made non-virtual. JSCell now 11 explicitly covers all cases of toBoolean, so having a virtual implementation of 12 JSCell::toBoolean is no longer necessary. This is part of a larger process of un-virtualizing JSCell. 13 14 * JavaScriptCore.exp: 15 * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: 16 * runtime/JSCell.cpp: 17 * runtime/JSCell.h: 18 * runtime/JSNotAnObject.cpp: 19 * runtime/JSNotAnObject.h: 20 * runtime/JSObject.h: 21 * runtime/JSString.h: 22 (JSC::JSCell::toBoolean): 23 (JSC::JSValue::toBoolean): 24 * runtime/StringObjectThatMasqueradesAsUndefined.h: 25 1 26 2011-09-14 Alexis Menard <alexis.menard@openbossa.org> 2 27 -
trunk/Source/JavaScriptCore/JavaScriptCore.exp
r94981 r95167 564 564 __ZNK3JSC6JSCell9getStringEPNS_9ExecStateE 565 565 __ZNK3JSC6JSCell9getStringEPNS_9ExecStateERNS_7UStringE 566 __ZNK3JSC6JSCell9toBooleanEPNS_9ExecStateE567 566 __ZNK3JSC7ArgList8getSliceEiRS0_ 568 567 __ZNK3JSC7JSArray12subclassDataEv … … 586 585 __ZNK3JSC8JSObject9toBooleanEPNS_9ExecStateE 587 586 __ZNK3JSC8JSString11resolveRopeEPNS_9ExecStateE 587 __ZNK3JSC8JSString9toBooleanEPNS_9ExecStateE 588 588 __ZNK3JSC9HashTable11createTableEPNS_12JSGlobalDataE 589 589 __ZNK3JSC9HashTable11deleteTableEv -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
r94981 r95167 348 348 ?tlsKeyCount@WTF@@YAAAJXZ 349 349 ?tlsKeys@WTF@@YAPAKXZ 350 ?toBoolean@JSCell@JSC@@UBE_NPAVExecState@2@@Z351 ?toBoolean@JSObject@JSC@@UBE_NPAVExecState@2@@Z352 ?toBoolean@JSString@JSC@@EBE_NPAVExecState@2@@Z353 350 ?toInt32@JSC@@YAHN@Z 354 351 ?toInteger@JSValue@JSC@@QBENPAVExecState@2@@Z -
trunk/Source/JavaScriptCore/runtime/JSCell.cpp
r94930 r95167 130 130 } 131 131 132 bool JSCell::toBoolean(ExecState*) const133 {134 ASSERT_NOT_REACHED();135 return false;136 }137 138 132 double JSCell::toNumber(ExecState*) const 139 133 { -
trunk/Source/JavaScriptCore/runtime/JSCell.h
r94932 r95167 106 106 virtual JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const; 107 107 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue&); 108 virtualbool toBoolean(ExecState*) const;108 bool toBoolean(ExecState*) const; 109 109 virtual double toNumber(ExecState*) const; 110 110 virtual UString toString(ExecState*) const; … … 317 317 } 318 318 319 inline bool JSValue::toBoolean(ExecState* exec) const320 {321 if (isInt32())322 return asInt32() != 0;323 if (isDouble())324 return asDouble() > 0.0 || asDouble() < 0.0; // false for NaN325 if (isCell())326 return asCell()->toBoolean(exec);327 return isTrue(); // false, null, and undefined all convert to false.328 }329 330 319 ALWAYS_INLINE double JSValue::toNumber(ExecState* exec) const 331 320 { -
trunk/Source/JavaScriptCore/runtime/JSNotAnObject.cpp
r88587 r95167 45 45 46 46 bool JSNotAnObject::getPrimitiveNumber(ExecState* exec, double&, JSValue&) 47 {48 ASSERT_UNUSED(exec, exec->hadException());49 return false;50 }51 52 bool JSNotAnObject::toBoolean(ExecState* exec) const53 47 { 54 48 ASSERT_UNUSED(exec, exec->hadException()); -
trunk/Source/JavaScriptCore/runtime/JSNotAnObject.h
r94929 r95167 66 66 virtual JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const; 67 67 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue&); 68 virtual bool toBoolean(ExecState*) const;69 68 virtual double toNumber(ExecState*) const; 70 69 virtual UString toString(ExecState*) const; -
trunk/Source/JavaScriptCore/runtime/JSObject.h
r95115 r95167 135 135 virtual JSValue toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const; 136 136 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue& value); 137 virtualbool toBoolean(ExecState*) const;137 bool toBoolean(ExecState*) const; 138 138 virtual double toNumber(ExecState*) const; 139 139 virtual UString toString(ExecState*) const; -
trunk/Source/JavaScriptCore/runtime/JSString.h
r94929 r95167 63 63 public: 64 64 friend class JIT; 65 friend class JSCell; 65 66 friend class JSGlobalData; 67 friend class JSValue; 66 68 friend class SpecializedThunkJIT; 67 69 friend struct ThunkHelpers; … … 495 497 virtual JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const; 496 498 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue& value); 497 virtualbool toBoolean(ExecState*) const;499 bool toBoolean(ExecState*) const; 498 500 virtual double toNumber(ExecState*) const; 499 501 virtual JSObject* toObject(ExecState*, JSGlobalObject*) const; … … 681 683 inline bool isJSString(JSGlobalData* globalData, JSValue v) { return v.isCell() && v.asCell()->vptr() == globalData->jsStringVPtr; } 682 684 685 inline bool JSCell::toBoolean(ExecState* exec) const 686 { 687 if (isString()) 688 return static_cast<const JSString*>(this)->toBoolean(exec); 689 return !structure()->typeInfo().masqueradesAsUndefined(); 690 } 691 683 692 // --- JSValue inlines ---------------------------- 693 694 inline bool JSValue::toBoolean(ExecState* exec) const 695 { 696 if (isInt32()) 697 return asInt32(); 698 if (isDouble()) 699 return asDouble() > 0.0 || asDouble() < 0.0; // false for NaN 700 if (isCell()) 701 return asCell()->toBoolean(exec); 702 return isTrue(); // false, null, and undefined all convert to false. 703 } 684 704 685 705 inline UString JSValue::toString(ExecState* exec) const -
trunk/Source/JavaScriptCore/runtime/StringObjectThatMasqueradesAsUndefined.h
r95108 r95167 54 54 55 55 static const unsigned StructureFlags = OverridesGetOwnPropertySlot | MasqueradesAsUndefined | OverridesGetPropertyNames | StringObject::StructureFlags; 56 57 virtual bool toBoolean(ExecState*) const { return false; }58 56 }; 59 57
Note: See TracChangeset
for help on using the changeset viewer.