Changeset 212310 in webkit
- Timestamp:
- Feb 14, 2017 11:13:04 AM (7 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r212262 r212310 1 2017-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 1 27 2017-02-13 Michael Saboff <msaboff@apple.com> 2 28 -
trunk/Source/JavaScriptCore/heap/Heap.cpp
r211622 r212310 1030 1030 } 1031 1031 1032 void 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 1032 1047 void Heap::collectAllGarbage() 1033 1048 { … … 1040 1055 if (UNLIKELY(Options::useImmortalObjects())) 1041 1056 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"); 1054 1063 } 1055 1064 m_objectSpace.assertNoUnswept(); … … 1596 1605 if (HasOwnPropertyCache* cache = vm()->hasOwnPropertyCache()) 1597 1606 cache->clear(); 1607 1608 if (Options::sweepSynchronously()) 1609 sweepSynchronously(); 1598 1610 1599 1611 if (Options::logGC()) { … … 1830 1842 HeapStatistics::recordGCPauseTime(gcStartTime, gcEndTime); 1831 1843 1832 if (Options::useZombieMode())1833 zombifyDeadObjects();1834 1835 1844 if (Options::dumpObjectStatistics()) 1836 1845 HeapStatistics::dumpObjectStatistics(this); … … 1932 1941 m_fullActivityCallback->setDidSyncGCRecently(); 1933 1942 collectAllGarbage(); 1934 }1935 1936 class Zombify : public MarkedBlock::VoidFunctor {1937 public:1938 inline void visit(HeapCell* cell) const1939 {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 called1943 // 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) const1952 {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());1964 1943 } 1965 1944 -
trunk/Source/JavaScriptCore/heap/Heap.h
r211622 r212310 86 86 } 87 87 88 static void* const zombifiedBits = reinterpret_cast<void*>(static_cast<uintptr_t>(0xdeadbeef));89 90 88 typedef HashCountedSet<JSCell*> ProtectCountSet; 91 89 typedef HashCountedSet<const char*> TypeCountSet; … … 168 166 JS_EXPORT_PRIVATE void collectAllGarbageIfNotDoneRecently(); 169 167 JS_EXPORT_PRIVATE void collectAllGarbage(); 168 JS_EXPORT_PRIVATE void sweepSynchronously(); 170 169 171 170 bool shouldCollectHeuristic(); … … 259 258 template<typename T> void releaseSoon(RetainPtr<T>&&); 260 259 #endif 261 262 static bool isZombified(JSCell* cell) { return *(void**)cell == zombifiedBits; }263 260 264 261 JS_EXPORT_PRIVATE void registerWeakGCMap(void* weakGCMap, std::function<void()> pruningCallback); … … 449 446 void didFinishCollection(double gcStartTime); 450 447 void resumeCompilerThreads(); 451 void zombifyDeadObjects();452 448 void gatherExtraHeapSnapshotData(HeapProfiler&); 453 449 void removeDeadHeapSnapshotNodes(HeapProfiler&); -
trunk/Source/JavaScriptCore/runtime/Options.cpp
r211603 r212310 435 435 fastSetMaxSingleAllocationSize(std::numeric_limits<size_t>::max()); 436 436 #endif 437 438 if (Options::useZombieMode()) { 439 Options::sweepSynchronously() = true; 440 Options::scribbleFreeCells() = true; 441 } 442 437 443 if (Options::useSigillCrashAnalyzer()) 438 444 enableSigillCrashAnalyzer(); -
trunk/Source/JavaScriptCore/runtime/Options.h
r211603 r212310 343 343 v(unsigned, forcedWeakRandomSeed, 0, Normal, nullptr) \ 344 344 \ 345 v(bool, useZombieMode, false, Normal, "debugging option to scribble over dead objects with 0x deadbeef") \345 v(bool, useZombieMode, false, Normal, "debugging option to scribble over dead objects with 0xbadbeef0") \ 346 346 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") \ 347 348 v(bool, dumpObjectStatistics, false, Normal, nullptr) \ 348 349 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.