Changeset 37714 in webkit
- Timestamp:
- Oct 20, 2008 12:29:28 AM (16 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r37712 r37714 1 2008-10-19 Darin Adler <darin@apple.com> 2 3 Reviewed by Cameron Zwarich. 4 5 - finish https://bugs.webkit.org/show_bug.cgi?id=21732 6 improve performance by eliminating JSValue as a base class for JSCell 7 8 * VM/Machine.cpp: 9 (JSC::Machine::cti_op_call_profiler): Use asFunction. 10 (JSC::Machine::cti_vm_lazyLinkCall): Ditto. 11 (JSC::Machine::cti_op_construct_JSConstructFast): Use asObject. 12 13 * kjs/JSCell.h: Re-sort friend classes. Eliminate inheritance from 14 JSValue. Changed cast in asCell from static_cast to reinterpret_cast. 15 Removed JSValue::getNumber(double&) and one of JSValue::getObject 16 overloads. 17 18 * kjs/JSValue.h: Made the private constructor and destructor both 19 non-virtual and also remove the definitions. This class can never 20 be instantiated or derived. 21 1 22 2008-10-19 Darin Adler <darin@apple.com> 2 23 -
trunk/JavaScriptCore/VM/Machine.cpp
r37706 r37714 4617 4617 4618 4618 ASSERT(*ARG_profilerReference); 4619 (*ARG_profilerReference)->willExecute(ARG_callFrame, static_cast<JSFunction*>(ARG_src1));4619 (*ARG_profilerReference)->willExecute(ARG_callFrame, asFunction(ARG_src1)); 4620 4620 } 4621 4621 … … 4677 4677 CodeBlock* callerCodeBlock = callerCallFrame->codeBlock(); 4678 4678 4679 JSFunction* callee = static_cast<JSFunction*>(ARG_src1);4679 JSFunction* callee = asFunction(ARG_src1); 4680 4680 CodeBlock* codeBlock = &callee->m_body->byteCode(callee->m_scopeChain.node()); 4681 4681 if (!codeBlock->ctiCode) … … 4842 4842 #ifndef NDEBUG 4843 4843 ConstructData constructData; 4844 ASSERT( static_cast<JSFunction*>(ARG_src1)->getConstructData(constructData) == ConstructTypeJS);4844 ASSERT(asFunction(ARG_src1)->getConstructData(constructData) == ConstructTypeJS); 4845 4845 #endif 4846 4846 4847 4847 StructureID* structure; 4848 4848 if (ARG_src2->isObject()) 4849 structure = static_cast<JSObject*>(ARG_src2)->inheritorID();4849 structure = asObject(ARG_src2)->inheritorID(); 4850 4850 else 4851 structure = static_cast<JSFunction*>(ARG_src1)->m_scopeChain.node()->globalObject()->emptyObjectStructure();4851 structure = asFunction(ARG_src1)->m_scopeChain.node()->globalObject()->emptyObjectStructure(); 4852 4852 return new (ARG_globalData) JSObject(structure); 4853 4853 } -
trunk/JavaScriptCore/kjs/JSCell.h
r37712 r37714 30 30 namespace JSC { 31 31 32 class JSCell : public JSValue { 32 class JSCell : Noncopyable { 33 friend class CTI; 34 friend class GetterSetter; 33 35 friend class Heap; 34 friend class GetterSetter;36 friend class JSNumberCell; 35 37 friend class JSObject; 36 38 friend class JSPropertyNameIterator; 39 friend class JSString; 37 40 friend class JSValue; 38 friend class JSNumberCell;39 friend class JSString;40 41 friend class Machine; 41 friend class CTI; 42 42 43 private: 43 44 explicit JSCell(StructureID*); … … 111 112 { 112 113 ASSERT(!JSImmediate::isImmediate(value)); 113 return static_cast<JSCell*>(value.payload());114 return reinterpret_cast<JSCell*>(value.payload()); 114 115 } 115 116 … … 197 198 } 198 199 199 inline bool JSValue::getNumber(double& v) const200 {201 if (JSImmediate::isImmediate(asValue())) {202 v = JSImmediate::toDouble(asValue());203 return true;204 }205 return asCell()->getNumber(v);206 }207 208 200 inline double JSValue::getNumber() const 209 201 { … … 221 213 } 222 214 223 inline JSObject* JSValue::getObject() 224 { 225 return JSImmediate::isImmediate(asValue()) ? 0 : asCell()->getObject(); 226 } 227 228 inline const JSObject* JSValue::getObject() const 215 inline JSObject* JSValue::getObject() const 229 216 { 230 217 return JSImmediate::isImmediate(asValue()) ? 0 : asCell()->getObject(); -
trunk/JavaScriptCore/kjs/JSValue.h
r37712 r37714 36 36 namespace JSC { 37 37 38 class ExecState;39 38 class Identifier; 40 class JSCell;41 class JSObject;42 39 class JSString; 43 40 class PropertySlot; 44 41 class PutPropertySlot; 45 class StructureID;46 42 47 43 struct ClassInfo; … … 50 46 enum PreferredPrimitiveType { NoPreference, PreferNumber, PreferString }; 51 47 52 /**53 * JSValue is the base type for all primitives (Undefined, Null, Boolean,54 * String, Number) and objects in ECMAScript.55 *56 * Note: you should never inherit from JSValue as it is for primitive types57 * only (all of which are provided internally by KJS). Instead, inherit from58 * JSObject.59 */60 48 class JSValue : Noncopyable { 61 friend class JSCell; // so it can derive from this class62 49 private: 63 50 JSValue(); 64 virtual~JSValue();51 ~JSValue(); 65 52 66 53 public: … … 74 61 bool isGetterSetter() const; 75 62 bool isObject() const; 76 bool isObject(const ClassInfo*) const; // FIXME: Merge with inherits.63 bool isObject(const ClassInfo*) const; 77 64 78 65 // Extracting the value. 79 66 bool getBoolean(bool&) const; 80 67 bool getBoolean() const; // false if not a boolean 81 bool getNumber(double&) const;82 68 double getNumber() const; // NaN if not a number 83 69 double uncheckedGetNumber() const; 84 70 bool getString(UString&) const; 85 71 UString getString() const; // null string if not a string 86 JSObject* getObject(); // NULL if not an object 87 const JSObject* getObject() const; // NULL if not an object 72 JSObject* getObject() const; // 0 if not an object 88 73 89 74 CallType getCallData(CallData&); … … 105 90 double toNumber(ExecState*) const; 106 91 JSValuePtr toJSNumber(ExecState*) const; // Fast path for when you expect that the value is an immediate number. 92 107 93 UString toString(ExecState*) const; 108 94 JSObject* toObject(ExecState*) const; … … 160 146 uint32_t toUInt32SlowCase(double, bool& ok); 161 147 162 inline JSValue::JSValue()163 {164 }165 166 inline JSValue::~JSValue()167 {168 }169 170 148 inline JSValuePtr JSValue::asValue() const 171 149 {
Note: See TracChangeset
for help on using the changeset viewer.