Changeset 178984 in webkit for trunk/Source/JavaScriptCore


Ignore:
Timestamp:
Jan 22, 2015, 11:04:05 PM (10 years ago)
Author:
[email protected]
Message:

EdenCollections unnecessarily visit SmallStrings
https://bugs.webkit.org/show_bug.cgi?id=140762

Reviewed by Geoffrey Garen.

  • heap/Heap.cpp:

(JSC::Heap::copyBackingStores): Also added a GCPhase for copying
backing stores, which is a significant portion of garbage collection.
(JSC::Heap::visitSmallStrings): Check to see if we need to visit
SmallStrings based on the collection type.

  • runtime/SmallStrings.cpp:

(JSC::SmallStrings::SmallStrings):
(JSC::SmallStrings::visitStrongReferences): Set the fact that we have
visited the SmallStrings since the last modification.

  • runtime/SmallStrings.h:

(JSC::SmallStrings::needsToBeVisited): If we're doing a
FullCollection, we need to visit. Otherwise, it depends on whether
we've been visited since the last modification/allocation.

Location:
trunk/Source/JavaScriptCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r178954 r178984  
     12015-01-22  Mark Hahnenberg  <[email protected]>
     2
     3        EdenCollections unnecessarily visit SmallStrings
     4        https://bugs.webkit.org/show_bug.cgi?id=140762
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * heap/Heap.cpp:
     9        (JSC::Heap::copyBackingStores): Also added a GCPhase for copying
     10        backing stores, which is a significant portion of garbage collection.
     11        (JSC::Heap::visitSmallStrings): Check to see if we need to visit
     12        SmallStrings based on the collection type.
     13        * runtime/SmallStrings.cpp:
     14        (JSC::SmallStrings::SmallStrings):
     15        (JSC::SmallStrings::visitStrongReferences): Set the fact that we have
     16        visited the SmallStrings since the last modification.
     17        * runtime/SmallStrings.h:
     18        (JSC::SmallStrings::needsToBeVisited): If we're doing a
     19        FullCollection, we need to visit. Otherwise, it depends on whether
     20        we've been visited since the last modification/allocation.
     21
    1222015-01-22  Ryosuke Niwa  <[email protected]>
    223
  • trunk/Source/JavaScriptCore/heap/Heap.cpp

    r178884 r178984  
    548548void Heap::copyBackingStores()
    549549{
     550    GCPHASE(CopyBackingStores);
    550551    if (m_operationInProgress == EdenCollection)
    551552        m_storageSpace.startedCopying<EdenCollection>();
     
    612613{
    613614    GCPHASE(VisitSmallStrings);
     615    if (!m_vm->smallStrings.needsToBeVisited(m_operationInProgress))
     616        return;
     617
    614618    m_vm->smallStrings.visitStrongReferences(m_slotVisitor);
    615 
    616619    if (Options::logGC() == GCLogging::Verbose)
    617620        dataLog("Small strings:\n", m_slotVisitor);
    618 
    619621    m_slotVisitor.donateAndDrain();
    620622}
  • trunk/Source/JavaScriptCore/runtime/SmallStrings.cpp

    r177222 r178984  
    6969    , m_nullObjectString(nullptr)
    7070    , m_undefinedObjectString(nullptr)
     71    , m_needsToBeVisited(true)
    7172{
    7273    COMPILE_ASSERT(singleCharacterStringCount == sizeof(m_singleCharacterStrings) / sizeof(m_singleCharacterStrings[0]), IsNumCharactersConstInSyncWithClassUsage);
     
    9091void SmallStrings::visitStrongReferences(SlotVisitor& visitor)
    9192{
     93    m_needsToBeVisited = false;
    9294    visitor.appendUnbarrieredPointer(&m_emptyString);
    9395    for (unsigned i = 0; i <= maxSingleCharacterString; ++i)
     
    108110    ASSERT(!m_emptyString);
    109111    m_emptyString = JSString::createHasOtherOwner(*vm, StringImpl::empty());
     112    m_needsToBeVisited = true;
    110113}
    111114
     
    116119    ASSERT(!m_singleCharacterStrings[character]);
    117120    m_singleCharacterStrings[character] = JSString::createHasOtherOwner(*vm, PassRefPtr<StringImpl>(m_storage->rep(character)));
     121    m_needsToBeVisited = true;
    118122}
    119123
     
    125129}
    126130
    127 void SmallStrings::initialize(VM* vm, JSString*& string, const char* value) const
     131void SmallStrings::initialize(VM* vm, JSString*& string, const char* value)
    128132{
    129133    string = JSString::create(*vm, StringImpl::create(value));
     134    m_needsToBeVisited = true;
    130135}
    131136
  • trunk/Source/JavaScriptCore/runtime/SmallStrings.h

    r176508 r178984  
    8989    JSString* undefinedObjectString() const { return m_undefinedObjectString; }
    9090
     91    bool needsToBeVisited(HeapOperation collectionType) const
     92    {
     93        if (collectionType == FullCollection)
     94            return true;
     95        return m_needsToBeVisited;
     96    }
     97
    9198private:
    9299    static const unsigned singleCharacterStringCount = maxSingleCharacterString + 1;
     
    95102    JS_EXPORT_PRIVATE void createSingleCharacterString(VM*, unsigned char);
    96103
    97     void initialize(VM*, JSString*&, const char* value) const;
     104    void initialize(VM*, JSString*&, const char* value);
    98105
    99106    JSString* m_emptyString;
     
    105112    JSString* m_singleCharacterStrings[singleCharacterStringCount];
    106113    std::unique_ptr<SmallStringsStorage> m_storage;
     114    bool m_needsToBeVisited;
    107115};
    108116
Note: See TracChangeset for help on using the changeset viewer.