Index: src/heap/heap.cc |
diff --git a/src/heap/heap.cc b/src/heap/heap.cc |
index 267f474a3af4fe8946dcf3e0974a7cd682d18217..134ea24bf487c41e6e49eb428a46b870c3a60b0c 100644 |
--- a/src/heap/heap.cc |
+++ b/src/heap/heap.cc |
@@ -4229,7 +4229,23 @@ void Heap::RegisterReservationsForBlackAllocation(Reservation* reservations) { |
// TODO(hpayer): We do not have to iterate reservations on black objects |
// for marking. We just have to execute the special visiting side effect |
// code that adds objects to global data structures, e.g. for array buffers. |
+ |
+ // Code space, map space, and large object space do not use black pages. |
+ // Hence we have to color all objects of the reservation first black to avoid |
+ // unnecessary marking deque load. |
if (incremental_marking()->black_allocation()) { |
+ for (int i = CODE_SPACE; i < Serializer::kNumberOfSpaces; i++) { |
+ const Heap::Reservation& res = reservations[i]; |
+ for (auto& chunk : res) { |
+ Address addr = chunk.start; |
+ while (addr < chunk.end) { |
+ HeapObject* obj = HeapObject::FromAddress(addr); |
+ Marking::MarkBlack(Marking::MarkBitFrom(obj)); |
+ MemoryChunk::IncrementLiveBytesFromGC(obj, obj->Size()); |
+ addr += obj->Size(); |
+ } |
+ } |
+ } |
for (int i = OLD_SPACE; i < Serializer::kNumberOfSpaces; i++) { |
const Heap::Reservation& res = reservations[i]; |
for (auto& chunk : res) { |