Commit 551d67a6 authored by Aleksey Kozyatinskiy's avatar Aleksey Kozyatinskiy Committed by Commit Bot

Revert "[heap] Support for minor MC marking during incremental marking"

This reverts commit d2c093bc.

Reason for revert: looks like it brokes try bot [1].

[1] https://build.chromium.org/p/client.v8/builders/V8%20Linux64%20-%20debug

Original change's description:
> [heap] Support for minor MC marking during incremental marking
> 
> BUG=chromium:651354
> 
> Change-Id: Ia8511723b17936b78b33ea685704237c100648e1
> Reviewed-on: https://chromium-review.googlesource.com/439285
> Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Reviewed-by: Hannes Payer <hpayer@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#43422}

TBR=ulan@chromium.org,hpayer@chromium.org,mlippautz@chromium.org,hablich@chromium.org,v8-reviews@googlegroups.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=chromium:651354

Change-Id: Ib5bada3ecf9d687568668b9a4ef4682bb665b8e1
Reviewed-on: https://chromium-review.googlesource.com/446977Reviewed-by: 's avatarAleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43424}
parent 0ccb0281
......@@ -644,6 +644,7 @@ DEFINE_INT(min_progress_during_incremental_marking_finalization, 32,
DEFINE_INT(max_incremental_marking_finalization_rounds, 3,
"at most try this many times to finalize incremental marking")
DEFINE_BOOL(minor_mc, false, "perform young generation mark compact GCs")
DEFINE_NEG_IMPLICATION(minor_mc, incremental_marking)
DEFINE_BOOL(black_allocation, true, "use black allocation")
DEFINE_BOOL(concurrent_sweeping, true, "use concurrent sweeping")
DEFINE_BOOL(parallel_compaction, true, "use parallel compaction")
......
......@@ -12,11 +12,10 @@
namespace v8 {
namespace internal {
template <MarkingMode mode>
void MarkCompactCollector::PushBlack(HeapObject* obj) {
DCHECK(ObjectMarking::IsBlack<mode>(obj));
if (!marking_deque<mode>()->Push(obj)) {
ObjectMarking::BlackToGrey<mode>(obj);
DCHECK(ObjectMarking::IsBlack(obj));
if (!marking_deque()->Push(obj)) {
ObjectMarking::BlackToGrey(obj);
}
}
......@@ -28,11 +27,10 @@ void MarkCompactCollector::UnshiftBlack(HeapObject* obj) {
}
}
template <MarkingMode mode>
void MarkCompactCollector::MarkObject(HeapObject* obj) {
if (ObjectMarking::IsWhite<mode>(obj)) {
ObjectMarking::WhiteToBlack<mode>(obj);
PushBlack<mode>(obj);
if (ObjectMarking::IsWhite(obj)) {
ObjectMarking::WhiteToBlack(obj);
PushBlack(obj);
}
}
......
This diff is collapsed.
......@@ -17,6 +17,8 @@
namespace v8 {
namespace internal {
enum class MarkCompactMode { FULL, YOUNG_GENERATION };
// Callback function, returns whether an object is alive. The heap size
// of the object is returned in size. It optionally updates the offset
// to the first live object in the page (only used for old and map objects).
......@@ -29,103 +31,87 @@ typedef void (*MarkObjectFunction)(Heap* heap, HeapObject* object);
class CodeFlusher;
class MarkCompactCollector;
class MarkingVisitor;
template <MarkingMode mode>
template <MarkCompactMode mode>
class RootMarkingVisitor;
class ObjectMarking : public AllStatic {
public:
template <MarkingMode mode = MarkingMode::FULL>
V8_INLINE static MarkBit MarkBitFrom(HeapObject* obj) {
const Address address = obj->address();
const MemoryChunk* p = MemoryChunk::FromAddress(address);
return p->markbits<mode>()->MarkBitFromIndex(
p->AddressToMarkbitIndex(address));
MemoryChunk* p = MemoryChunk::FromAddress(address);
return p->markbits()->MarkBitFromIndex(p->AddressToMarkbitIndex(address));
}
template <MarkingMode mode = MarkingMode::FULL>
V8_INLINE static Marking::ObjectColor Color(HeapObject* obj) {
return Marking::Color(ObjectMarking::MarkBitFrom<mode>(obj));
static Marking::ObjectColor Color(HeapObject* obj) {
return Marking::Color(ObjectMarking::MarkBitFrom(obj));
}
template <MarkingMode mode = MarkingMode::FULL>
V8_INLINE static bool IsImpossible(HeapObject* obj) {
return Marking::IsImpossible(MarkBitFrom<mode>(obj));
return Marking::IsImpossible(MarkBitFrom(obj));
}
template <MarkingMode mode = MarkingMode::FULL>
V8_INLINE static bool IsBlack(HeapObject* obj) {
return Marking::IsBlack(MarkBitFrom<mode>(obj));
return Marking::IsBlack(MarkBitFrom(obj));
}
template <MarkingMode mode = MarkingMode::FULL>
V8_INLINE static bool IsWhite(HeapObject* obj) {
return Marking::IsWhite(MarkBitFrom<mode>(obj));
return Marking::IsWhite(MarkBitFrom(obj));
}
template <MarkingMode mode = MarkingMode::FULL>
V8_INLINE static bool IsGrey(HeapObject* obj) {
return Marking::IsGrey(MarkBitFrom<mode>(obj));
return Marking::IsGrey(MarkBitFrom(obj));
}
template <MarkingMode mode = MarkingMode::FULL>
V8_INLINE static bool IsBlackOrGrey(HeapObject* obj) {
return Marking::IsBlackOrGrey(MarkBitFrom<mode>(obj));
return Marking::IsBlackOrGrey(MarkBitFrom(obj));
}
template <MarkingMode mode = MarkingMode::FULL>
V8_INLINE static void ClearMarkBit(HeapObject* obj) {
Marking::MarkWhite(MarkBitFrom<mode>(obj));
Marking::MarkWhite(MarkBitFrom(obj));
}
template <MarkingMode mode = MarkingMode::FULL>
V8_INLINE static void BlackToWhite(HeapObject* obj) {
DCHECK(IsBlack<mode>(obj));
MarkBit markbit = MarkBitFrom<mode>(obj);
DCHECK(IsBlack(obj));
MarkBit markbit = MarkBitFrom(obj);
Marking::BlackToWhite(markbit);
MemoryChunk::IncrementLiveBytes<mode>(obj, -obj->Size());
MemoryChunk::IncrementLiveBytes(obj, -obj->Size());
}
template <MarkingMode mode = MarkingMode::FULL>
V8_INLINE static void GreyToWhite(HeapObject* obj) {
DCHECK(IsGrey<mode>(obj));
Marking::GreyToWhite(MarkBitFrom<mode>(obj));
DCHECK(IsGrey(obj));
Marking::GreyToWhite(MarkBitFrom(obj));
}
template <MarkingMode mode = MarkingMode::FULL>
V8_INLINE static void BlackToGrey(HeapObject* obj) {
DCHECK(IsBlack<mode>(obj));
MarkBit markbit = MarkBitFrom<mode>(obj);
DCHECK(IsBlack(obj));
MarkBit markbit = MarkBitFrom(obj);
Marking::BlackToGrey(markbit);
MemoryChunk::IncrementLiveBytes<mode>(obj, -obj->Size());
MemoryChunk::IncrementLiveBytes(obj, -obj->Size());
}
template <MarkingMode mode = MarkingMode::FULL>
V8_INLINE static void WhiteToGrey(HeapObject* obj) {
DCHECK(IsWhite<mode>(obj));
Marking::WhiteToGrey(MarkBitFrom<mode>(obj));
DCHECK(IsWhite(obj));
Marking::WhiteToGrey(MarkBitFrom(obj));
}
template <MarkingMode mode = MarkingMode::FULL>
V8_INLINE static void WhiteToBlack(HeapObject* obj) {
DCHECK(IsWhite<mode>(obj));
MarkBit markbit = MarkBitFrom<mode>(obj);
DCHECK(IsWhite(obj));
MarkBit markbit = MarkBitFrom(obj);
Marking::WhiteToBlack(markbit);
MemoryChunk::IncrementLiveBytes<mode>(obj, obj->Size());
MemoryChunk::IncrementLiveBytes(obj, obj->Size());
}
template <MarkingMode mode = MarkingMode::FULL>
V8_INLINE static void GreyToBlack(HeapObject* obj) {
DCHECK(IsGrey<mode>(obj));
MarkBit markbit = MarkBitFrom<mode>(obj);
DCHECK(IsGrey(obj));
MarkBit markbit = MarkBitFrom(obj);
Marking::GreyToBlack(markbit);
MemoryChunk::IncrementLiveBytes<mode>(obj, obj->Size());
MemoryChunk::IncrementLiveBytes(obj, obj->Size());
}
template <MarkingMode mode = MarkingMode::FULL>
V8_INLINE static void AnyToGrey(HeapObject* obj) {
MarkBit markbit = MarkBitFrom<mode>(obj);
MarkBit markbit = MarkBitFrom(obj);
if (Marking::IsBlack(markbit)) {
MemoryChunk::IncrementLiveBytes<mode>(obj, -obj->Size());
MemoryChunk::IncrementLiveBytes(obj, -obj->Size());
}
Marking::AnyToGrey(markbit);
}
......@@ -587,11 +573,7 @@ class MarkCompactCollector {
// is marked.
void MarkImplicitRefGroups(MarkObjectFunction mark_object);
template <MarkingMode mode = MarkingMode::FULL>
MarkingDeque* marking_deque() {
return mode == MarkingMode::FULL ? &marking_deque_
: &marking_deque_young_generation_;
}
MarkingDeque* marking_deque() { return &marking_deque_; }
Sweeper& sweeper() { return sweeper_; }
......@@ -649,7 +631,7 @@ class MarkCompactCollector {
friend class MarkCompactMarkingVisitor;
friend class MarkingVisitor;
friend class RecordMigratedSlotVisitor;
template <MarkingMode mode>
template <MarkCompactMode mode>
friend class RootMarkingVisitor;
friend class SharedFunctionInfoMarkingVisitor;
friend class StaticYoungGenerationMarkingVisitor;
......@@ -667,28 +649,26 @@ class MarkCompactCollector {
// Pushes a black object onto the marking stack and accounts for live bytes.
// Note that this assumes live bytes have not yet been counted.
template <MarkingMode mode = MarkingMode::FULL>
V8_INLINE void PushBlack(HeapObject* obj);
INLINE(void PushBlack(HeapObject* obj));
// Unshifts a black object into the marking stack and accounts for live bytes.
// Note that this assumes lives bytes have already been counted.
V8_INLINE void UnshiftBlack(HeapObject* obj);
INLINE(void UnshiftBlack(HeapObject* obj));
// Marks the object black and pushes it on the marking stack.
// This is for non-incremental marking only.
template <MarkingMode mode = MarkingMode::FULL>
V8_INLINE void MarkObject(HeapObject* obj);
INLINE(void MarkObject(HeapObject* obj));
// Mark the heap roots and all objects reachable from them.
void MarkRoots(RootMarkingVisitor<MarkingMode::FULL>* visitor);
void MarkRoots(RootMarkingVisitor<MarkCompactMode::FULL>* visitor);
// Mark the string table specially. References to internalized strings from
// the string table are weak.
void MarkStringTable(RootMarkingVisitor<MarkingMode::FULL>* visitor);
void MarkStringTable(RootMarkingVisitor<MarkCompactMode::FULL>* visitor);
// Mark objects reachable (transitively) from objects in the marking stack
// or overflowed in the heap.
template <MarkingMode mode>
template <MarkCompactMode mode>
void ProcessMarkingDeque();
// Mark objects reachable (transitively) from objects in the marking stack
......@@ -712,13 +692,13 @@ class MarkCompactCollector {
// stack. This function empties the marking stack, but may leave
// overflowed objects in the heap, in which case the marking stack's
// overflow flag will be set.
template <MarkingMode mode>
template <MarkCompactMode mode>
void EmptyMarkingDeque();
// Refill the marking stack with overflowed objects from the heap. This
// function either leaves the marking stack full or clears the overflow
// flag on the marking stack.
template <MarkingMode mode>
template <MarkCompactMode mode>
void RefillMarkingDeque();
// Helper methods for refilling the marking stack by discovering grey objects
......@@ -836,7 +816,6 @@ class MarkCompactCollector {
bool have_code_to_deoptimize_;
MarkingDeque marking_deque_;
MarkingDeque marking_deque_young_generation_;
CodeFlusher* code_flusher_;
......
......@@ -226,52 +226,27 @@ void Page::InitializeFreeListCategories() {
}
}
template <MarkingMode mode>
void MemoryChunk::IncrementLiveBytes(HeapObject* object, int by) {
MemoryChunk::FromAddress(object->address())->IncrementLiveBytes<mode>(by);
MemoryChunk::FromAddress(object->address())->IncrementLiveBytes(by);
}
template <MarkingMode mode>
void MemoryChunk::TraceLiveBytes(intptr_t old_value, intptr_t new_value) {
if (!FLAG_trace_live_bytes) return;
PrintIsolate(heap()->isolate(),
"live-bytes[%p:%s]: %" V8PRIdPTR "-> %" V8PRIdPTR "\n",
static_cast<void*>(this),
mode == MarkingMode::FULL ? "internal" : "external", old_value,
new_value);
}
template <MarkingMode mode>
void MemoryChunk::ResetLiveBytes() {
switch (mode) {
case MarkingMode::FULL:
TraceLiveBytes(live_byte_count_, 0);
live_byte_count_ = 0;
break;
case MarkingMode::YOUNG_GENERATION:
TraceLiveBytes(young_generation_live_byte_count_, 0);
young_generation_live_byte_count_ = 0;
break;
if (FLAG_trace_live_bytes) {
PrintIsolate(heap()->isolate(), "live-bytes: reset page=%p %d->0\n",
static_cast<void*>(this), live_byte_count_);
}
live_byte_count_ = 0;
}
template <MarkingMode mode>
void MemoryChunk::IncrementLiveBytes(int by) {
switch (mode) {
case MarkingMode::FULL:
TraceLiveBytes(live_byte_count_, live_byte_count_ + by);
if (FLAG_trace_live_bytes) {
PrintIsolate(
heap()->isolate(), "live-bytes: update page=%p delta=%d %d->%d\n",
static_cast<void*>(this), by, live_byte_count_, live_byte_count_ + by);
}
live_byte_count_ += by;
DCHECK_GE(live_byte_count_, 0);
DCHECK_LE(static_cast<size_t>(live_byte_count_), size_);
break;
case MarkingMode::YOUNG_GENERATION:
TraceLiveBytes(young_generation_live_byte_count_,
young_generation_live_byte_count_ + by);
young_generation_live_byte_count_ += by;
DCHECK_GE(young_generation_live_byte_count_, 0);
DCHECK_LE(static_cast<size_t>(young_generation_live_byte_count_), size_);
break;
}
}
bool PagedSpace::Contains(Address addr) {
......
......@@ -538,8 +538,8 @@ MemoryChunk* MemoryChunk::Initialize(Heap* heap, Address base, size_t size,
chunk->mutex_ = new base::Mutex();
chunk->available_in_free_list_ = 0;
chunk->wasted_memory_ = 0;
chunk->ResetLiveBytes();
chunk->ClearLiveness();
chunk->young_generation_bitmap_ = nullptr;
chunk->set_next_chunk(nullptr);
chunk->set_prev_chunk(nullptr);
chunk->local_tracker_ = nullptr;
......@@ -1119,7 +1119,6 @@ void MemoryChunk::ReleaseAllocatedMemory() {
if (typed_old_to_new_slots_.Value() != nullptr) ReleaseTypedOldToNewSlots();
if (typed_old_to_old_slots_ != nullptr) ReleaseTypedOldToOldSlots();
if (local_tracker_ != nullptr) ReleaseLocalTracker();
if (young_generation_bitmap_ != nullptr) ReleaseExternalBitmap();
}
static SlotSet* AllocateSlotSet(size_t size, Address page_start) {
......@@ -1185,18 +1184,6 @@ void MemoryChunk::ReleaseLocalTracker() {
local_tracker_ = nullptr;
}
void MemoryChunk::AllocateExternalBitmap() {
DCHECK_NULL(young_generation_bitmap_);
young_generation_bitmap_ = static_cast<Bitmap*>(calloc(1, Bitmap::kSize));
young_generation_live_byte_count_ = 0;
}
void MemoryChunk::ReleaseExternalBitmap() {
DCHECK_NOT_NULL(young_generation_bitmap_);
free(young_generation_bitmap_);
young_generation_bitmap_ = nullptr;
}
void MemoryChunk::ClearLiveness() {
markbits()->Clear();
ResetLiveBytes();
......
......@@ -224,10 +224,6 @@ class FreeListCategory {
friend class PagedSpace;
};
// MarkingMode determines which bitmaps and counters should be used when
// accessing marking information on MemoryChunk.
enum class MarkingMode { FULL, YOUNG_GENERATION };
// MemoryChunk represents a memory region owned by a specific space.
// It is divided into the header and the body. Chunk start is always
// 1MB aligned. Start of the body is aligned so it can accommodate
......@@ -327,8 +323,8 @@ class MemoryChunk {
static const intptr_t kReservationOffset = kAreaEndOffset + kPointerSize;
static const intptr_t kOwnerOffset = kReservationOffset + 2 * kPointerSize;
static const size_t kMinHeaderSize = kSizeOffset // NOLINT
+ kSizetSize // size_t size
static const size_t kMinHeaderSize =
kSizeOffset + kSizetSize // size_t size
+ kIntptrSize // Flags flags_
+ kPointerSize // Address area_start_
+ kPointerSize // Address area_end_
......@@ -348,11 +344,9 @@ class MemoryChunk {
+ 2 * kSizetSize // AtomicNumber free-list statistics
+ kPointerSize // AtomicValue next_chunk_
+ kPointerSize // AtomicValue prev_chunk_
+ FreeListCategory::kSize * kNumberOfCategories
// FreeListCategory categories_[kNumberOfCategories]
+ kPointerSize // LocalArrayBufferTracker* local_tracker_
+ kIntptrSize // intptr_t young_generation_live_byte_count_
+ kPointerSize; // Bitmap* young_generation_bitmap_
+ FreeListCategory::kSize * kNumberOfCategories +
kPointerSize; // LocalArrayBufferTracker* local_tracker_
// We add some more space to the computed header size to amount for missing
// alignment requirements in our computation.
......@@ -376,7 +370,6 @@ class MemoryChunk {
static const int kAllocatableMemory = kPageSize - kObjectStartOffset;
template <MarkingMode mode = MarkingMode::FULL>
static inline void IncrementLiveBytes(HeapObject* object, int by);
// Only works if the pointer is in the first kPageSize of the MemoryChunk.
......@@ -402,9 +395,7 @@ class MemoryChunk {
static bool IsValid(MemoryChunk* chunk) { return chunk != nullptr; }
Address address() const {
return reinterpret_cast<Address>(const_cast<MemoryChunk*>(this));
}
Address address() { return reinterpret_cast<Address>(this); }
base::Mutex* mutex() { return mutex_; }
......@@ -427,24 +418,12 @@ class MemoryChunk {
}
// Manage live byte count, i.e., count of bytes in black objects.
template <MarkingMode mode = MarkingMode::FULL>
inline void ResetLiveBytes();
template <MarkingMode mode = MarkingMode::FULL>
inline void IncrementLiveBytes(int by);
template <MarkingMode mode = MarkingMode::FULL>
int LiveBytes() {
switch (mode) {
case MarkingMode::FULL:
DCHECK_LE(static_cast<unsigned>(live_byte_count_), size_);
return live_byte_count_;
case MarkingMode::YOUNG_GENERATION:
DCHECK_LE(static_cast<unsigned>(young_generation_live_byte_count_),
size_);
return static_cast<int>(young_generation_live_byte_count_);
}
UNREACHABLE();
return 0;
}
void SetLiveBytes(int live_bytes) {
......@@ -482,8 +461,6 @@ class MemoryChunk {
void ReleaseTypedOldToOldSlots();
void AllocateLocalTracker();
void ReleaseLocalTracker();
void AllocateExternalBitmap();
void ReleaseExternalBitmap();
Address area_start() { return area_start_; }
Address area_end() { return area_end_; }
......@@ -512,18 +489,15 @@ class MemoryChunk {
}
}
template <MarkingMode mode = MarkingMode::FULL>
inline Bitmap* markbits() const {
return mode == MarkingMode::FULL
? Bitmap::FromAddress(address() + kHeaderSize)
: young_generation_bitmap_;
inline Bitmap* markbits() {
return Bitmap::FromAddress(address() + kHeaderSize);
}
inline uint32_t AddressToMarkbitIndex(Address addr) const {
inline uint32_t AddressToMarkbitIndex(Address addr) {
return static_cast<uint32_t>(addr - this->address()) >> kPointerSizeLog2;
}
inline Address MarkbitIndexToAddress(uint32_t index) const {
inline Address MarkbitIndexToAddress(uint32_t index) {
return this->address() + (index << kPointerSizeLog2);
}
......@@ -614,9 +588,6 @@ class MemoryChunk {
base::VirtualMemory* reserved_memory() { return &reservation_; }
template <MarkingMode mode = MarkingMode::FULL>
inline void TraceLiveBytes(intptr_t old_value, intptr_t new_value);
size_t size_;
Flags flags_;
......@@ -672,9 +643,6 @@ class MemoryChunk {
LocalArrayBufferTracker* local_tracker_;
intptr_t young_generation_live_byte_count_;
Bitmap* young_generation_bitmap_;
private:
void InitializeReservedMemory() { reservation_.Reset(); }
......@@ -2675,9 +2643,6 @@ class NewSpace : public Space {
std::unique_ptr<ObjectIterator> GetObjectIterator() override;
SemiSpace& from_space() { return from_space_; }
SemiSpace& to_space() { return to_space_; }
private:
// Update allocation info to match the current to-space page.
void UpdateAllocationInfo();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment