Changeset 212310 in webkit


Ignore:
Timestamp:
Feb 14, 2017 11:13:04 AM (7 years ago)
Author:
mark.lam@apple.com
Message:

Add JSC_sweepSynchronously and fix JSC_useZombieMode options.
https://bugs.webkit.org/show_bug.cgi?id=168257
<rdar://problem/30451496>

Reviewed by Filip Pizlo.

JSC_useZombieMode now basically enables JSC_sweepSynchronously and
JSC_scribbleFreeCells, which together does the job of zombifying dead objects
immediately after a GC.

  • heap/Heap.cpp:

(JSC::Heap::sweepSynchronously):
(JSC::Heap::collectAllGarbage):
(JSC::Heap::finalize):
(JSC::Heap::didFinishCollection):
(JSC::Zombify::visit): Deleted.
(JSC::Zombify::operator()): Deleted.
(JSC::Heap::zombifyDeadObjects): Deleted.

  • heap/Heap.h:

(JSC::Heap::isZombified): Deleted.

  • runtime/Options.cpp:

(JSC::recomputeDependentOptions):

  • runtime/Options.h:
Location:
trunk/Source/JavaScriptCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r212262 r212310  
     12017-02-14  Mark Lam  <mark.lam@apple.com>
     2
     3        Add JSC_sweepSynchronously and fix JSC_useZombieMode options.
     4        https://bugs.webkit.org/show_bug.cgi?id=168257
     5        <rdar://problem/30451496>
     6
     7        Reviewed by Filip Pizlo.
     8
     9        JSC_useZombieMode now basically enables JSC_sweepSynchronously and
     10        JSC_scribbleFreeCells, which together does the job of zombifying dead objects
     11        immediately after a GC.
     12
     13        * heap/Heap.cpp:
     14        (JSC::Heap::sweepSynchronously):
     15        (JSC::Heap::collectAllGarbage):
     16        (JSC::Heap::finalize):
     17        (JSC::Heap::didFinishCollection):
     18        (JSC::Zombify::visit): Deleted.
     19        (JSC::Zombify::operator()): Deleted.
     20        (JSC::Heap::zombifyDeadObjects): Deleted.
     21        * heap/Heap.h:
     22        (JSC::Heap::isZombified): Deleted.
     23        * runtime/Options.cpp:
     24        (JSC::recomputeDependentOptions):
     25        * runtime/Options.h:
     26
    1272017-02-13  Michael Saboff  <msaboff@apple.com>
    228
  • trunk/Source/JavaScriptCore/heap/Heap.cpp

    r211622 r212310  
    10301030}
    10311031
     1032void Heap::sweepSynchronously()
     1033{
     1034    double before = 0;
     1035    if (Options::logGC()) {
     1036        dataLog("[Full sweep: ", capacity() / 1024, "kb ");
     1037        before = currentTimeMS();
     1038    }
     1039    m_objectSpace.sweep();
     1040    m_objectSpace.shrink();
     1041    if (Options::logGC()) {
     1042        double after = currentTimeMS();
     1043        dataLog("=> ", capacity() / 1024, "kb, ", after - before, "ms] ");
     1044    }
     1045}
     1046
    10321047void Heap::collectAllGarbage()
    10331048{
     
    10401055    if (UNLIKELY(Options::useImmortalObjects()))
    10411056        sweeper()->willFinishSweeping();
    1042     else {
    1043         double before = 0;
    1044         if (Options::logGC()) {
    1045             dataLog("[Full sweep: ", capacity() / 1024, "kb ");
    1046             before = currentTimeMS();
    1047         }
    1048         m_objectSpace.sweep();
    1049         m_objectSpace.shrink();
    1050         if (Options::logGC()) {
    1051             double after = currentTimeMS();
    1052             dataLog("=> ", capacity() / 1024, "kb, ", after - before, "ms]\n");
    1053         }
     1057
     1058    bool alreadySweptInCollectSync = Options::sweepSynchronously();
     1059    if (!alreadySweptInCollectSync) {
     1060        sweepSynchronously();
     1061        if (Options::logGC())
     1062            dataLog("\n");
    10541063    }
    10551064    m_objectSpace.assertNoUnswept();
     
    15961605    if (HasOwnPropertyCache* cache = vm()->hasOwnPropertyCache())
    15971606        cache->clear();
     1607
     1608    if (Options::sweepSynchronously())
     1609        sweepSynchronously();
    15981610
    15991611    if (Options::logGC()) {
     
    18301842        HeapStatistics::recordGCPauseTime(gcStartTime, gcEndTime);
    18311843
    1832     if (Options::useZombieMode())
    1833         zombifyDeadObjects();
    1834 
    18351844    if (Options::dumpObjectStatistics())
    18361845        HeapStatistics::dumpObjectStatistics(this);
     
    19321941    m_fullActivityCallback->setDidSyncGCRecently();
    19331942    collectAllGarbage();
    1934 }
    1935 
    1936 class Zombify : public MarkedBlock::VoidFunctor {
    1937 public:
    1938     inline void visit(HeapCell* cell) const
    1939     {
    1940         void** current = reinterpret_cast_ptr<void**>(cell);
    1941 
    1942         // We want to maintain zapped-ness because that's how we know if we've called
    1943         // the destructor.
    1944         if (cell->isZapped())
    1945             current++;
    1946 
    1947         void* limit = static_cast<void*>(reinterpret_cast<char*>(cell) + cell->cellSize());
    1948         for (; current < limit; current++)
    1949             *current = zombifiedBits;
    1950     }
    1951     IterationStatus operator()(HeapCell* cell, HeapCell::Kind) const
    1952     {
    1953         visit(cell);
    1954         return IterationStatus::Continue;
    1955     }
    1956 };
    1957 
    1958 void Heap::zombifyDeadObjects()
    1959 {
    1960     // Sweep now because destructors will crash once we're zombified.
    1961     m_objectSpace.sweep();
    1962     HeapIterationScope iterationScope(*this);
    1963     m_objectSpace.forEachDeadCell(iterationScope, Zombify());
    19641943}
    19651944
  • trunk/Source/JavaScriptCore/heap/Heap.h

    r211622 r212310  
    8686}
    8787
    88 static void* const zombifiedBits = reinterpret_cast<void*>(static_cast<uintptr_t>(0xdeadbeef));
    89 
    9088typedef HashCountedSet<JSCell*> ProtectCountSet;
    9189typedef HashCountedSet<const char*> TypeCountSet;
     
    168166    JS_EXPORT_PRIVATE void collectAllGarbageIfNotDoneRecently();
    169167    JS_EXPORT_PRIVATE void collectAllGarbage();
     168    JS_EXPORT_PRIVATE void sweepSynchronously();
    170169
    171170    bool shouldCollectHeuristic();
     
    259258    template<typename T> void releaseSoon(RetainPtr<T>&&);
    260259#endif
    261 
    262     static bool isZombified(JSCell* cell) { return *(void**)cell == zombifiedBits; }
    263260
    264261    JS_EXPORT_PRIVATE void registerWeakGCMap(void* weakGCMap, std::function<void()> pruningCallback);
     
    449446    void didFinishCollection(double gcStartTime);
    450447    void resumeCompilerThreads();
    451     void zombifyDeadObjects();
    452448    void gatherExtraHeapSnapshotData(HeapProfiler&);
    453449    void removeDeadHeapSnapshotNodes(HeapProfiler&);
  • trunk/Source/JavaScriptCore/runtime/Options.cpp

    r211603 r212310  
    435435        fastSetMaxSingleAllocationSize(std::numeric_limits<size_t>::max());
    436436#endif
     437
     438    if (Options::useZombieMode()) {
     439        Options::sweepSynchronously() = true;
     440        Options::scribbleFreeCells() = true;
     441    }
     442
    437443    if (Options::useSigillCrashAnalyzer())
    438444        enableSigillCrashAnalyzer();
  • trunk/Source/JavaScriptCore/runtime/Options.h

    r211603 r212310  
    343343    v(unsigned, forcedWeakRandomSeed, 0, Normal, nullptr) \
    344344    \
    345     v(bool, useZombieMode, false, Normal, "debugging option to scribble over dead objects with 0xdeadbeef") \
     345    v(bool, useZombieMode, false, Normal, "debugging option to scribble over dead objects with 0xbadbeef0") \
    346346    v(bool, useImmortalObjects, false, Normal, "debugging option to keep all objects alive forever") \
     347    v(bool, sweepSynchronously, false, Normal, "debugging option to sweep all dead objects synchronously at GC end before resuming mutator") \
    347348    v(bool, dumpObjectStatistics, false, Normal, nullptr) \
    348349    v(unsigned, maxSingleAllocationSize, 0, Configurable, "debugging option to limit individual allocations to a max size (0 = limit not set, N = limit size in bytes)") \
Note: See TracChangeset for help on using the changeset viewer.