Changeset 89156 in webkit


Ignore:
Timestamp:
Jun 17, 2011 12:11:44 PM (13 years ago)
Author:
ggaren@apple.com
Message:

2011-06-16 Geoffrey Garen <ggaren@apple.com>

Reviewed by Oliver Hunt.

Added some write barrier action, compiled out by default
https://bugs.webkit.org/show_bug.cgi?id=62844

  • JavaScriptCore.xcodeproj/project.pbxproj: Fixed an incremental build issue with Heap.cpp.
  • heap/Heap.cpp: (JSC::Heap::writeBarrierSlowCase):
  • heap/Heap.h: (JSC::Heap::writeBarrier):
  • heap/MarkedBlock.h: (JSC::MarkedBlock::isAtomAligned): (JSC::MarkedBlock::blockFor): (JSC::MarkedBlock::atomNumber): (JSC::MarkedBlock::ownerSetNumber): (JSC::MarkedBlock::addOldSpaceOwner): (JSC::MarkedBlock::OwnerSet::OwnerSet): (JSC::MarkedBlock::OwnerSet::add): (JSC::MarkedBlock::OwnerSet::clear): (JSC::MarkedBlock::OwnerSet::size): (JSC::MarkedBlock::OwnerSet::didOverflow): (JSC::MarkedBlock::OwnerSet::owners): Added a basic write barrier that tracks owners for regions within blocks. Currently unused.
Location:
trunk/Source/JavaScriptCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r89153 r89156  
     12011-06-16  Geoffrey Garen  <ggaren@apple.com>
     2
     3        Reviewed by Oliver Hunt.
     4
     5        Added some write barrier action, compiled out by default
     6        https://bugs.webkit.org/show_bug.cgi?id=62844
     7
     8        * JavaScriptCore.exp: Build!
     9
     10        * JavaScriptCore.xcodeproj/project.pbxproj: Fixed an incremental build
     11        issue with Heap.cpp.
     12
     13        * heap/Heap.cpp:
     14        (JSC::Heap::writeBarrierSlowCase):
     15        * heap/Heap.h:
     16        (JSC::Heap::writeBarrier):
     17        * heap/MarkedBlock.h:
     18        (JSC::MarkedBlock::isAtomAligned):
     19        (JSC::MarkedBlock::blockFor):
     20        (JSC::MarkedBlock::atomNumber):
     21        (JSC::MarkedBlock::ownerSetNumber):
     22        (JSC::MarkedBlock::addOldSpaceOwner):
     23        (JSC::MarkedBlock::OwnerSet::OwnerSet):
     24        (JSC::MarkedBlock::OwnerSet::add):
     25        (JSC::MarkedBlock::OwnerSet::clear):
     26        (JSC::MarkedBlock::OwnerSet::size):
     27        (JSC::MarkedBlock::OwnerSet::didOverflow):
     28        (JSC::MarkedBlock::OwnerSet::owners): Added a basic write barrier that
     29        tracks owners for regions within blocks. Currently unused.
     30
    1312011-06-17  Raphael Kubo da Costa  <kubo@profusion.mobi>
    232
  • trunk/Source/JavaScriptCore/JavaScriptCore.exp

    r89069 r89156  
    228228__ZN3JSC4Heap19setActivityCallbackEN3WTF10PassOwnPtrINS_18GCActivityCallbackEEE
    229229__ZN3JSC4Heap20protectedObjectCountEv
     230__ZN3JSC4Heap20writeBarrierSlowCaseEPKNS_6JSCellEPS1_
    230231__ZN3JSC4Heap25protectedObjectTypeCountsEv
    231232__ZN3JSC4Heap26protectedGlobalObjectCountEv
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def

    r89077 r89156  
    375375    ?writable@PropertyDescriptor@JSC@@QBE_NXZ
    376376    ?writeBarrier@HandleHeap@JSC@@QAEXPAVJSValue@2@ABV32@@Z
     377    ?writeBarrierSlowCase@Heap@JSC@@CAXPBVJSCell@2@PAV32@@Z
    377378    ?yield@WTF@@YAXXZ
    378379    WTFLog
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r89075 r89156  
    184184                14B8EC720A5652090062BE54 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6560A4CF04B3B3E7008AE952 /* CoreFoundation.framework */; };
    185185                14BA78F113AAB88F005B7C2C /* SlotVisitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 14BA78F013AAB88F005B7C2C /* SlotVisitor.h */; settings = {ATTRIBUTES = (Private, ); }; };
     186                14BA7A9713AADFF8005B7C2C /* Heap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14BA7A9513AADFF8005B7C2C /* Heap.cpp */; };
     187                14BA7A9813AADFF8005B7C2C /* Heap.h in Headers */ = {isa = PBXBuildFile; fileRef = 14BA7A9613AADFF8005B7C2C /* Heap.h */; };
    186188                14BD59C50A3E8F9F00BAF59C /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 932F5BD90822A1C700736975 /* JavaScriptCore.framework */; };
    187189                14BD5A300A3E91F600BAF59C /* JSContextRef.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14BD5A290A3E91F600BAF59C /* JSContextRef.cpp */; };
     
    195197                14F8BA43107EC88C009892DC /* TCSystemAlloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6541BD7008E80A17002CBEE7 /* TCSystemAlloc.cpp */; };
    196198                14F97447138C853E00DA1C67 /* HeapRootVisitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 14F97446138C853E00DA1C67 /* HeapRootVisitor.h */; settings = {ATTRIBUTES = (Private, ); }; };
    197                 14FB986D135225410085A5DB /* Heap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14FB986B135225410085A5DB /* Heap.cpp */; };
    198                 14FB986E135225410085A5DB /* Heap.h in Headers */ = {isa = PBXBuildFile; fileRef = 14FB986C135225410085A5DB /* Heap.h */; settings = {ATTRIBUTES = (Private, ); }; };
    199199                14FFF98C12BFFF7500795BB8 /* PageAllocationAligned.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 14FFF98A12BFFF7500795BB8 /* PageAllocationAligned.cpp */; };
    200200                14FFF98D12BFFF7500795BB8 /* PageAllocationAligned.h in Headers */ = {isa = PBXBuildFile; fileRef = 14FFF98B12BFFF7500795BB8 /* PageAllocationAligned.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    816816                14B8ECA60A5653980062BE54 /* JavaScriptCore.exp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.exports; path = JavaScriptCore.exp; sourceTree = "<group>"; tabWidth = 4; usesTabs = 0; };
    817817                14BA78F013AAB88F005B7C2C /* SlotVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SlotVisitor.h; sourceTree = "<group>"; };
     818                14BA7A9513AADFF8005B7C2C /* Heap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Heap.cpp; path = ../../../webkit/Source/JavaScriptCore/heap/Heap.cpp; sourceTree = SOURCE_ROOT; };
     819                14BA7A9613AADFF8005B7C2C /* Heap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Heap.h; path = ../../../webkit/Source/JavaScriptCore/heap/Heap.h; sourceTree = SOURCE_ROOT; };
    818820                14BD59BF0A3E8F9000BAF59C /* testapi */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testapi; sourceTree = BUILT_PRODUCTS_DIR; };
    819821                14BD5A290A3E91F600BAF59C /* JSContextRef.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSContextRef.cpp; sourceTree = "<group>"; };
     
    831833                14F252560D08DD8D004ECFFF /* JSVariableObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSVariableObject.h; sourceTree = "<group>"; };
    832834                14F97446138C853E00DA1C67 /* HeapRootVisitor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HeapRootVisitor.h; sourceTree = "<group>"; };
    833                 14FB986B135225410085A5DB /* Heap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Heap.cpp; sourceTree = "<group>"; };
    834                 14FB986C135225410085A5DB /* Heap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Heap.h; sourceTree = "<group>"; };
    835835                14FFF98A12BFFF7500795BB8 /* PageAllocationAligned.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageAllocationAligned.cpp; sourceTree = "<group>"; };
    836836                14FFF98B12BFFF7500795BB8 /* PageAllocationAligned.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PageAllocationAligned.h; sourceTree = "<group>"; };
     
    15011501                                142E312F134FF0A600AFADB5 /* HandleStack.h */,
    15021502                                146FA5A81378F6B0003627A3 /* HandleTypes.h */,
    1503                                 14FB986B135225410085A5DB /* Heap.cpp */,
    1504                                 14FB986C135225410085A5DB /* Heap.h */,
     1503                                14BA7A9513AADFF8005B7C2C /* Heap.cpp */,
     1504                                14BA7A9613AADFF8005B7C2C /* Heap.h */,
    15051505                                14F97446138C853E00DA1C67 /* HeapRootVisitor.h */,
    15061506                                142E3130134FF0A600AFADB5 /* Local.h */,
     
    25492549                                86704B4312DB8A8100A9FE7B /* YarrSyntaxChecker.h in Headers */,
    25502550                                5DE6E5B30E1728EC00180407 /* create_hash_table in Headers */,
    2551                                 14FB986E135225410085A5DB /* Heap.h in Headers */,
    25522551                                865A30F1135007E100CDB49E /* JSValueInlineMethods.h in Headers */,
    25532552                                142D6F0913539A2800B02E86 /* MarkedBlock.h in Headers */,
     
    25712570                                142A1D8413A19C84009DA5FE /* OldSpace.h in Headers */,
    25722571                                14BA78F113AAB88F005B7C2C /* SlotVisitor.h in Headers */,
     2572                                14BA7A9813AADFF8005B7C2C /* Heap.h in Headers */,
    25732573                        );
    25742574                        runOnlyForDeploymentPostprocessing = 0;
     
    30113011                                86704B8912DBA33700A9FE7B /* YarrPattern.cpp in Sources */,
    30123012                                86704B4212DB8A8100A9FE7B /* YarrSyntaxChecker.cpp in Sources */,
    3013                                 14FB986D135225410085A5DB /* Heap.cpp in Sources */,
    30143013                                142D6F0813539A2800B02E86 /* MarkedBlock.cpp in Sources */,
    30153014                                142D6F1113539A4100B02E86 /* MarkStack.cpp in Sources */,
     
    30193018                                14D2F3DA139F4BE200491031 /* NewSpace.cpp in Sources */,
    30203019                                142A1D8313A19C84009DA5FE /* OldSpace.cpp in Sources */,
     3020                                14BA7A9713AADFF8005B7C2C /* Heap.cpp in Sources */,
    30213021                        );
    30223022                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/JavaScriptCore/heap/Heap.cpp

    r89069 r89156  
    606606}
    607607
     608#if ENABLE(GGC)
     609void Heap::writeBarrierSlowCase(const JSCell* owner, JSCell* cell)
     610{
     611    if (!cell)
     612        return;
     613    MarkedBlock::blockFor(cell)->addOldSpaceOwner(owner, cell);
     614}
     615
     616#else
     617
     618void Heap::writeBarrierSlowCase(const JSCell*, JSCell*)
     619{
     620}
     621#endif
     622
    608623} // namespace JSC
  • trunk/Source/JavaScriptCore/heap/Heap.h

    r89069 r89156  
    142142        RegisterFile& registerFile();
    143143
     144        static void writeBarrierSlowCase(const JSCell*, JSCell*);
     145
    144146        OperationInProgress m_operationInProgress;
    145147        NewSpace m_newSpace;
     
    199201    }
    200202
     203#if ENABLE(GGC)
     204    inline void Heap::writeBarrier(const JSCell* owner, JSCell* cell)
     205    {
     206        if (MarkedBlock::blockFor(owner)->inNewSpace())
     207            return;
     208        writeBarrierSlowCase(owner, cell);
     209    }
     210
     211    inline void Heap::writeBarrier(const JSCell* owner, JSValue value)
     212    {
     213        if (!value)
     214            return;
     215        if (!value.isCell())
     216            return;
     217        writeBarrier(owner, value.asCell());
     218    }
     219
     220#else
     221
     222    inline void Heap::writeBarrier(const JSCell*, JSCell*)
     223    {
     224    }
     225
    201226    inline void Heap::writeBarrier(const JSCell*, JSValue)
    202227    {
    203228    }
    204 
    205     inline void Heap::writeBarrier(const JSCell*, JSCell*)
    206     {
    207     }
     229#endif
    208230
    209231    inline void Heap::reportExtraMemoryCost(size_t cost)
  • trunk/Source/JavaScriptCore/heap/MarkedBlock.h

    r88519 r89156  
    4343        friend class WTF::DoublyLinkedListNode<MarkedBlock>;
    4444    public:
     45        static const size_t atomSize = sizeof(double); // Ensures natural alignment for all built-in types.
     46        static const size_t blockSize = 16 * KB;
     47
     48        static const size_t atomsPerBlock = blockSize / atomSize; // ~1.5% overhead
     49        static const size_t ownerSetsPerBlock = 8; // ~2% overhead.
     50
    4551        struct VoidFunctor {
    4652            typedef void ReturnType;
     
    4854        };
    4955
    50         static const size_t atomSize = sizeof(double); // Ensures natural alignment for all built-in types.
    51         static const size_t blockSize = 16 * KB;
     56        class OwnerSet {
     57        public:
     58            OwnerSet();
     59           
     60            void add(const JSCell*);
     61            void clear();
     62
     63            size_t size();
     64            bool didOverflow();
     65           
     66            const JSCell** owners();
     67
     68        private:
     69            static const size_t capacity = 5;
     70            unsigned char m_size;
     71            const JSCell* m_owners[capacity];
     72        };
    5273
    5374        static MarkedBlock* create(Heap*, size_t cellSize);
     
    7798        size_t capacity();
    7899
    79         size_t atomNumber(const void*);
    80100        bool isMarked(const void*);
    81101        bool testAndSetMarked(const void*);
    82102        bool testAndClearMarked(const void*);
    83103        void setMarked(const void*);
    84        
     104
     105        void addOldSpaceOwner(const JSCell* owner, const JSCell*);
     106
    85107        template <typename Functor> void forEachCell(Functor&);
    86108
    87109    private:
    88110        static const size_t blockMask = ~(blockSize - 1); // blockSize must be a power of two.
    89 
    90111        static const size_t atomMask = ~(atomSize - 1); // atomSize must be a power of two.
    91        
    92         static const size_t atomsPerBlock = blockSize / atomSize;
    93112
    94113        typedef char Atom[atomSize];
     
    96115        MarkedBlock(const PageAllocationAligned&, Heap*, size_t cellSize);
    97116        Atom* atoms();
     117
     118        size_t atomNumber(const void*);
     119        size_t ownerSetNumber(const JSCell*);
    98120
    99121        size_t m_nextAtom;
     
    102124        WTF::Bitmap<blockSize / atomSize> m_marks;
    103125        bool m_inNewSpace;
     126        OwnerSet m_ownerSets[ownerSetsPerBlock];
    104127        PageAllocationAligned m_allocation;
    105128        Heap* m_heap;
     
    120143    inline bool MarkedBlock::isAtomAligned(const void* p)
    121144    {
    122         return !((intptr_t)(p) & ~atomMask);
     145        return !(reinterpret_cast<Bits>(p) & ~atomMask);
    123146    }
    124147
    125148    inline MarkedBlock* MarkedBlock::blockFor(const void* p)
    126149    {
    127         return reinterpret_cast<MarkedBlock*>(reinterpret_cast<uintptr_t>(p) & blockMask);
     150        return reinterpret_cast<MarkedBlock*>(reinterpret_cast<Bits>(p) & blockMask);
    128151    }
    129152
     
    182205    inline size_t MarkedBlock::atomNumber(const void* p)
    183206    {
    184         return (reinterpret_cast<uintptr_t>(p) - reinterpret_cast<uintptr_t>(this)) / atomSize;
     207        return (reinterpret_cast<Bits>(p) - reinterpret_cast<Bits>(this)) / atomSize;
    185208    }
    186209
     
    228251        return 0;
    229252    }
    230    
     253
     254    inline size_t MarkedBlock::ownerSetNumber(const JSCell* cell)
     255    {
     256        return (reinterpret_cast<Bits>(cell) - reinterpret_cast<Bits>(this)) * ownerSetsPerBlock / blockSize;
     257    }
     258
     259    inline void MarkedBlock::addOldSpaceOwner(const JSCell* owner, const JSCell* cell)
     260    {
     261        OwnerSet& ownerSet = m_ownerSets[ownerSetNumber(cell)];
     262        ownerSet.add(owner);
     263    }
     264
     265    inline MarkedBlock::OwnerSet::OwnerSet()
     266        : m_size(0)
     267    {
     268    }
     269
     270    inline void MarkedBlock::OwnerSet::add(const JSCell* owner)
     271    {
     272        if (m_size < capacity) {
     273            m_owners[m_size++] = owner;
     274            return;
     275        }
     276        m_size = capacity + 1; // Signals overflow.
     277    }
     278
     279    inline void MarkedBlock::OwnerSet::clear()
     280    {
     281        m_size = 0;
     282    }
     283
     284    inline size_t MarkedBlock::OwnerSet::size()
     285    {
     286        return m_size;
     287    }
     288
     289    inline bool MarkedBlock::OwnerSet::didOverflow()
     290    {
     291        return m_size > capacity;
     292    }
     293
     294    inline const JSCell** MarkedBlock::OwnerSet::owners()
     295    {
     296        return m_owners;
     297    }
     298
    231299} // namespace JSC
    232300
Note: See TracChangeset for help on using the changeset viewer.