Changeset 37985 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Oct 29, 2008, 4:52:52 PM (17 years ago)
Author:
[email protected]
Message:

2008-10-29 Sam Weinig <[email protected]>

Reviewed by Geoffrey Garen.

Rename and move the StructureID transition table to its own file.

  • GNUmakefile.am:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • runtime/StructureID.cpp: (JSC::StructureID::addPropertyTransition):
  • runtime/StructureID.h: (JSC::StructureID::):
  • runtime/StructureIDTransitionTable.h: Copied from runtime/StructureID.h. (JSC::StructureIDTransitionTableHash::hash): (JSC::StructureIDTransitionTableHash::equal):
Location:
trunk/JavaScriptCore
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r37981 r37985  
     12008-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
    1182008-10-29  Sam Weinig  <[email protected]>
    219
  • trunk/JavaScriptCore/GNUmakefile.am

    r37963 r37985  
    231231        JavaScriptCore/runtime/StructureID.cpp \
    232232        JavaScriptCore/runtime/StructureID.h \
     233        JavaScriptCore/runtime/StructureIDTransitionTable.h \
    233234        JavaScriptCore/wrec/CharacterClassConstructor.cpp \
    234235        JavaScriptCore/wrec/CharacterClassConstructor.h \
  • trunk/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj

    r37959 r37985  
    879879                        <File
    880880                                RelativePath="..\..\runtime\StructureID.h"
     881                                >
     882                        </File>
     883                        <File
     884                                RelativePath="..\..\runtime\StructureIDTransitionTable.h"
    881885                                >
    882886                        </File>
  • trunk/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r37938 r37985  
    283283                BC756FC90E2031B200DE7D12 /* JSGlobalObjectFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = BC756FC70E2031B200DE7D12 /* JSGlobalObjectFunctions.h */; };
    284284                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, ); }; };
    285286                BCD202C20E1706A7002C7E82 /* RegExpConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD202BE0E1706A7002C7E82 /* RegExpConstructor.h */; };
    286287                BCD202C40E1706A7002C7E82 /* RegExpPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = BCD202C00E1706A7002C7E82 /* RegExpPrototype.h */; };
     
    655656                BC7F8FBA0E19D1EF008632C0 /* JSCell.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCell.cpp; sourceTree = "<group>"; };
    656657                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>"; };
    657659                BC9BB95B0E19680600DF8855 /* InternalFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InternalFunction.cpp; sourceTree = "<group>"; };
    658660                BCA62DFE0E2826230004F30D /* CallData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CallData.cpp; sourceTree = "<group>"; };
     
    12621264                                BCDE3AB00E6C82CF001453A7 /* StructureID.cpp */,
    12631265                                BCDE3AB10E6C82CF001453A7 /* StructureID.h */,
     1266                                BC9041470EB9250900FE26FA /* StructureIDTransitionTable.h */,
    12641267                        );
    12651268                        path = runtime;
     
    15481551                                869EBCB70E8C6D4A008722CC /* ResultType.h in Headers */,
    15491552                                14F3488F0E95EF8A003648BC /* CollectorHeapIterator.h in Headers */,
     1553                                BC9041480EB9250900FE26FA /* StructureIDTransitionTable.h in Headers */,
    15501554                        );
    15511555                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/JavaScriptCore/runtime/StructureID.cpp

    r37981 r37985  
    286286        StructureID* existingTransition = structureID->m_transitions.singleTransition;
    287287        structureID->m_usingSingleTransitionSlot = false;
    288         TransitionTable* transitionTable = new TransitionTable;
     288        StructureIDTransitionTable* transitionTable = new StructureIDTransitionTable;
    289289        structureID->m_transitions.table = transitionTable;
    290290        transitionTable->add(make_pair(existingTransition->m_nameInPrevious, existingTransition->m_attributesInPrevious), existingTransition);
  • trunk/JavaScriptCore/runtime/StructureID.h

    r37981 r37985  
    3131#include "JSValue.h"
    3232#include "PropertyMap.h"
     33#include "StructureIDTransitionTable.h"
    3334#include "TypeInfo.h"
    3435#include "ustring.h"
     
    4647    class PropertyNameArrayData;
    4748    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     };
    7749
    7850    class StructureID : public RefCounted<StructureID> {
     
    141113
    142114    private:
    143         typedef std::pair<RefPtr<UString::Rep>, unsigned> TransitionTableKey;
    144         typedef HashMap<TransitionTableKey, StructureID*, TransitionTableHash, TransitionTableHashTraits> TransitionTable;
    145 
    146115        StructureID(JSValue* prototype, const TypeInfo&);
    147116       
     
    159128        union {
    160129            StructureID* singleTransition;
    161             TransitionTable* table;
     130            StructureIDTransitionTable* table;
    162131        } m_transitions;
    163132
  • trunk/JavaScriptCore/runtime/StructureIDTransitionTable.h

    r37981 r37985  
    1 // -*- mode: c++; c-basic-offset: 4 -*-
    21/*
    32 * Copyright (C) 2008 Apple Inc. All rights reserved.
     
    2524 */
    2625
    27 #ifndef StructureID_h
    28 #define StructureID_h
     26#ifndef StructureIDTransitionTable_h
     27#define StructureIDTransitionTable_h
    2928
    30 #include "JSType.h"
    31 #include "JSValue.h"
    32 #include "PropertyMap.h"
    33 #include "TypeInfo.h"
    3429#include "ustring.h"
    3530#include <wtf/HashFunctions.h>
     31#include <wtf/HashMap.h>
    3632#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>
    4234
    4335namespace JSC {
    4436
    45     class PropertyNameArray;
    46     class PropertyNameArrayData;
    47     class StructureIDChain;
     37    class StructureID;
    4838
    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)
    5242        {
    5343            return p.first->computedHash();
    5444        }
    5545
    56         static bool equal(const TransitionTableKey& a, const TransitionTableKey& b)
     46        static bool equal(const Key& a, const Key& b)
    5747        {
    5848            return a == b;
     
    6252    };
    6353
    64     struct TransitionTableHashTraits {
     54    struct StructureIDTransitionTableHashTraits {
    6555        typedef WTF::HashTraits<RefPtr<UString::Rep> > FirstTraits;
    6656        typedef WTF::GenericHashTraits<unsigned> SecondTraits;
     
    7666    };
    7767
    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;
    19069
    19170} // namespace JSC
    19271
    193 #endif // StructureID_h
     72#endif // StructureIDTransitionTable_h
Note: See TracChangeset for help on using the changeset viewer.