Index: src/heap/mark-compact.cc |
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc |
index f95b91ac4db80791a7cf2dc9ea408e9369a1286e..6aa40877bced1be6cfb8d0942206f0978d685e89 100644 |
--- a/src/heap/mark-compact.cc |
+++ b/src/heap/mark-compact.cc |
@@ -1867,6 +1867,10 @@ int MarkCompactCollector::DiscoverAndEvacuateBlackObjectsOnPage( |
Object* target = allocation.ToObjectChecked(); |
MigrateObject(HeapObject::cast(target), object, size, NEW_SPACE); |
+ if (V8_UNLIKELY(target->IsJSArrayBuffer())) { |
+ heap()->RegisterLiveArrayBuffer( |
+ true, JSArrayBuffer::cast(target)->backing_store()); |
+ } |
heap()->IncrementSemiSpaceCopiedObjectSize(size); |
} |
*cells = 0; |
@@ -4431,10 +4435,13 @@ void MarkCompactCollector::SweepSpaces() { |
// buffer entries are already filter out. We can just release the memory. |
heap()->FreeQueuedChunks(); |
- heap()->FreeDeadArrayBuffers(false); |
- |
EvacuateNewSpaceAndCandidates(); |
+ // EvacuateNewSpaceAndCandidates iterates over new space objects and for |
+ // ArrayBuffers either re-registers them as live or promotes them. This is |
+ // needed to properly free them. |
+ heap()->FreeDeadArrayBuffers(false); |
+ |
// Clear the marking state of live large objects. |
heap_->lo_space()->ClearMarkingStateOfLiveObjects(); |