| Index: src/heap/incremental-marking.cc
|
| diff --git a/src/heap/incremental-marking.cc b/src/heap/incremental-marking.cc
|
| index 0933530b10595d65a8d8eabe633cbcb7e462f068..fd58ef06a08f78fca205de119a38453bb51f3249 100644
|
| --- a/src/heap/incremental-marking.cc
|
| +++ b/src/heap/incremental-marking.cc
|
| @@ -39,12 +39,15 @@
|
|
|
| bool IncrementalMarking::BaseRecordWrite(HeapObject* obj, Object* value) {
|
| HeapObject* value_heap_obj = HeapObject::cast(value);
|
| - DCHECK(!ObjectMarking::IsImpossible(value_heap_obj));
|
| - DCHECK(!ObjectMarking::IsImpossible(obj));
|
| - const bool is_black = ObjectMarking::IsBlack(obj);
|
| -
|
| - if (is_black && ObjectMarking::IsWhite(value_heap_obj)) {
|
| - WhiteToGreyAndPush(value_heap_obj);
|
| + MarkBit value_bit = ObjectMarking::MarkBitFrom(value_heap_obj);
|
| + DCHECK(!Marking::IsImpossible(value_bit));
|
| +
|
| + MarkBit obj_bit = ObjectMarking::MarkBitFrom(obj);
|
| + DCHECK(!Marking::IsImpossible(obj_bit));
|
| + bool is_black = Marking::IsBlack(obj_bit);
|
| +
|
| + if (is_black && Marking::IsWhite(value_bit)) {
|
| + WhiteToGreyAndPush(value_heap_obj, value_bit);
|
| RestartIfNotMarking();
|
| }
|
| return is_compacting_ && is_black;
|
| @@ -115,8 +118,9 @@
|
| }
|
| }
|
|
|
| -void IncrementalMarking::WhiteToGreyAndPush(HeapObject* obj) {
|
| - ObjectMarking::WhiteToGrey(obj);
|
| +
|
| +void IncrementalMarking::WhiteToGreyAndPush(HeapObject* obj, MarkBit mark_bit) {
|
| + Marking::WhiteToGrey(mark_bit);
|
| heap_->mark_compact_collector()->marking_deque()->Push(obj);
|
| }
|
|
|
| @@ -124,13 +128,16 @@
|
| static void MarkObjectGreyDoNotEnqueue(Object* obj) {
|
| if (obj->IsHeapObject()) {
|
| HeapObject* heap_obj = HeapObject::cast(obj);
|
| - ObjectMarking::AnyToGrey(heap_obj);
|
| + MarkBit mark_bit = ObjectMarking::MarkBitFrom(HeapObject::cast(obj));
|
| + if (Marking::IsBlack(mark_bit)) {
|
| + MemoryChunk::IncrementLiveBytes(heap_obj, -heap_obj->Size());
|
| + }
|
| + Marking::AnyToGrey(mark_bit);
|
| }
|
| }
|
|
|
| void IncrementalMarking::TransferMark(Heap* heap, HeapObject* from,
|
| HeapObject* to) {
|
| - DCHECK(MemoryChunk::FromAddress(from->address())->SweepingDone());
|
| // This is only used when resizing an object.
|
| DCHECK(MemoryChunk::FromAddress(from->address()) ==
|
| MemoryChunk::FromAddress(to->address()));
|
| @@ -151,12 +158,11 @@
|
|
|
| if (Marking::IsBlack(old_mark_bit)) {
|
| Marking::BlackToWhite(old_mark_bit);
|
| - Marking::WhiteToBlack(new_mark_bit);
|
| + Marking::MarkBlack(new_mark_bit);
|
| return;
|
| } else if (Marking::IsGrey(old_mark_bit)) {
|
| Marking::GreyToWhite(old_mark_bit);
|
| - Marking::WhiteToGrey(new_mark_bit);
|
| - heap->mark_compact_collector()->marking_deque()->Push(to);
|
| + heap->incremental_marking()->WhiteToGreyAndPush(to, new_mark_bit);
|
| heap->incremental_marking()->RestartIfNotMarking();
|
| }
|
|
|
| @@ -204,10 +210,10 @@
|
| } while (scan_until_end && start_offset < object_size);
|
| chunk->set_progress_bar(start_offset);
|
| if (start_offset < object_size) {
|
| - if (ObjectMarking::IsGrey(object)) {
|
| + if (Marking::IsGrey(ObjectMarking::MarkBitFrom(object))) {
|
| heap->mark_compact_collector()->marking_deque()->Unshift(object);
|
| } else {
|
| - DCHECK(ObjectMarking::IsBlack(object));
|
| + DCHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(object)));
|
| heap->mark_compact_collector()->UnshiftBlack(object);
|
| }
|
| heap->incremental_marking()->NotifyIncompleteScanOfObject(
|
| @@ -259,8 +265,10 @@
|
| // Returns true if object needed marking and false otherwise.
|
| INLINE(static bool MarkObjectWithoutPush(Heap* heap, Object* obj)) {
|
| HeapObject* heap_object = HeapObject::cast(obj);
|
| - if (ObjectMarking::IsWhite(heap_object)) {
|
| - ObjectMarking::WhiteToBlack(heap_object);
|
| + MarkBit mark_bit = ObjectMarking::MarkBitFrom(heap_object);
|
| + if (Marking::IsWhite(mark_bit)) {
|
| + Marking::MarkBlack(mark_bit);
|
| + MemoryChunk::IncrementLiveBytes(heap_object, heap_object->Size());
|
| return true;
|
| }
|
| return false;
|
| @@ -268,7 +276,7 @@
|
| };
|
|
|
| void IncrementalMarking::IterateBlackObject(HeapObject* object) {
|
| - if (IsMarking() && ObjectMarking::IsBlack(object)) {
|
| + if (IsMarking() && Marking::IsBlack(ObjectMarking::MarkBitFrom(object))) {
|
| Page* page = Page::FromAddress(object->address());
|
| if ((page->owner() != nullptr) && (page->owner()->identity() == LO_SPACE)) {
|
| // IterateBlackObject requires us to visit the whole object.
|
| @@ -653,7 +661,8 @@
|
| }
|
| Object* constructor = map->GetConstructor();
|
| if (!constructor->IsHeapObject() ||
|
| - ObjectMarking::IsWhite(HeapObject::cast(constructor))) {
|
| + Marking::IsWhite(
|
| + ObjectMarking::MarkBitFrom(HeapObject::cast(constructor)))) {
|
| // The constructor is dead, no new objects with this map can
|
| // be created. Do not retain this map.
|
| return false;
|
| @@ -682,14 +691,16 @@
|
| int age = Smi::cast(retained_maps->Get(i + 1))->value();
|
| int new_age;
|
| Map* map = Map::cast(cell->value());
|
| + MarkBit map_mark = ObjectMarking::MarkBitFrom(map);
|
| if (i >= number_of_disposed_maps && !map_retaining_is_disabled &&
|
| - ObjectMarking::IsWhite(map)) {
|
| + Marking::IsWhite(map_mark)) {
|
| if (ShouldRetainMap(map, age)) {
|
| MarkGrey(heap(), map);
|
| }
|
| Object* prototype = map->prototype();
|
| if (age > 0 && prototype->IsHeapObject() &&
|
| - ObjectMarking::IsWhite(HeapObject::cast(prototype))) {
|
| + Marking::IsWhite(
|
| + ObjectMarking::MarkBitFrom(HeapObject::cast(prototype)))) {
|
| // The prototype is not marked, age the map.
|
| new_age = age - 1;
|
| } else {
|
| @@ -796,12 +807,15 @@
|
| // them.
|
| if (map_word.IsForwardingAddress()) {
|
| HeapObject* dest = map_word.ToForwardingAddress();
|
| - if (ObjectMarking::IsBlack(dest)) continue;
|
| + if (Marking::IsBlack(ObjectMarking::MarkBitFrom(dest))) continue;
|
| array[new_top] = dest;
|
| new_top = ((new_top + 1) & mask);
|
| DCHECK(new_top != marking_deque->bottom());
|
| - DCHECK(ObjectMarking::IsGrey(obj) ||
|
| - (obj->IsFiller() && ObjectMarking::IsWhite(obj)));
|
| +#ifdef DEBUG
|
| + MarkBit mark_bit = ObjectMarking::MarkBitFrom(obj);
|
| + DCHECK(Marking::IsGrey(mark_bit) ||
|
| + (obj->IsFiller() && Marking::IsWhite(mark_bit)));
|
| +#endif
|
| }
|
| } else if (obj->map() != filler_map) {
|
| // Skip one word filler objects that appear on the
|
| @@ -809,11 +823,14 @@
|
| array[new_top] = obj;
|
| new_top = ((new_top + 1) & mask);
|
| DCHECK(new_top != marking_deque->bottom());
|
| - DCHECK(ObjectMarking::IsGrey(obj) ||
|
| - (obj->IsFiller() && ObjectMarking::IsWhite(obj)) ||
|
| - (MemoryChunk::FromAddress(obj->address())
|
| - ->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR) &&
|
| - ObjectMarking::IsBlack(obj)));
|
| +#ifdef DEBUG
|
| + MarkBit mark_bit = ObjectMarking::MarkBitFrom(obj);
|
| + MemoryChunk* chunk = MemoryChunk::FromAddress(obj->address());
|
| + DCHECK(Marking::IsGrey(mark_bit) ||
|
| + (obj->IsFiller() && Marking::IsWhite(mark_bit)) ||
|
| + (chunk->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR) &&
|
| + Marking::IsBlack(mark_bit)));
|
| +#endif
|
| }
|
| }
|
| marking_deque->set_top(new_top);
|
| @@ -837,14 +854,17 @@
|
| }
|
|
|
| void IncrementalMarking::MarkGrey(Heap* heap, HeapObject* object) {
|
| - if (ObjectMarking::IsWhite(object)) {
|
| - heap->incremental_marking()->WhiteToGreyAndPush(object);
|
| + MarkBit mark_bit = ObjectMarking::MarkBitFrom(object);
|
| + if (Marking::IsWhite(mark_bit)) {
|
| + heap->incremental_marking()->WhiteToGreyAndPush(object, mark_bit);
|
| }
|
| }
|
|
|
| void IncrementalMarking::MarkBlack(HeapObject* obj, int size) {
|
| - if (ObjectMarking::IsBlack(obj)) return;
|
| - ObjectMarking::GreyToBlack(obj);
|
| + MarkBit mark_bit = ObjectMarking::MarkBitFrom(obj);
|
| + if (Marking::IsBlack(mark_bit)) return;
|
| + Marking::GreyToBlack(mark_bit);
|
| + MemoryChunk::IncrementLiveBytes(obj, size);
|
| }
|
|
|
| intptr_t IncrementalMarking::ProcessMarkingDeque(
|
| @@ -859,7 +879,8 @@
|
| // Left trimming may result in white filler objects on the marking deque.
|
| // Ignore these objects.
|
| if (obj->IsFiller()) {
|
| - DCHECK(ObjectMarking::IsImpossible(obj) || ObjectMarking::IsWhite(obj));
|
| + DCHECK(Marking::IsImpossible(ObjectMarking::MarkBitFrom(obj)) ||
|
| + Marking::IsWhite(ObjectMarking::MarkBitFrom(obj)));
|
| continue;
|
| }
|
|
|
| @@ -914,8 +935,10 @@
|
| HeapObject* cache = HeapObject::cast(
|
| Context::cast(context)->get(Context::NORMALIZED_MAP_CACHE_INDEX));
|
| if (!cache->IsUndefined(heap_->isolate())) {
|
| - if (ObjectMarking::IsGrey(cache)) {
|
| - ObjectMarking::GreyToBlack(cache);
|
| + MarkBit mark_bit = ObjectMarking::MarkBitFrom(cache);
|
| + if (Marking::IsGrey(mark_bit)) {
|
| + Marking::GreyToBlack(mark_bit);
|
| + MemoryChunk::IncrementLiveBytes(cache, cache->Size());
|
| }
|
| }
|
| context = Context::cast(context)->next_context_link();
|
|
|