Skip to content

Commit 20e5254

Browse files
committed
Extra asserts for testing in prod
1 parent 8e51f23 commit 20e5254

File tree

12 files changed

+36
-62
lines changed

12 files changed

+36
-62
lines changed

Source/JavaScriptCore/heap/MarkedBlock.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,9 @@ void MarkedBlock::Handle::removeFromDirectory()
318318

319319
void MarkedBlock::Handle::didAddToDirectory(BlockDirectory* directory, unsigned index)
320320
{
321-
ASSERT(m_index == std::numeric_limits<unsigned>::max());
322-
ASSERT(!m_directory);
321+
RELEASE_ASSERT(m_index == std::numeric_limits<unsigned>::max());
322+
RELEASE_ASSERT(WTF::opaque(!m_directory));
323+
RELEASE_ASSERT(WTF::opaque(directory));
323324

324325
RELEASE_ASSERT(directory->subspace()->alignedMemoryAllocator() == m_alignedMemoryAllocator);
325326

@@ -348,21 +349,19 @@ void MarkedBlock::Handle::didAddToDirectory(BlockDirectory* directory, unsigned
348349

349350
void MarkedBlock::Handle::didRemoveFromDirectory()
350351
{
351-
ASSERT(m_index != std::numeric_limits<unsigned>::max());
352-
ASSERT(m_directory);
352+
RELEASE_ASSERT(m_index != std::numeric_limits<unsigned>::max());
353+
RELEASE_ASSERT(m_directory);
353354

354355
m_index = std::numeric_limits<unsigned>::max();
355356
m_directory = nullptr;
356357
blockFooter().m_subspace = nullptr;
357358
}
358359

359-
#if ASSERT_ENABLED
360360
void MarkedBlock::assertValidCell(VM& vm, HeapCell* cell) const
361361
{
362362
RELEASE_ASSERT(&vm == &this->vm());
363363
RELEASE_ASSERT(const_cast<MarkedBlock*>(this)->handle().cellAlign(cell) == cell);
364364
}
365-
#endif // ASSERT_ENABLED
366365

367366
void MarkedBlock::Handle::dumpState(PrintStream& out)
368367
{
@@ -488,4 +487,3 @@ void printInternal(PrintStream& out, JSC::MarkedBlock::Handle::SweepMode mode)
488487
}
489488

490489
} // namespace WTF
491-

Source/JavaScriptCore/heap/MarkedBlock.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,11 +354,7 @@ class MarkedBlock {
354354

355355
bool hasAnyMarked() const;
356356
void noteMarked();
357-
#if ASSERT_ENABLED
358357
void assertValidCell(VM&, HeapCell*) const;
359-
#else
360-
void assertValidCell(VM&, HeapCell*) const { }
361-
#endif
362358

363359
WeakSet& weakSet();
364360

Source/JavaScriptCore/heap/PreciseAllocation.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -253,14 +253,11 @@ void PreciseAllocation::dump(PrintStream& out) const
253253
out.print(RawPointer(this), ":(cell at ", RawPointer(cell()), " with size ", m_cellSize, " and attributes ", m_attributes, ")");
254254
}
255255

256-
#if ASSERT_ENABLED
257256
void PreciseAllocation::assertValidCell(VM& vm, HeapCell* cell) const
258257
{
259-
ASSERT(&vm == &this->vm());
260-
ASSERT(cell == this->cell());
261-
ASSERT(m_hasValidCell);
258+
RELEASE_ASSERT(&vm == &this->vm());
259+
RELEASE_ASSERT(cell == this->cell());
260+
RELEASE_ASSERT(m_hasValidCell);
262261
}
263-
#endif
264262

265263
} // namespace JSC
266-

Source/JavaScriptCore/heap/PreciseAllocation.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,7 @@ class PreciseAllocation : public PackedRawSentinelNode<PreciseAllocation> {
139139

140140
void noteMarked() { }
141141

142-
#if ASSERT_ENABLED
143142
void assertValidCell(VM&, HeapCell*) const;
144-
#else
145-
void assertValidCell(VM&, HeapCell*) const { }
146-
#endif
147143

148144
void sweep();
149145

@@ -182,4 +178,3 @@ inline void* PreciseAllocation::basePointer() const
182178
}
183179

184180
} // namespace JSC
185-

Source/JavaScriptCore/heap/SlotVisitor.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ void SlotVisitor::appendHiddenSlow(JSCell* cell, Dependency dependency)
235235

236236
ALWAYS_INLINE void SlotVisitor::appendHiddenSlowImpl(JSCell* cell, Dependency dependency)
237237
{
238-
ASSERT(!m_isCheckingForDefaultMarkViolation);
238+
RELEASE_ASSERT(!m_isCheckingForDefaultMarkViolation);
239239

240240
#if ENABLE(GC_VALIDATION)
241241
validate(cell);
@@ -274,14 +274,14 @@ void SlotVisitor::appendToMarkStack(JSCell* cell)
274274
template<typename ContainerType>
275275
ALWAYS_INLINE void SlotVisitor::appendToMarkStack(ContainerType& container, JSCell* cell)
276276
{
277-
ASSERT(m_heap.isMarked(cell));
278-
#if CPU(X86_64)
277+
RELEASE_ASSERT(m_heap.isMarked(cell));
278+
279279
if (UNLIKELY(Options::dumpZappedCellCrashData())) {
280280
if (UNLIKELY(cell->isZapped()))
281281
reportZappedCellAndCrash(m_heap, cell);
282282
}
283-
#endif
284-
ASSERT(!cell->isZapped());
283+
284+
RELEASE_ASSERT(!cell->isZapped());
285285

286286
container.noteMarked();
287287

@@ -295,7 +295,7 @@ void SlotVisitor::markAuxiliary(const void* base)
295295
{
296296
HeapCell* cell = bitwise_cast<HeapCell*>(base);
297297

298-
ASSERT(cell->heap() == heap());
298+
RELEASE_ASSERT(cell->heap() == heap());
299299

300300
if (Heap::testAndSetMarked(m_markingVersion, cell))
301301
return;
@@ -344,7 +344,7 @@ class SetCurrentCellScope {
344344

345345
ALWAYS_INLINE void SlotVisitor::visitChildren(const JSCell* cell)
346346
{
347-
ASSERT(m_heap.isMarked(cell));
347+
RELEASE_ASSERT(m_heap.isMarked(cell));
348348

349349
SetCurrentCellScope currentCellScope(*this, cell);
350350

@@ -380,7 +380,6 @@ ALWAYS_INLINE void SlotVisitor::visitChildren(const JSCell* cell)
380380
default:
381381
// FIXME: This could be so much better.
382382
// https://bugs.webkit.org/show_bug.cgi?id=162462
383-
#if CPU(X86_64)
384383
if (UNLIKELY(Options::dumpZappedCellCrashData())) {
385384
Structure* structure = cell->structure();
386385
if (LIKELY(structure)) {
@@ -390,7 +389,6 @@ ALWAYS_INLINE void SlotVisitor::visitChildren(const JSCell* cell)
390389
}
391390
reportZappedCellAndCrash(m_heap, const_cast<JSCell*>(cell));
392391
}
393-
#endif
394392
cell->methodTable()->visitChildren(const_cast<JSCell*>(cell), *this);
395393
break;
396394
}

Source/JavaScriptCore/runtime/JSCast.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ template<typename To, typename From>
3333
inline To jsCast(From* from)
3434
{
3535
static_assert(std::is_base_of<JSCell, typename std::remove_pointer<To>::type>::value && std::is_base_of<JSCell, typename std::remove_pointer<From>::type>::value, "JS casting expects that the types you are casting to/from are subclasses of JSCell");
36-
#if (ASSERT_ENABLED || ENABLE(SECURITY_ASSERTIONS)) && CPU(X86_64)
36+
#if (ASSERT_ENABLED || ENABLE(SECURITY_ASSERTIONS))
3737
if (from && !from->JSCell::inherits(std::remove_pointer<To>::type::info()))
3838
reportZappedCellAndCrash(*from->JSCell::heap(), from);
3939
#else

Source/JavaScriptCore/runtime/JSCell.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ void JSCellLock::unlockSlow()
259259
IndexingTypeLockAlgorithm::unlockSlow(*lock);
260260
}
261261

262-
#if CPU(X86_64)
263262
NEVER_INLINE NO_RETURN_DUE_TO_CRASH NOT_TAIL_CALLED void reportZappedCellAndCrash(Heap& heap, const JSCell* cell)
264263
{
265264
MarkedBlock::Handle* foundBlockHandle = nullptr;
@@ -336,6 +335,5 @@ NEVER_INLINE NO_RETURN_DUE_TO_CRASH NOT_TAIL_CALLED void reportZappedCellAndCras
336335

337336
CRASH_WITH_INFO(cellAddress, headerWord, zapReasonAndMore, subspaceHash, cellSize, foundBlock, variousState);
338337
}
339-
#endif // CPU(X86_64)
340338

341339
} // namespace JSC

Source/JavaScriptCore/runtime/JSCell.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,6 @@ inline auto subspaceForConcurrently(VM& vm)
297297
return Type::template subspaceFor<Type, SubspaceAccess::Concurrently>(vm);
298298
}
299299

300-
#if CPU(X86_64)
301300
JS_EXPORT_PRIVATE NEVER_INLINE NO_RETURN_DUE_TO_CRASH NOT_TAIL_CALLED void reportZappedCellAndCrash(Heap&, const JSCell*);
302-
#endif
303301

304302
} // namespace JSC

Source/JavaScriptCore/runtime/JSCellInlines.h

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ namespace JSC {
5252
inline JSCell::JSCell(CreatingEarlyCellTag)
5353
: m_cellState(CellState::DefinitelyWhite)
5454
{
55-
ASSERT(!isCompilationThread());
55+
RELEASE_ASSERT(!isCompilationThread());
5656
}
5757

5858
inline JSCell::JSCell(VM&, Structure* structure)
@@ -62,7 +62,7 @@ inline JSCell::JSCell(VM&, Structure* structure)
6262
, m_flags(structure->typeInfo().inlineTypeFlags())
6363
, m_cellState(CellState::DefinitelyWhite)
6464
{
65-
ASSERT(!isCompilationThread());
65+
RELEASE_ASSERT(!isCompilationThread());
6666

6767
// Note that in the constructor initializer list above, we are only using values
6868
// inside structure but not necessarily the structure pointer itself. All these
@@ -84,18 +84,18 @@ inline void JSCell::finishCreation(VM& vm)
8484
// to make sure that none of our stores sink below here.
8585
vm.mutatorFence();
8686
#if ENABLE(GC_VALIDATION)
87-
ASSERT(vm.isInitializingObject());
87+
RELEASE_ASSERT(vm.isInitializingObject());
8888
vm.setInitializingObjectClass(0);
8989
#else
9090
UNUSED_PARAM(vm);
9191
#endif
92-
ASSERT(m_structureID);
92+
RELEASE_ASSERT(m_structureID);
9393
}
9494

9595
inline void JSCell::finishCreation(VM& vm, Structure* structure, CreatingEarlyCellTag)
9696
{
9797
#if ENABLE(GC_VALIDATION)
98-
ASSERT(vm.isInitializingObject());
98+
RELEASE_ASSERT(vm.isInitializingObject());
9999
vm.setInitializingObjectClass(0);
100100
if (structure) {
101101
#endif
@@ -109,7 +109,7 @@ inline void JSCell::finishCreation(VM& vm, Structure* structure, CreatingEarlyCe
109109
UNUSED_PARAM(vm);
110110
#endif
111111
// Very first set of allocations won't have a real structure.
112-
ASSERT(m_structureID || !vm.structureStructure);
112+
RELEASE_ASSERT(m_structureID || !vm.structureStructure);
113113
}
114114

115115
inline JSType JSCell::type() const
@@ -170,15 +170,15 @@ inline Allocator allocatorForConcurrently(VM& vm, size_t allocationSize, Allocat
170170
template<typename T, AllocationFailureMode failureMode>
171171
ALWAYS_INLINE void* tryAllocateCellHelper(VM& vm, size_t size, GCDeferralContext* deferralContext)
172172
{
173-
ASSERT(deferralContext || vm.heap.isDeferred() || !DisallowGC::isInEffectOnCurrentThread());
174-
ASSERT(size >= sizeof(T));
173+
RELEASE_ASSERT(deferralContext || vm.heap.isDeferred() || !DisallowGC::isInEffectOnCurrentThread());
174+
RELEASE_ASSERT(size >= sizeof(T));
175175
JSCell* result = static_cast<JSCell*>(subspaceFor<T>(vm)->allocate(vm, size, deferralContext, failureMode));
176176
if constexpr (failureMode == AllocationFailureMode::ReturnNull) {
177177
if (!result)
178178
return nullptr;
179179
}
180180
#if ENABLE(GC_VALIDATION)
181-
ASSERT(!vm.isInitializingObject());
181+
RELEASE_ASSERT(!vm.isInitializingObject());
182182
vm.setInitializingObjectClass(T::info());
183183
#endif
184184
result->clearStructure();
@@ -298,16 +298,16 @@ inline bool JSCell::isAPIValueWrapper() const
298298

299299
ALWAYS_INLINE void JSCell::setStructure(VM& vm, Structure* structure)
300300
{
301-
ASSERT(structure->classInfoForCells() == this->structure()->classInfoForCells());
302-
ASSERT(!this->structure()
301+
RELEASE_ASSERT(structure->classInfoForCells() == this->structure()->classInfoForCells());
302+
RELEASE_ASSERT(!this->structure()
303303
|| this->structure()->transitionWatchpointSetHasBeenInvalidated()
304304
|| structure->id().decode() == structure);
305305
m_structureID = structure->id();
306306
m_flags = TypeInfo::mergeInlineTypeFlags(structure->typeInfo().inlineTypeFlags(), m_flags);
307307
m_type = structure->typeInfo().type();
308308
IndexingType newIndexingType = structure->indexingModeIncludingHistory();
309309
if (m_indexingTypeAndMisc != newIndexingType) {
310-
ASSERT(!(newIndexingType & ~AllArrayTypesAndHistory));
310+
RELEASE_ASSERT(!(newIndexingType & ~AllArrayTypesAndHistory));
311311
for (;;) {
312312
IndexingType oldValue = m_indexingTypeAndMisc;
313313
IndexingType newValue = (oldValue & ~AllArrayTypesAndHistory) | structure->indexingModeIncludingHistory();
@@ -321,10 +321,8 @@ ALWAYS_INLINE void JSCell::setStructure(VM& vm, Structure* structure)
321321
inline const MethodTable* JSCell::methodTable() const
322322
{
323323
Structure* structure = this->structure();
324-
#if ASSERT_ENABLED
325324
if (Structure* rootStructure = structure->structure())
326-
ASSERT(rootStructure == rootStructure->structure());
327-
#endif
325+
RELEASE_ASSERT(rootStructure == rootStructure->structure());
328326
return &structure->classInfoForCells()->methodTable;
329327
}
330328

@@ -362,7 +360,7 @@ ALWAYS_INLINE const ClassInfo* JSCell::classInfo() const
362360
// destructing the object. The GC thread or JIT threads, unlike the mutator thread, are able to access classInfo
363361
// independent of whether the mutator thread is sweeping or not. Hence, we also check for !currentThreadIsHoldingAPILock()
364362
// to allow the GC thread or JIT threads to pass this assertion.
365-
ASSERT(vm().heap.mutatorState() != MutatorState::Sweeping || !vm().currentThreadIsHoldingAPILock());
363+
RELEASE_ASSERT(vm().heap.mutatorState() != MutatorState::Sweeping || !vm().currentThreadIsHoldingAPILock());
366364
return structure()->classInfoForCells();
367365
}
368366

Source/JavaScriptCore/runtime/OptionsList.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,14 @@ bool canUseWebAssemblyFastMemory();
213213
v(Double, gcIncrementBytes, 10000, Normal, nullptr) \
214214
v(Double, gcIncrementMaxBytes, 100000, Normal, nullptr) \
215215
v(Double, gcIncrementScale, 0, Normal, nullptr) \
216-
v(Bool, scribbleFreeCells, false, Normal, nullptr) \
216+
v(Bool, scribbleFreeCells, true, Normal, nullptr) \
217217
v(Double, sizeClassProgression, 1.4, Normal, nullptr) \
218218
v(Unsigned, preciseAllocationCutoff, 100000, Normal, nullptr) \
219219
v(Bool, dumpSizeClasses, false, Normal, nullptr) \
220220
v(Bool, useBumpAllocator, true, Normal, nullptr) \
221-
v(Bool, stealEmptyBlocksFromOtherAllocators, true, Normal, nullptr) \
221+
v(Bool, stealEmptyBlocksFromOtherAllocators, false, Normal, nullptr) \
222222
v(Bool, eagerlyUpdateTopCallFrame, false, Normal, nullptr) \
223-
v(Bool, dumpZappedCellCrashData, false, Normal, nullptr) \
223+
v(Bool, dumpZappedCellCrashData, true, Normal, nullptr) \
224224
\
225225
v(Bool, useOSREntryToDFG, true, Normal, nullptr) \
226226
v(Bool, useOSREntryToFTL, true, Normal, nullptr) \
@@ -349,9 +349,9 @@ bool canUseWebAssemblyFastMemory();
349349
v(Bool, forceWeakRandomSeed, false, Normal, nullptr) \
350350
v(Unsigned, forcedWeakRandomSeed, 0, Normal, nullptr) \
351351
\
352-
v(Bool, useZombieMode, false, Normal, "debugging option to scribble over dead objects with 0xbadbeef0") \
352+
v(Bool, useZombieMode, true, Normal, "debugging option to scribble over dead objects with 0xbadbeef0") \
353353
v(Bool, useImmortalObjects, false, Normal, "debugging option to keep all objects alive forever") \
354-
v(Bool, sweepSynchronously, false, Normal, "debugging option to sweep all dead objects synchronously at GC end before resuming mutator") \
354+
v(Bool, sweepSynchronously, true, Normal, "debugging option to sweep all dead objects synchronously at GC end before resuming mutator") \
355355
v(Unsigned, maxSingleAllocationSize, 0, Configurable, "debugging option to limit individual allocations to a max size (0 = limit not set, N = limit size in bytes)") \
356356
\
357357
v(GCLogLevel, logGC, GCLogging::None, Normal, "debugging option to log GC activity (0 = None, 1 = Basic, 2 = Verbose)") \

0 commit comments

Comments
 (0)