Changeset 47601 in webkit for trunk/JavaScriptCore/runtime/StructureTransitionTable.h
- Timestamp:
- Aug 20, 2009, 3:36:36 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/runtime/StructureTransitionTable.h
r44076 r47601 1 1 /* 2 * Copyright (C) 2008 Apple Inc. All rights reserved.2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 38 38 39 39 struct StructureTransitionTableHash { 40 typedef std::pair<RefPtr<UString::Rep>, std::pair<unsigned, JSCell*>> Key;40 typedef std::pair<RefPtr<UString::Rep>, unsigned> Key; 41 41 static unsigned hash(const Key& p) 42 42 { … … 54 54 struct StructureTransitionTableHashTraits { 55 55 typedef WTF::HashTraits<RefPtr<UString::Rep> > FirstTraits; 56 typedef WTF::GenericHashTraits<unsigned> SecondFirstTraits; 57 typedef WTF::GenericHashTraits<JSCell*> SecondSecondTraits; 58 typedef std::pair<FirstTraits::TraitType, std::pair<SecondFirstTraits::TraitType, SecondSecondTraits::TraitType> > TraitType; 56 typedef WTF::GenericHashTraits<unsigned> SecondTraits; 57 typedef std::pair<FirstTraits::TraitType, SecondTraits::TraitType > TraitType; 59 58 60 static const bool emptyValueIsZero = FirstTraits::emptyValueIsZero && Second FirstTraits::emptyValueIsZero && SecondSecondTraits::emptyValueIsZero;61 static TraitType emptyValue() { return std::make_pair(FirstTraits::emptyValue(), std::make_pair(SecondFirstTraits::emptyValue(), SecondSecondTraits::emptyValue())); }59 static const bool emptyValueIsZero = FirstTraits::emptyValueIsZero && SecondTraits::emptyValueIsZero; 60 static TraitType emptyValue() { return std::make_pair(FirstTraits::emptyValue(), SecondTraits::emptyValue()); } 62 61 63 static const bool needsDestruction = FirstTraits::needsDestruction || Second FirstTraits::needsDestruction || SecondSecondTraits::needsDestruction;62 static const bool needsDestruction = FirstTraits::needsDestruction || SecondTraits::needsDestruction; 64 63 65 64 static void constructDeletedValue(TraitType& slot) { FirstTraits::constructDeletedValue(slot.first); } … … 67 66 }; 68 67 69 typedef HashMap<StructureTransitionTableHash::Key, Structure*, StructureTransitionTableHash, StructureTransitionTableHashTraits> StructureTransitionTable; 68 class StructureTransitionTable { 69 typedef std::pair<Structure*, Structure*> Transition; 70 typedef HashMap<StructureTransitionTableHash::Key, Transition, StructureTransitionTableHash, StructureTransitionTableHashTraits> TransitionTable; 71 public: 72 inline bool contains(const StructureTransitionTableHash::Key& key, JSCell* specificValue); 73 inline Structure* get(const StructureTransitionTableHash::Key& key, JSCell* specificValue) const; 74 bool hasTransition(const StructureTransitionTableHash::Key& key) 75 { 76 return m_table.contains(key); 77 } 78 void remove(const StructureTransitionTableHash::Key& key, JSCell* specificValue) 79 { 80 TransitionTable::iterator find = m_table.find(key); 81 if (!specificValue) 82 find->second.first = 0; 83 else 84 find->second.second = 0; 85 if (!find->second.first && !find->second.second) 86 m_table.remove(find); 87 } 88 void add(const StructureTransitionTableHash::Key& key, Structure* structure, JSCell* specificValue) 89 { 90 if (!specificValue) { 91 TransitionTable::iterator find = m_table.find(key); 92 if (find == m_table.end()) 93 m_table.add(key, Transition(structure, 0)); 94 else 95 find->second.first = structure; 96 } else { 97 // If we're adding a transition to a specific value, then there cannot be 98 // an existing transition 99 ASSERT(!m_table.contains(key)); 100 m_table.add(key, Transition(0, structure)); 101 } 102 103 104 } 105 private: 106 TransitionTable m_table; 107 }; 70 108 71 109 } // namespace JSC
Note:
See TracChangeset
for help on using the changeset viewer.