summaryrefslogtreecommitdiffstats
path: root/JavaScriptCore/runtime/Structure.h
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-04-27 16:23:55 +0100
committerSteve Block <steveblock@google.com>2010-04-27 17:07:03 +0100
commit692e5dbf12901edacf14812a6fae25462920af42 (patch)
treed62802373a429e0a9dc093b6046c166b2c514285 /JavaScriptCore/runtime/Structure.h
parente24bea4efef1c414137d36a9778aa4e142e10c7d (diff)
downloadexternal_webkit-692e5dbf12901edacf14812a6fae25462920af42.zip
external_webkit-692e5dbf12901edacf14812a6fae25462920af42.tar.gz
external_webkit-692e5dbf12901edacf14812a6fae25462920af42.tar.bz2
Merge webkit.org at r55033 : Initial merge by git
Change-Id: I98a4af828067cc243ec3dc5e5826154dd88074b5
Diffstat (limited to 'JavaScriptCore/runtime/Structure.h')
-rw-r--r--JavaScriptCore/runtime/Structure.h74
1 files changed, 21 insertions, 53 deletions
diff --git a/JavaScriptCore/runtime/Structure.h b/JavaScriptCore/runtime/Structure.h
index 95cf94c..968443a 100644
--- a/JavaScriptCore/runtime/Structure.h
+++ b/JavaScriptCore/runtime/Structure.h
@@ -179,6 +179,20 @@ namespace JSC {
// Since the number of transitions is always the same as m_offset, we keep the size of Structure down by not storing both.
return m_offset == noOffset ? 0 : m_offset + 1;
}
+
+ typedef std::pair<Structure*, Structure*> Transition;
+ typedef HashMap<StructureTransitionTableHash::Key, Transition, StructureTransitionTableHash, StructureTransitionTableHashTraits> TransitionTable;
+
+ inline bool transitionTableContains(const StructureTransitionTableHash::Key& key, JSCell* specificValue);
+ inline void transitionTableRemove(const StructureTransitionTableHash::Key& key, JSCell* specificValue);
+ inline void transitionTableAdd(const StructureTransitionTableHash::Key& key, Structure* structure, JSCell* specificValue);
+ inline bool transitionTableHasTransition(const StructureTransitionTableHash::Key& key) const;
+ inline Structure* transitionTableGet(const StructureTransitionTableHash::Key& key, JSCell* specificValue) const;
+
+ TransitionTable* transitionTable() const { ASSERT(!m_isUsingSingleSlot); return m_transitions.m_table; }
+ inline void setTransitionTable(TransitionTable* table);
+ Structure* singleTransition() const { ASSERT(m_isUsingSingleSlot); return m_transitions.m_singleTransition; }
+ void setSingleTransition(Structure* structure) { ASSERT(m_isUsingSingleSlot); m_transitions.m_singleTransition = structure; }
bool isValid(ExecState*, StructureChain* cachedPrototypeChain) const;
@@ -199,7 +213,11 @@ namespace JSC {
RefPtr<UString::Rep> m_nameInPrevious;
JSCell* m_specificValueInPrevious;
- StructureTransitionTable table;
+ // 'm_isUsingSingleSlot' indicates whether we are using the single transition optimisation.
+ union {
+ TransitionTable* m_table;
+ Structure* m_singleTransition;
+ } m_transitions;
WeakGCPtr<JSPropertyNameIterator> m_enumerationCache;
@@ -224,7 +242,8 @@ namespace JSC {
#endif
unsigned m_specificFunctionThrashCount : 2;
unsigned m_anonymousSlotCount : 5;
- // 5 free bits
+ unsigned m_isUsingSingleSlot : 1;
+ // 4 free bits
};
inline size_t Structure::get(const Identifier& propertyName)
@@ -271,58 +290,7 @@ namespace JSC {
return m_propertyTable->entries()[entryIndex - 1].offset;
}
}
-
- bool StructureTransitionTable::contains(const StructureTransitionTableHash::Key& key, JSCell* specificValue)
- {
- if (usingSingleTransitionSlot()) {
- Structure* existingTransition = singleTransition();
- return existingTransition && existingTransition->m_nameInPrevious.get() == key.first
- && existingTransition->m_attributesInPrevious == key.second
- && (existingTransition->m_specificValueInPrevious == specificValue || existingTransition->m_specificValueInPrevious == 0);
- }
- TransitionTable::iterator find = table()->find(key);
- if (find == table()->end())
- return false;
-
- return find->second.first || find->second.second->transitionedFor(specificValue);
- }
- Structure* StructureTransitionTable::get(const StructureTransitionTableHash::Key& key, JSCell* specificValue) const
- {
- if (usingSingleTransitionSlot()) {
- Structure* existingTransition = singleTransition();
- if (existingTransition && existingTransition->m_nameInPrevious.get() == key.first
- && existingTransition->m_attributesInPrevious == key.second
- && (existingTransition->m_specificValueInPrevious == specificValue || existingTransition->m_specificValueInPrevious == 0))
- return existingTransition;
- return 0;
- }
-
- Transition transition = table()->get(key);
- if (transition.second && transition.second->transitionedFor(specificValue))
- return transition.second;
- return transition.first;
- }
-
- bool StructureTransitionTable::hasTransition(const StructureTransitionTableHash::Key& key) const
- {
- if (usingSingleTransitionSlot()) {
- Structure* transition = singleTransition();
- return transition && transition->m_nameInPrevious == key.first
- && transition->m_attributesInPrevious == key.second;
- }
- return table()->contains(key);
- }
-
- void StructureTransitionTable::reifySingleTransition()
- {
- ASSERT(usingSingleTransitionSlot());
- Structure* existingTransition = singleTransition();
- TransitionTable* transitionTable = new TransitionTable;
- setTransitionTable(transitionTable);
- if (existingTransition)
- add(std::make_pair(existingTransition->m_nameInPrevious.get(), existingTransition->m_attributesInPrevious), existingTransition, existingTransition->m_specificValueInPrevious);
- }
} // namespace JSC
#endif // Structure_h