Enhanced GC logging
authormhahnenberg@apple.com <mhahnenberg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Apr 2014 20:05:04 +0000 (20:05 +0000)
committermhahnenberg@apple.com <mhahnenberg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 5 Apr 2014 20:05:04 +0000 (20:05 +0000)
commit0f12d133e90a3aba4b8d228673f3e351af6208a5
tree8f2707926946467801cbf6c6a3193e8e9e2c0736
parent3b76b699a4f875ca234aa14476e292f73e5e98d9
Enhanced GC logging
https://bugs.webkit.org/show_bug.cgi?id=131246

Reviewed by Geoff Garen.

Source/JavaScriptCore:

Getting data on the state of the JSC Heap at runtime is currently in a sad state.
The OBJECT_MARK_LOGGING macro enables some basic GC logging, but it requires a full
recompile to turn it on. It would be nice if we could runtime enable our GC logging
infrastructure while incurring minimal cost when it is disabled.

It would also be nice to get a complete view of the Heap. Currently OBJECT_MARK_LOGGING
provides us with the discovered roots along with parent-child relationships as objects
are scanned. However, once an object is scanned it will never be declared as the child
of another object during that collection. This gives us a tree-like view of the
Heap (i.e. each scanned node only reports having a single parent), where the actual
Heap can be an arbitrary graph.

This patch replaces OBJECT_MARK_LOGGING and gives us these nice to haves. First it enhances
our logGC() runtime Option by changing it to be a tri-state value of None, Basic, or Verbose
logging levels. None means no logging is done, Basic is what logGC() = true would have done
prior to this patch, and Verbose logs all object relationships.

JSCell has new dump/dumpToStream methods, the latter of which is "virtual" to allow
subclasses to override the default string representation that will be dumped. These
methods allow JSCells to be dumped using the standard dataLog() calls similar to much of
the logging infrastructure in our compilers.

This patch also adds a GCLogging class that handles dumping the relationships between objects.
It does this by using the pre-existing visitChildren virtual methods to obtain the immediate
children of each live cell at the end of garbage collection.

This change meets our goal of being neutral on the benchmarks we track.

* JavaScriptCore.xcodeproj/project.pbxproj:
* heap/GCLogging.cpp: Added.
(JSC::GCLogging::levelAsString):
(JSC::LoggingFunctor::LoggingFunctor):
(JSC::LoggingFunctor::operator()):
(JSC::LoggingFunctor::log):
(JSC::LoggingFunctor::reviveCells):
(JSC::LoggingFunctor::returnValue):
(JSC::GCLogging::dumpObjectGraph):
* heap/GCLogging.h: Added.
* heap/GCSegmentedArray.h:
(JSC::GCSegmentedArray::begin):
(JSC::GCSegmentedArray::end):
* heap/Heap.cpp:
(JSC::Heap::markRoots):
(JSC::Heap::visitSmallStrings):
(JSC::Heap::visitConservativeRoots):
(JSC::Heap::visitCompilerWorklists):
(JSC::Heap::visitProtectedObjects):
(JSC::Heap::visitTempSortVectors):
(JSC::Heap::visitArgumentBuffers):
(JSC::Heap::visitException):
(JSC::Heap::visitStrongHandles):
(JSC::Heap::visitHandleStack):
(JSC::Heap::traceCodeBlocksAndJITStubRoutines):
(JSC::Heap::visitWeakHandles):
(JSC::Heap::updateObjectCounts):
(JSC::Heap::collect):
(JSC::Heap::didFinishCollection):
* heap/Heap.h:
* heap/MarkStack.h:
* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::dump):
* heap/SlotVisitor.h:
(JSC::SlotVisitor::markStack):
* heap/SlotVisitorInlines.h:
(JSC::SlotVisitor::internalAppend):
* runtime/ClassInfo.h:
* runtime/JSCell.cpp:
(JSC::JSCell::dump):
(JSC::JSCell::dumpToStream):
(JSC::JSCell::className):
* runtime/JSCell.h:
* runtime/JSCellInlines.h:
(JSC::JSCell::visitChildren):
* runtime/JSString.cpp:
(JSC::JSString::dumpToStream):
(JSC::JSString::visitChildren):
* runtime/JSString.h:
(JSC::JSString::length):
(JSC::JSRopeString::RopeBuilder::length):
* runtime/Options.cpp:
(JSC::parse):
(JSC::Options::setOption):
(JSC::Options::dumpOption):
* runtime/Options.h:

Source/WTF:

Remove OBJECT_MARK_LOGGING

* wtf/FeatureDefines.h:
* wtf/Platform.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@166837 268f45cc-cd09-0410-ab3c-d52691b4dbfc
23 files changed:
Source/JavaScriptCore/CMakeLists.txt
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj
Source/JavaScriptCore/JavaScriptCore.vcxproj/JavaScriptCore.vcxproj.filters
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/heap/GCSegmentedArray.h
Source/JavaScriptCore/heap/Heap.cpp
Source/JavaScriptCore/heap/Heap.h
Source/JavaScriptCore/heap/MarkStack.h
Source/JavaScriptCore/heap/SlotVisitor.cpp
Source/JavaScriptCore/heap/SlotVisitor.h
Source/JavaScriptCore/heap/SlotVisitorInlines.h
Source/JavaScriptCore/runtime/ClassInfo.h
Source/JavaScriptCore/runtime/JSCell.cpp
Source/JavaScriptCore/runtime/JSCell.h
Source/JavaScriptCore/runtime/JSCellInlines.h
Source/JavaScriptCore/runtime/JSString.cpp
Source/JavaScriptCore/runtime/JSString.h
Source/JavaScriptCore/runtime/Options.cpp
Source/JavaScriptCore/runtime/Options.h
Source/WTF/ChangeLog
Source/WTF/wtf/FeatureDefines.h
Source/WTF/wtf/Platform.h