Changeset 37985 in webkit for trunk/JavaScriptCore
- Timestamp:
- Oct 29, 2008, 4:52:52 PM (17 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 6 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r37981 r37985 1 2008-10-29 Sam Weinig <[email protected]> 2 3 Reviewed by Geoffrey Garen. 4 5 Rename and move the StructureID transition table to its own file. 6 7 * GNUmakefile.am: 8 * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: 9 * JavaScriptCore.xcodeproj/project.pbxproj: 10 * runtime/StructureID.cpp: 11 (JSC::StructureID::addPropertyTransition): 12 * runtime/StructureID.h: 13 (JSC::StructureID::): 14 * runtime/StructureIDTransitionTable.h: Copied from runtime/StructureID.h. 15 (JSC::StructureIDTransitionTableHash::hash): 16 (JSC::StructureIDTransitionTableHash::equal): 17 1 18 2008-10-29 Sam Weinig <[email protected]> 2 19 -
trunk/JavaScriptCore/GNUmakefile.am
r37963 r37985 231 231 JavaScriptCore/runtime/StructureID.cpp \ 232 232 JavaScriptCore/runtime/StructureID.h \ 233 JavaScriptCore/runtime/StructureIDTransitionTable.h \ 233 234 JavaScriptCore/wrec/CharacterClassConstructor.cpp \ 234 235 JavaScriptCore/wrec/CharacterClassConstructor.h \ -
trunk/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj
r37959 r37985 879 879 <File 880 880 RelativePath="..\..\runtime\StructureID.h" 881 > 882 </File> 883 <File 884 RelativePath="..\..\runtime\StructureIDTransitionTable.h" 881 885 > 882 886 </File> -
trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
r37938 r37985 283 283 BC756FC90E2031B200DE7D12 /* JSGlobalObjectFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = BC756FC70E2031B200DE7D12 /* JSGlobalObjectFunctions.h */; }; 284 284 BC7F8FB90E19D1C3008632C0 /* JSNumberCell.h in Headers */ = {isa = PBXBuildFile; fileRef = BC7F8FB80E19D1C3008632C0 /* JSNumberCell.h */; settings = {ATTRIBUTES = (Private, ); }; }; 285 BC9041480EB9250900FE26FA /* StructureIDTransitionTable.h in Headers */ = {isa = PBXBuildFile; fileRef = BC9041470EB9250900FE26FA /* StructureIDTransitionTable.h */; settings = {ATTRIBUTES = (Private, ); }; }; 285 286 BCD202C20E1706A7002C7E82 /* RegExpConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD202BE0E1706A7002C7E82 /* RegExpConstructor.h */; }; 286 287 BCD202C40E1706A7002C7E82 /* RegExpPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD202C00E1706A7002C7E82 /* RegExpPrototype.h */; }; … … 655 656 BC7F8FBA0E19D1EF008632C0 /* JSCell.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCell.cpp; sourceTree = "<group>"; }; 656 657 BC8F3CCF0DAF17BA00577A80 /* ConstructData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConstructData.h; sourceTree = "<group>"; }; 658 BC9041470EB9250900FE26FA /* StructureIDTransitionTable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StructureIDTransitionTable.h; sourceTree = "<group>"; }; 657 659 BC9BB95B0E19680600DF8855 /* InternalFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InternalFunction.cpp; sourceTree = "<group>"; }; 658 660 BCA62DFE0E2826230004F30D /* CallData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CallData.cpp; sourceTree = "<group>"; }; … … 1262 1264 BCDE3AB00E6C82CF001453A7 /* StructureID.cpp */, 1263 1265 BCDE3AB10E6C82CF001453A7 /* StructureID.h */, 1266 BC9041470EB9250900FE26FA /* StructureIDTransitionTable.h */, 1264 1267 ); 1265 1268 path = runtime; … … 1548 1551 869EBCB70E8C6D4A008722CC /* ResultType.h in Headers */, 1549 1552 14F3488F0E95EF8A003648BC /* CollectorHeapIterator.h in Headers */, 1553 BC9041480EB9250900FE26FA /* StructureIDTransitionTable.h in Headers */, 1550 1554 ); 1551 1555 runOnlyForDeploymentPostprocessing = 0; -
trunk/JavaScriptCore/runtime/StructureID.cpp
r37981 r37985 286 286 StructureID* existingTransition = structureID->m_transitions.singleTransition; 287 287 structureID->m_usingSingleTransitionSlot = false; 288 TransitionTable* transitionTable = newTransitionTable;288 StructureIDTransitionTable* transitionTable = new StructureIDTransitionTable; 289 289 structureID->m_transitions.table = transitionTable; 290 290 transitionTable->add(make_pair(existingTransition->m_nameInPrevious, existingTransition->m_attributesInPrevious), existingTransition); -
trunk/JavaScriptCore/runtime/StructureID.h
r37981 r37985 31 31 #include "JSValue.h" 32 32 #include "PropertyMap.h" 33 #include "StructureIDTransitionTable.h" 33 34 #include "TypeInfo.h" 34 35 #include "ustring.h" … … 46 47 class PropertyNameArrayData; 47 48 class StructureIDChain; 48 49 struct TransitionTableHash {50 typedef std::pair<RefPtr<UString::Rep>, unsigned> TransitionTableKey;51 static unsigned hash(const TransitionTableKey& p)52 {53 return p.first->computedHash();54 }55 56 static bool equal(const TransitionTableKey& a, const TransitionTableKey& b)57 {58 return a == b;59 }60 61 static const bool safeToCompareToEmptyOrDeleted = true;62 };63 64 struct TransitionTableHashTraits {65 typedef WTF::HashTraits<RefPtr<UString::Rep> > FirstTraits;66 typedef WTF::GenericHashTraits<unsigned> SecondTraits;67 typedef std::pair<FirstTraits::TraitType, SecondTraits::TraitType> TraitType;68 69 static const bool emptyValueIsZero = FirstTraits::emptyValueIsZero && SecondTraits::emptyValueIsZero;70 static TraitType emptyValue() { return std::make_pair(FirstTraits::emptyValue(), SecondTraits::emptyValue()); }71 72 static const bool needsDestruction = FirstTraits::needsDestruction || SecondTraits::needsDestruction;73 74 static void constructDeletedValue(TraitType& slot) { FirstTraits::constructDeletedValue(slot.first); }75 static bool isDeletedValue(const TraitType& value) { return FirstTraits::isDeletedValue(value.first); }76 };77 49 78 50 class StructureID : public RefCounted<StructureID> { … … 141 113 142 114 private: 143 typedef std::pair<RefPtr<UString::Rep>, unsigned> TransitionTableKey;144 typedef HashMap<TransitionTableKey, StructureID*, TransitionTableHash, TransitionTableHashTraits> TransitionTable;145 146 115 StructureID(JSValue* prototype, const TypeInfo&); 147 116 … … 159 128 union { 160 129 StructureID* singleTransition; 161 TransitionTable* table;130 StructureIDTransitionTable* table; 162 131 } m_transitions; 163 132 -
trunk/JavaScriptCore/runtime/StructureIDTransitionTable.h
r37981 r37985 1 // -*- mode: c++; c-basic-offset: 4 -*-2 1 /* 3 2 * Copyright (C) 2008 Apple Inc. All rights reserved. … … 25 24 */ 26 25 27 #ifndef StructureID _h28 #define StructureID _h26 #ifndef StructureIDTransitionTable_h 27 #define StructureIDTransitionTable_h 29 28 30 #include "JSType.h"31 #include "JSValue.h"32 #include "PropertyMap.h"33 #include "TypeInfo.h"34 29 #include "ustring.h" 35 30 #include <wtf/HashFunctions.h> 31 #include <wtf/HashMap.h> 36 32 #include <wtf/HashTraits.h> 37 #include <wtf/OwnArrayPtr.h> 38 #include <wtf/PassRefPtr.h> 39 #include <wtf/RefCounted.h> 40 41 #define DUMP_STRUCTURE_ID_STATISTICS 0 33 #include <wtf/RefPtr.h> 42 34 43 35 namespace JSC { 44 36 45 class PropertyNameArray; 46 class PropertyNameArrayData; 47 class StructureIDChain; 37 class StructureID; 48 38 49 struct TransitionTableHash {50 typedef std::pair<RefPtr<UString::Rep>, unsigned> TransitionTableKey;51 static unsigned hash(const TransitionTableKey& p)39 struct StructureIDTransitionTableHash { 40 typedef std::pair<RefPtr<UString::Rep>, unsigned> Key; 41 static unsigned hash(const Key& p) 52 42 { 53 43 return p.first->computedHash(); 54 44 } 55 45 56 static bool equal(const TransitionTableKey& a, const TransitionTableKey& b)46 static bool equal(const Key& a, const Key& b) 57 47 { 58 48 return a == b; … … 62 52 }; 63 53 64 struct TransitionTableHashTraits {54 struct StructureIDTransitionTableHashTraits { 65 55 typedef WTF::HashTraits<RefPtr<UString::Rep> > FirstTraits; 66 56 typedef WTF::GenericHashTraits<unsigned> SecondTraits; … … 76 66 }; 77 67 78 class StructureID : public RefCounted<StructureID> { 79 public: 80 friend class CTI; 81 static PassRefPtr<StructureID> create(JSValue* prototype, const TypeInfo& typeInfo) 82 { 83 return adoptRef(new StructureID(prototype, typeInfo)); 84 } 85 86 static void startIgnoringLeaks(); 87 static void stopIgnoringLeaks(); 88 89 #if DUMP_STRUCTURE_ID_STATISTICS 90 static void dumpStatistics(); 91 #endif 92 93 static PassRefPtr<StructureID> changePrototypeTransition(StructureID*, JSValue* prototype); 94 static PassRefPtr<StructureID> addPropertyTransition(StructureID*, const Identifier& propertyName, unsigned attributes, size_t& offset); 95 static PassRefPtr<StructureID> getterSetterTransition(StructureID*); 96 static PassRefPtr<StructureID> toDictionaryTransition(StructureID*); 97 static PassRefPtr<StructureID> fromDictionaryTransition(StructureID*); 98 99 ~StructureID(); 100 101 void mark() 102 { 103 if (!m_prototype->marked()) 104 m_prototype->mark(); 105 } 106 107 // These should be used with caution. 108 size_t addPropertyWithoutTransition(const Identifier& propertyName, unsigned attributes); 109 void setPrototypeWithoutTransition(JSValue* prototype) { m_prototype = prototype; } 110 111 bool isDictionary() const { return m_isDictionary; } 112 113 const TypeInfo& typeInfo() const { return m_typeInfo; } 114 115 // For use when first creating a new structure. 116 TypeInfo& mutableTypeInfo() { return m_typeInfo; } 117 118 JSValue* storedPrototype() const { return m_prototype; } 119 JSValue* prototypeForLookup(ExecState*); 120 121 StructureID* previousID() const { return m_previous.get(); } 122 123 StructureIDChain* createCachedPrototypeChain(); 124 void setCachedPrototypeChain(PassRefPtr<StructureIDChain> cachedPrototypeChain) { m_cachedPrototypeChain = cachedPrototypeChain; } 125 StructureIDChain* cachedPrototypeChain() const { return m_cachedPrototypeChain.get(); } 126 127 const PropertyMap& propertyMap() const { return m_propertyMap; } 128 PropertyMap& propertyMap() { return m_propertyMap; } 129 130 void setCachedTransistionOffset(size_t offset) { m_cachedTransistionOffset = offset; } 131 size_t cachedTransistionOffset() const { return m_cachedTransistionOffset; } 132 133 void growPropertyStorageCapacity(); 134 size_t propertyStorageCapacity() const { return m_propertyStorageCapacity; } 135 136 void getEnumerablePropertyNames(ExecState*, PropertyNameArray&, JSObject*); 137 void clearEnumerationCache(); 138 139 bool hasGetterSetterProperties() const { return m_hasGetterSetterProperties; } 140 void setHasGetterSetterProperties(bool hasGetterSetterProperties) { m_hasGetterSetterProperties = hasGetterSetterProperties; } 141 142 private: 143 typedef std::pair<RefPtr<UString::Rep>, unsigned> TransitionTableKey; 144 typedef HashMap<TransitionTableKey, StructureID*, TransitionTableHash, TransitionTableHashTraits> TransitionTable; 145 146 StructureID(JSValue* prototype, const TypeInfo&); 147 148 static const size_t s_maxTransitionLength = 64; 149 150 TypeInfo m_typeInfo; 151 152 JSValue* m_prototype; 153 RefPtr<StructureIDChain> m_cachedPrototypeChain; 154 155 RefPtr<StructureID> m_previous; 156 UString::Rep* m_nameInPrevious; 157 158 size_t m_transitionCount; 159 union { 160 StructureID* singleTransition; 161 TransitionTable* table; 162 } m_transitions; 163 164 RefPtr<PropertyNameArrayData> m_cachedPropertyNameArrayData; 165 166 PropertyMap m_propertyMap; 167 size_t m_propertyStorageCapacity; 168 169 size_t m_cachedTransistionOffset; 170 171 bool m_isDictionary : 1; 172 bool m_hasGetterSetterProperties : 1; 173 bool m_usingSingleTransitionSlot : 1; 174 unsigned m_attributesInPrevious : 5; 175 }; 176 177 class StructureIDChain : public RefCounted<StructureIDChain> { 178 public: 179 static PassRefPtr<StructureIDChain> create(StructureID* structureID) { return adoptRef(new StructureIDChain(structureID)); } 180 181 RefPtr<StructureID>* head() { return m_vector.get(); } 182 183 private: 184 StructureIDChain(StructureID* structureID); 185 186 OwnArrayPtr<RefPtr<StructureID> > m_vector; 187 }; 188 189 bool structureIDChainsAreEqual(StructureIDChain*, StructureIDChain*); 68 typedef HashMap<StructureIDTransitionTableHash::Key, StructureID*, StructureIDTransitionTableHash, StructureIDTransitionTableHashTraits> StructureIDTransitionTable; 190 69 191 70 } // namespace JSC 192 71 193 #endif // StructureID _h72 #endif // StructureIDTransitionTable_h
Note:
See TracChangeset
for help on using the changeset viewer.