Reviewed by Maciej Stachowiak.
Bug 20819: JSValue::isObject() is slow
<https://bugs.webkit.org/show_bug.cgi?id=20819>
Optimize JSCell::isObject() and JSCell::isString() by making them
non-virtual calls that rely on the StructureID type information.
This is a 0.7% speedup on SunSpider and a 1.0% speedup on the V8
benchmark suite.
* JavaScriptCore.exp:
* kjs/JSCell.cpp:
* kjs/JSCell.h:
(JSC::JSCell::isObject):
(JSC::JSCell::isString):
* kjs/JSObject.cpp:
* kjs/JSObject.h:
* kjs/JSString.cpp:
* kjs/JSString.h:
(JSC::JSString::JSString):
* kjs/StructureID.h:
(JSC::StructureID::type):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@36368
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2008-09-12 Cameron Zwarich <cwzwarich@uwaterloo.ca>
+
+ Reviewed by Maciej Stachowiak.
+
+ Bug 20819: JSValue::isObject() is slow
+ <https://bugs.webkit.org/show_bug.cgi?id=20819>
+
+ Optimize JSCell::isObject() and JSCell::isString() by making them
+ non-virtual calls that rely on the StructureID type information.
+
+ This is a 0.7% speedup on SunSpider and a 1.0% speedup on the V8
+ benchmark suite.
+
+ * JavaScriptCore.exp:
+ * kjs/JSCell.cpp:
+ * kjs/JSCell.h:
+ (JSC::JSCell::isObject):
+ (JSC::JSCell::isString):
+ * kjs/JSObject.cpp:
+ * kjs/JSObject.h:
+ * kjs/JSString.cpp:
+ * kjs/JSString.h:
+ (JSC::JSString::JSString):
+ * kjs/StructureID.h:
+ (JSC::StructureID::type):
+
2008-09-11 Stephanie Lewis <slewis@apple.com>
Reviewed by Oliver Hunt.
__ZNK3JSC6JSCell14isGetterSetterEv
__ZNK3JSC6JSCell17getTruncatedInt32ERi
__ZNK3JSC6JSCell18getTruncatedUInt32ERj
-__ZNK3JSC6JSCell8isObjectEv
-__ZNK3JSC6JSCell8isStringEv
__ZNK3JSC6JSCell9classInfoEv
__ZNK3JSC6JSCell9getNumberEv
__ZNK3JSC6JSCell9getStringERNS_7UStringE
__ZNK3JSC8JSObject14toGlobalObjectEPNS_9ExecStateE
__ZNK3JSC8JSObject21getPropertyAttributesEPNS_9ExecStateERKNS_10IdentifierERj
__ZNK3JSC8JSObject21implementsHasInstanceEv
-__ZNK3JSC8JSObject8isObjectEv
__ZNK3JSC8JSObject8toNumberEPNS_9ExecStateE
__ZNK3JSC8JSObject8toObjectEPNS_9ExecStateE
__ZNK3JSC8JSObject8toStringEPNS_9ExecStateE
return 0;
}
-bool JSCell::isString() const
-{
- return false;
-}
-
bool JSCell::isGetterSetter() const
{
return false;
}
-bool JSCell::isObject() const
-{
- return false;
-}
-
} // namespace JSC
public:
// Querying the type.
bool isNumber() const;
- virtual bool isString() const;
+ bool isString() const;
+ bool isObject() const;
virtual bool isGetterSetter() const;
- virtual bool isObject() const;
virtual bool isObject(const ClassInfo*) const;
StructureID* structureID() const;
return Heap::isNumber(const_cast<JSCell*>(this));
}
+ inline bool JSCell::isObject() const
+ {
+ return m_structureID->type() == ObjectType;
+ }
+
+ inline bool JSCell::isString() const
+ {
+ return m_structureID->type() == StringType;
+ }
+
inline StructureID* JSCell::structureID() const
{
return m_structureID;
return m_inheritorID.get();
}
-bool JSObject::isObject() const
-{
- return true;
-}
-
void JSObject::allocatePropertyStorage(size_t oldSize, size_t newSize)
{
JSValue** oldPropertStorage = m_propertyStorage;
bool getOwnPropertySlotForWrite(ExecState*, const Identifier&, PropertySlot&, bool& slotIsWriteable);
private:
- virtual bool isObject() const;
-
const HashEntry* findPropertyHashEntry(ExecState*, const Identifier& propertyName) const;
StructureID* createInheritorID();
return JSString::getOwnPropertySlot(exec, Identifier::from(exec, propertyName), slot);
}
-bool JSString::isString() const
-{
- // FIXME: Change JSCell::isString to a non-virtual implementation like the one in Machine::isJSString.
- return true;
-}
-
JSString* jsString(ExecState* exec, const UString& s)
{
int size = s.size();
: JSCell(0)
{
}
- virtual bool isString() const;
virtual JSValue* toPrimitive(ExecState*, PreferredPrimitiveType) const;
virtual bool getPrimitiveNumber(ExecState*, double& number, JSValue*& value);
bool isDictionary() const { return m_isDictionary; }
+ JSType type() const { return m_type; }
+
JSValue* storedPrototype() const { return m_prototype; }
JSValue* prototypeForLookup(ExecState*);