Skip to content

Commit 798ff29

Browse files
committed
[JSC] Make JSC::CompleteSubspace::allocateSlow memory exhaust explicit crash
https://bugs.webkit.org/show_bug.cgi?id=287376 rdar://144494170 Reviewed by Mark Lam. Use RELEASE_ASSERT_RESOURCE_AVAILABLE for CompleteSubspace's memory exhaust crashes explicitly. * Source/JavaScriptCore/heap/CompleteSubspace.cpp: (JSC::CompleteSubspace::allocateSlow): (JSC::CompleteSubspace::reallocatePreciseAllocationNonVirtual): Canonical link: https://commits.webkit.org/291743@main
1 parent 226e750 commit 798ff29

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

‎Source/JavaScriptCore/heap/CompleteSubspace.cpp‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ Allocator CompleteSubspace::allocatorForSlow(size_t size)
106106
void* CompleteSubspace::allocateSlow(VM& vm, size_t size, GCDeferralContext* deferralContext, AllocationFailureMode failureMode)
107107
{
108108
void* result = tryAllocateSlow(vm, size, deferralContext);
109-
if (failureMode == AllocationFailureMode::Assert)
110-
RELEASE_ASSERT(result);
109+
if (UNLIKELY(!result))
110+
RELEASE_ASSERT_RESOURCE_AVAILABLE(failureMode != AllocationFailureMode::Assert, MemoryExhaustion, "Crash intentionally because memory is exhausted.");
111111
return result;
112112
}
113113

@@ -161,8 +161,7 @@ void* CompleteSubspace::reallocatePreciseAllocationNonVirtual(VM& vm, HeapCell*
161161

162162
sanitizeStackForVM(vm);
163163

164-
if (size <= Options::preciseAllocationCutoff()
165-
&& size <= MarkedSpace::largeCutoff) {
164+
if (UNLIKELY(size <= Options::preciseAllocationCutoff() && size <= MarkedSpace::largeCutoff)) {
166165
dataLog("FATAL: attampting to allocate small object using large allocation.\n");
167166
dataLog("Requested allocation size: ", size, "\n");
168167
RELEASE_ASSERT_NOT_REACHED();
@@ -177,8 +176,8 @@ void* CompleteSubspace::reallocatePreciseAllocationNonVirtual(VM& vm, HeapCell*
177176
oldAllocation->remove();
178177

179178
PreciseAllocation* allocation = oldAllocation->tryReallocate(size, this);
180-
if (!allocation) {
181-
RELEASE_ASSERT(failureMode != AllocationFailureMode::Assert);
179+
if (UNLIKELY(!allocation)) {
180+
RELEASE_ASSERT_RESOURCE_AVAILABLE(failureMode != AllocationFailureMode::Assert, MemoryExhaustion, "Crash intentionally because memory is exhausted.");
182181
m_preciseAllocations.append(oldAllocation);
183182
return nullptr;
184183
}

0 commit comments

Comments
 (0)