2008-09-10 Maciej Stachowiak <mjs@apple.com>
Reviewed by Oliver.
- enable polymorphic inline caching of properties of primitives
1.012x speedup on SunSpider.
We create special structure IDs for JSString and
JSNumberCell. Unlike normal structure IDs, these cannot hold the
true prototype. Due to JS autoboxing semantics, the prototype used
when looking up string or number properties depends on the lexical
global object of the call site, not the creation site. Thus we
enable StructureIDs to handle this quirk for primitives.
Everything else should be straightforward.
* VM/CTI.cpp:
(JSC::CTI::privateCompileGetByIdProto):
(JSC::CTI::privateCompileGetByIdChain):
* VM/CTI.h:
(JSC::CTI::compileGetByIdProto):
(JSC::CTI::compileGetByIdChain):
* VM/JSPropertyNameIterator.h:
(JSC::JSPropertyNameIterator::JSPropertyNameIterator):
* VM/Machine.cpp:
(JSC::Machine::Machine):
(JSC::cachePrototypeChain):
(JSC::Machine::tryCachePutByID):
(JSC::Machine::tryCacheGetByID):
(JSC::Machine::privateExecute):
(JSC::Machine::tryCTICachePutByID):
(JSC::Machine::tryCTICacheGetByID):
* kjs/GetterSetter.h:
(JSC::GetterSetter::GetterSetter):
* kjs/JSCell.h:
* kjs/JSGlobalData.cpp:
(JSC::JSGlobalData::JSGlobalData):
* kjs/JSGlobalData.h:
* kjs/JSGlobalObject.h:
(JSC::StructureID::prototypeForLookup):
* kjs/JSNumberCell.h:
(JSC::JSNumberCell::JSNumberCell):
(JSC::jsNumberCell):
* kjs/JSObject.h:
(JSC::JSObject::prototype):
* kjs/JSString.cpp:
(JSC::jsString):
(JSC::jsSubstring):
(JSC::jsOwnedString):
* kjs/JSString.h:
(JSC::JSString::JSString):
(JSC::JSString::):
(JSC::jsSingleCharacterString):
(JSC::jsSingleCharacterSubstring):
(JSC::jsNontrivialString):
* kjs/SmallStrings.cpp:
(JSC::SmallStrings::createEmptyString):
(JSC::SmallStrings::createSingleCharacterString):
* kjs/StructureID.cpp:
(JSC::StructureID::StructureID):
(JSC::StructureID::addPropertyTransition):
(JSC::StructureID::getterSetterTransition):
(JSC::StructureIDChain::StructureIDChain):
* kjs/StructureID.h:
(JSC::StructureID::create):
(JSC::StructureID::storedPrototype):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@36316 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/kjs/StructureID.h b/JavaScriptCore/kjs/StructureID.h
index e2a4cca..67ab4b4 100644
--- a/JavaScriptCore/kjs/StructureID.h
+++ b/JavaScriptCore/kjs/StructureID.h
@@ -26,6 +26,7 @@
#ifndef StructureID_h
#define StructureID_h
+#include "JSType.h"
#include "JSValue.h"
#include "PropertyMap.h"
#include "ustring.h"
@@ -71,9 +72,9 @@
class StructureID : public RefCounted<StructureID> {
public:
- static PassRefPtr<StructureID> create(JSValue* prototype)
+ static PassRefPtr<StructureID> create(JSValue* prototype, JSType type = ObjectType)
{
- return adoptRef(new StructureID(prototype));
+ return adoptRef(new StructureID(prototype, type));
}
static PassRefPtr<StructureID> changePrototypeTransition(StructureID*, JSValue* prototype);
@@ -92,8 +93,9 @@
bool isDictionary() const { return m_isDictionary; }
- JSValue* prototype() const { return m_prototype; }
-
+ JSValue* storedPrototype() const { return m_prototype; }
+ JSValue* prototypeForLookup(ExecState*);
+
void setCachedPrototypeChain(PassRefPtr<StructureIDChain> cachedPrototypeChain) { m_cachedPrototypeChain = cachedPrototypeChain; }
StructureIDChain* cachedPrototypeChain() const { return m_cachedPrototypeChain.get(); }
@@ -104,11 +106,12 @@
typedef std::pair<RefPtr<UString::Rep>, unsigned> TransitionTableKey;
typedef HashMap<TransitionTableKey, StructureID*, TransitionTableHash, TransitionTableHashTraits> TransitionTable;
- StructureID(JSValue* prototype);
+ StructureID(JSValue* prototype, JSType);
static const size_t s_maxTransitionLength = 64;
bool m_isDictionary;
+ JSType m_type;
JSValue* m_prototype;
RefPtr<StructureIDChain> m_cachedPrototypeChain;