[heap] Share marking state between incremental marking and full GC.

Bug: chromium:694255
Change-Id: I076a41230c559d5aa8540753bb3c42b46bc66ff1
Reviewed-on: https://chromium-review.googlesource.com/620664
Reviewed-by: Michael Lippautz <mlippautz@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47423}
This commit is contained in:
Ulan Degenbaev 2017-08-18 11:36:14 +02:00 committed by Commit Bot
parent 21db1fafbc
commit d8a939624e
3 changed files with 29 additions and 52 deletions

View File

@ -22,52 +22,6 @@ class PagedSpace;
enum class StepOrigin { kV8, kTask };
class IncrementalAtomicMarkingState final
: public MarkingStateBase<IncrementalAtomicMarkingState,
AccessMode::ATOMIC> {
public:
Bitmap* bitmap(const MemoryChunk* chunk) const {
return Bitmap::FromAddress(chunk->address() + MemoryChunk::kHeaderSize);
}
void IncrementLiveBytes(MemoryChunk* chunk, intptr_t by) {
reinterpret_cast<base::AtomicNumber<intptr_t>*>(&chunk->live_byte_count_)
->Increment(by);
}
intptr_t live_bytes(MemoryChunk* chunk) const {
return reinterpret_cast<base::AtomicNumber<intptr_t>*>(
&chunk->live_byte_count_)
->Value();
}
void SetLiveBytes(MemoryChunk* chunk, intptr_t value) {
reinterpret_cast<base::AtomicNumber<intptr_t>*>(&chunk->live_byte_count_)
->SetValue(value);
}
};
class IncrementalNonAtomicMarkingState final
: public MarkingStateBase<IncrementalNonAtomicMarkingState,
AccessMode::NON_ATOMIC> {
public:
Bitmap* bitmap(const MemoryChunk* chunk) const {
return Bitmap::FromAddress(chunk->address() + MemoryChunk::kHeaderSize);
}
void IncrementLiveBytes(MemoryChunk* chunk, intptr_t by) {
chunk->live_byte_count_ += by;
}
intptr_t live_bytes(MemoryChunk* chunk) const {
return chunk->live_byte_count_;
}
void SetLiveBytes(MemoryChunk* chunk, intptr_t value) {
chunk->live_byte_count_ = value;
}
};
class V8_EXPORT_PRIVATE IncrementalMarking {
public:
enum State { STOPPED, SWEEPING, MARKING, COMPLETE };
@ -79,12 +33,12 @@ class V8_EXPORT_PRIVATE IncrementalMarking {
enum GCRequestType { NONE, COMPLETE_MARKING, FINALIZATION };
#ifdef V8_CONCURRENT_MARKING
using MarkingState = IncrementalAtomicMarkingState;
using MarkingState = MajorAtomicMarkingState;
#else
using MarkingState = IncrementalNonAtomicMarkingState;
using MarkingState = MajorNonAtomicMarkingState;
#endif
using AtomicMarkingState = IncrementalAtomicMarkingState;
using NonAtomicMarkingState = IncrementalNonAtomicMarkingState;
using AtomicMarkingState = MajorAtomicMarkingState;
using NonAtomicMarkingState = MajorNonAtomicMarkingState;
class PauseBlackAllocationScope {
public:

View File

@ -432,6 +432,30 @@ class MinorMarkCompactCollector final : public MarkCompactCollectorBase {
friend class YoungGenerationMarkingVisitor;
};
class MajorAtomicMarkingState final
: public MarkingStateBase<MajorAtomicMarkingState, AccessMode::ATOMIC> {
public:
Bitmap* bitmap(const MemoryChunk* chunk) const {
return Bitmap::FromAddress(chunk->address() + MemoryChunk::kHeaderSize);
}
void IncrementLiveBytes(MemoryChunk* chunk, intptr_t by) {
reinterpret_cast<base::AtomicNumber<intptr_t>*>(&chunk->live_byte_count_)
->Increment(by);
}
intptr_t live_bytes(MemoryChunk* chunk) const {
return reinterpret_cast<base::AtomicNumber<intptr_t>*>(
&chunk->live_byte_count_)
->Value();
}
void SetLiveBytes(MemoryChunk* chunk, intptr_t value) {
reinterpret_cast<base::AtomicNumber<intptr_t>*>(&chunk->live_byte_count_)
->SetValue(value);
}
};
class MajorNonAtomicMarkingState final
: public MarkingStateBase<MajorNonAtomicMarkingState,
AccessMode::NON_ATOMIC> {

View File

@ -699,8 +699,7 @@ class MemoryChunk {
void InitializeReservedMemory() { reservation_.Reset(); }
friend class ConcurrentMarkingState;
friend class IncrementalAtomicMarkingState;
friend class IncrementalNonAtomicMarkingState;
friend class MajorAtomicMarkingState;
friend class MajorNonAtomicMarkingState;
friend class MemoryAllocator;
friend class MemoryChunkValidator;