Add crash diagnostics for debugging unexpected zapped cells.
https://bugs.webkit.org/show_bug.cgi?id=200149
<rdar://problem/53570112>
Reviewed by Yusuke Suzuki.
Source/JavaScriptCore:
Add a check for zapped cells in SlotVisitor::appendToMarkStack() and
SlotVisitor::visitChildren(). If a zapped cell is detected, we will crash with
some diagnostic info.
To facilitate this, we've made the following changes:
- Changed FreeCell to preserve the 1st 8 bytes. This is fine to do because all
cells are at least 16 bytes long.
- Changed HeapCell::zap() to only zap the structureID. Leave the rest of the
cell header info intact (including the cell JSType).
- Changed HeapCell::zap() to record the reason for zapping the cell. We stash
the reason immediately after the first 8 bytes. This is the same location as
FreeCell::scrambledNext. However, since a cell is not expected to be zapped
and on the free list at the same time, it is also fine to do this.
- Added a few utility functions to MarkedBlock for checking if a cell points
into the block.
- Added VMInspector and JSDollarVM utilities to dump in-use subspace hashes.
- Added some comments to document the hashes of known subspaces.
- Added Options::dumpZappedCellCrashData() to make this check conditional.
We use this option to disable this check for slower machines so that their
PLT5 performance is not impacted.
(JSC::hwL3CacheSize):
(JSC::hwPhysicalCPUMax):
(JSC::hwL3CacheSize):
(JSC::hwPhysicalCPUMax):
(JSC::FreeCell::offsetOfScrambledNext):
(JSC::HeapCell::zap):
(JSC::HeapCell::isZapped const):
(JSC::MarkedBlock::Handle::stopAllocating):
(JSC::MarkedBlock::Handle::start const):
(JSC::MarkedBlock::Handle::end const):
(JSC::MarkedBlock::Handle::contains const):
- heap/MarkedBlockInlines.h:
(JSC::MarkedBlock::Handle::specializedSweep):
(JSC::MarkedSpace::forEachSubspace):
(JSC::SlotVisitor::appendToMarkStack):
(JSC::SlotVisitor::visitChildren):
(JSC::SlotVisitor::reportZappedCellAndCrash):
- heap/SlotVisitor.h:
- jit/AssemblyHelpers.cpp:
(JSC::AssemblyHelpers::emitAllocateWithNonNullAllocator):
(JSC::Options::initialize):
- runtime/Options.h:
- runtime/VM.cpp:
(JSC::VM::VM):
(JSC::functionDumpSubspaceHashes):
(JSC::JSDollarVM::finishCreation):
(JSC::VMInspector::dumpSubspaceHashes):
Source/WebCore:
No new tests because this is a feature for debugging crashes. It has been tested
manually by modifying the code to force a crash at the point of interest.
Added some comments to document the hashes of known subspaces.
- bindings/js/WebCoreJSClientData.cpp:
(WebCore::JSVMClientData::JSVMClientData):