Changeset 95466 in webkit
- Timestamp:
- Sep 19, 2011 1:32:52 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r95455 r95466 1 2011-09-19 Mark Hahnenberg <mhahnenberg@apple.com> 2 3 Remove toPrimitive from JSCell 4 https://bugs.webkit.org/show_bug.cgi?id=67875 5 6 Reviewed by Geoffrey Garen. 7 8 Part of the refactoring process to un-virtualize JSCell. We move 9 all of the implicit functionality provided by the virtual toPrimitive method 10 in JSCell to be explicit in JSValue::toPrimitive and JSCell:toPrimitive while 11 also de-virtualizing JSCell::toPrimitive. 12 13 * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: 14 * runtime/JSCell.cpp: 15 (JSC::JSCell::toPrimitive): 16 * runtime/JSCell.h: 17 18 We replace JSNotAnObject::toPrimitive with defaultValue, which it overrides from 19 JSObject. This pushes the virtual method further down, enabling us to get rid 20 of the virtual call in JSCell. Eventually we'll probably have to deal with this 21 again, but we'll cross that bridge when we come to it. 22 * runtime/JSNotAnObject.cpp: 23 (JSC::JSNotAnObject::defaultValue): 24 * runtime/JSNotAnObject.h: 25 * runtime/JSObject.h: 26 * runtime/JSString.h: 27 (JSC::JSValue::toPrimitive): 28 1 29 2011-09-19 Oliver Hunt <oliver@apple.com> 2 30 -
trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def
r95450 r95466 357 357 ?toObject@JSObject@JSC@@UBEPAV12@PAVExecState@2@PAVJSGlobalObject@2@@Z 358 358 ?toObjectSlowCase@JSValue@JSC@@ABEPAVJSObject@2@PAVExecState@2@PAVJSGlobalObject@2@@Z 359 ?toPrimitive@JSCell@JSC@@UBE?AVJSValue@2@PAVExecState@2@W4PreferredPrimitiveType@2@@Z360 ?toPrimitive@JSString@JSC@@EBE?AVJSValue@2@PAVExecState@2@W4PreferredPrimitiveType@2@@Z361 359 ?toStrictThisObject@JSObject@JSC@@UBE?AVJSValue@2@PAVExecState@2@@Z 362 360 ?toString@JSCell@JSC@@UBE?AVUString@2@PAVExecState@2@@Z -
trunk/Source/JavaScriptCore/runtime/JSCell.cpp
r95229 r95466 30 30 31 31 namespace JSC { 32 33 JSValue JSCell::toPrimitive(ExecState* exec, PreferredPrimitiveType preferredType) const 34 { 35 if (isString()) 36 return static_cast<const JSString*>(this)->toPrimitive(exec, preferredType); 37 return static_cast<const JSObject*>(this)->toPrimitive(exec, preferredType); 38 } 32 39 33 40 bool JSCell::getString(ExecState* exec, UString&stringValue) const … … 118 125 } 119 126 120 JSValue JSCell::toPrimitive(ExecState*, PreferredPrimitiveType) const121 {122 ASSERT_NOT_REACHED();123 return JSValue();124 }125 126 127 bool JSCell::getPrimitiveNumber(ExecState*, double&, JSValue&) 127 128 { -
trunk/Source/JavaScriptCore/runtime/JSCell.h
r95453 r95466 103 103 104 104 // Basic conversions. 105 virtualJSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;105 JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const; 106 106 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue&); 107 107 virtual bool toBoolean(ExecState*) const; … … 284 284 } 285 285 return false; 286 }287 288 inline JSValue JSValue::toPrimitive(ExecState* exec, PreferredPrimitiveType preferredType) const289 {290 return isCell() ? asCell()->toPrimitive(exec, preferredType) : asValue();291 286 } 292 287 -
trunk/Source/JavaScriptCore/runtime/JSNotAnObject.cpp
r95229 r95466 38 38 39 39 // JSValue methods 40 JSValue JSNotAnObject:: toPrimitive(ExecState* exec, PreferredPrimitiveType) const40 JSValue JSNotAnObject::defaultValue(ExecState* exec, PreferredPrimitiveType) const 41 41 { 42 42 ASSERT_UNUSED(exec, exec->hadException()); -
trunk/Source/JavaScriptCore/runtime/JSNotAnObject.h
r95229 r95466 64 64 65 65 // JSValue methods 66 virtual JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;66 virtual JSValue defaultValue(ExecState*, PreferredPrimitiveType) const; 67 67 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue&); 68 68 virtual bool toBoolean(ExecState*) const; -
trunk/Source/JavaScriptCore/runtime/JSObject.h
r95447 r95466 133 133 virtual void getOwnPropertyNames(ExecState*, PropertyNameArray&, EnumerationMode mode = ExcludeDontEnumProperties); 134 134 135 virtualJSValue toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const;135 JSValue toPrimitive(ExecState*, PreferredPrimitiveType = NoPreference) const; 136 136 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue& value); 137 137 virtual bool toBoolean(ExecState*) const; -
trunk/Source/JavaScriptCore/runtime/JSString.h
r95229 r95466 427 427 unsigned length() { return m_length; } 428 428 429 JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const; 429 430 bool getStringPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); 430 431 bool getStringPropertySlot(ExecState*, unsigned propertyName, PropertySlot&); … … 493 494 } 494 495 495 virtual JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const;496 496 virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue& value); 497 497 virtual bool toBoolean(ExecState*) const; … … 682 682 683 683 // --- JSValue inlines ---------------------------- 684 685 inline JSValue JSValue::toPrimitive(ExecState* exec, PreferredPrimitiveType preferredType) const 686 { 687 if (!isCell()) 688 return asValue(); 689 return asCell()->toPrimitive(exec, preferredType); 690 } 684 691 685 692 inline UString JSValue::toString(ExecState* exec) const
Note: See TracChangeset
for help on using the changeset viewer.