[heap] MarkCompact marking: Avoid atomics on live byte count

Similar to the incremental marker, rename the MarkingState to
MajorMarkingState and avoid using atomics on live byte count as the
concurrent tasks cache its value.

CQ_INCLUDE_TRYBOTS=master.tryserver.v8:v8_linux64_tsan_rel;master.tryserver.v8:v8_linux64_tsan_concurrent_marking_rel_ng;master.tryserver.blink:linux_trusty_blink_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel

Bug: chromium:750084
Change-Id: Id37bb89385d4fbae95542073ea652617e61010d5
Reviewed-on: https://chromium-review.googlesource.com/735399
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48885}
This commit is contained in:
Michael Lippautz 2017-10-24 11:01:25 +02:00 committed by Commit Bot
parent e18ebb6064
commit af424eeab1
5 changed files with 41 additions and 35 deletions

View File

@ -21,28 +21,6 @@ class PagedSpace;
enum class StepOrigin { kV8, kTask };
// This marking state is used when concurrent marking is running.
class IncrementalMarkingState final
: public MarkingStateBase<IncrementalMarkingState, AccessMode::ATOMIC> {
public:
Bitmap* bitmap(const MemoryChunk* chunk) const {
return Bitmap::FromAddress(chunk->address() + MemoryChunk::kHeaderSize);
}
// Concurrent marking uses local live bytes.
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 };
@ -57,7 +35,7 @@ class V8_EXPORT_PRIVATE IncrementalMarking {
using MarkingState = IncrementalMarkingState;
#else
using MarkingState = MajorNonAtomicMarkingState;
#endif
#endif // V8_CONCURRENT_MARKING
using AtomicMarkingState = MajorAtomicMarkingState;
using NonAtomicMarkingState = MajorNonAtomicMarkingState;

View File

@ -316,7 +316,7 @@ void MarkingVisitor<fixed_array_mode, retaining_path_mode,
}
void MarkCompactCollector::MarkObject(HeapObject* host, HeapObject* obj) {
if (atomic_marking_state()->WhiteToGrey(obj)) {
if (marking_state()->WhiteToGrey(obj)) {
marking_worklist()->Push(obj);
if (V8_UNLIKELY(FLAG_track_retaining_path)) {
heap_->AddRetainer(host, obj);
@ -325,7 +325,7 @@ void MarkCompactCollector::MarkObject(HeapObject* host, HeapObject* obj) {
}
void MarkCompactCollector::MarkRootObject(Root root, HeapObject* obj) {
if (atomic_marking_state()->WhiteToGrey(obj)) {
if (marking_state()->WhiteToGrey(obj)) {
marking_worklist()->Push(obj);
if (V8_UNLIKELY(FLAG_track_retaining_path)) {
heap_->AddRetainingRoot(root, obj);
@ -334,7 +334,7 @@ void MarkCompactCollector::MarkRootObject(Root root, HeapObject* obj) {
}
void MarkCompactCollector::MarkExternallyReferencedObject(HeapObject* obj) {
if (atomic_marking_state()->WhiteToGrey(obj)) {
if (marking_state()->WhiteToGrey(obj)) {
marking_worklist()->Push(obj);
if (V8_UNLIKELY(FLAG_track_retaining_path)) {
heap_->AddRetainingRoot(Root::kWrapperTracing, obj);

View File

@ -350,7 +350,8 @@ class YoungGenerationEvacuationVerifier : public EvacuationVerifier {
using MarkCompactMarkingVisitor =
MarkingVisitor<FixedArrayVisitationMode::kRegular,
TraceRetainingPathMode::kEnabled, MajorAtomicMarkingState>;
TraceRetainingPathMode::kEnabled,
MarkCompactCollector::MarkingState>;
namespace {
@ -1779,7 +1780,7 @@ void MarkCompactCollector::MarkStringTable(
ObjectVisitor* custom_root_body_visitor) {
StringTable* string_table = heap()->string_table();
// Mark the string table itself.
if (atomic_marking_state()->WhiteToBlack(string_table)) {
if (marking_state()->WhiteToBlack(string_table)) {
// Explicitly mark the prefix.
string_table->IteratePrefix(custom_root_body_visitor);
}
@ -1798,13 +1799,13 @@ void MarkCompactCollector::MarkRoots(RootVisitor* root_visitor,
void MarkCompactCollector::ProcessMarkingWorklist() {
HeapObject* object;
MarkCompactMarkingVisitor visitor(this, atomic_marking_state());
MarkCompactMarkingVisitor visitor(this, marking_state());
while ((object = marking_worklist()->Pop()) != nullptr) {
DCHECK(!object->IsFiller());
DCHECK(object->IsHeapObject());
DCHECK(heap()->Contains(object));
DCHECK(!(atomic_marking_state()->IsWhite(object)));
atomic_marking_state()->GreyToBlack(object);
DCHECK(!(marking_state()->IsWhite(object)));
marking_state()->GreyToBlack(object);
Map* map = object->map();
MarkObject(object, map);
visitor.Visit(map, object);
@ -2849,7 +2850,7 @@ void MarkCompactCollector::TrimEnumCache(Map* map,
void MarkCompactCollector::ProcessWeakCollections() {
MarkCompactMarkingVisitor visitor(this, atomic_marking_state());
MarkCompactMarkingVisitor visitor(this, marking_state());
Object* weak_collection_obj = heap()->encountered_weak_collections();
while (weak_collection_obj != Smi::kZero) {
JSWeakCollection* weak_collection =

View File

@ -423,6 +423,28 @@ class MinorMarkCompactCollector final : public MarkCompactCollectorBase {
friend class YoungGenerationMarkingVisitor;
};
// This marking state is used when concurrent marking is running.
class IncrementalMarkingState final
: public MarkingStateBase<IncrementalMarkingState, AccessMode::ATOMIC> {
public:
Bitmap* bitmap(const MemoryChunk* chunk) const {
return Bitmap::FromAddress(chunk->address() + MemoryChunk::kHeaderSize);
}
// Concurrent marking uses local live bytes.
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 MajorAtomicMarkingState final
: public MarkingStateBase<MajorAtomicMarkingState, AccessMode::ATOMIC> {
public:
@ -477,7 +499,11 @@ struct WeakObjects {
// Collector for young and old generation.
class MarkCompactCollector final : public MarkCompactCollectorBase {
public:
using AtomicMarkingState = MajorAtomicMarkingState;
#ifdef V8_CONCURRENT_MARKING
using MarkingState = IncrementalMarkingState;
#else
using MarkingState = MajorNonAtomicMarkingState;
#endif // V8_CONCURRENT_MARKING
using NonAtomicMarkingState = MajorNonAtomicMarkingState;
static const int kMainThread = 0;
@ -730,7 +756,7 @@ class MarkCompactCollector final : public MarkCompactCollectorBase {
kClearMarkbits,
};
AtomicMarkingState* atomic_marking_state() { return &atomic_marking_state_; }
MarkingState* marking_state() { return &marking_state_; }
NonAtomicMarkingState* non_atomic_marking_state() {
return &non_atomic_marking_state_;
@ -982,7 +1008,7 @@ class MarkCompactCollector final : public MarkCompactCollectorBase {
Sweeper sweeper_;
AtomicMarkingState atomic_marking_state_;
MarkingState marking_state_;
NonAtomicMarkingState non_atomic_marking_state_;
friend class FullEvacuator;

View File

@ -724,6 +724,7 @@ class MemoryChunk {
friend class ConcurrentMarkingState;
friend class IncrementalMarkingState;
friend class MajorAtomicMarkingState;
friend class MajorMarkingState;
friend class MajorNonAtomicMarkingState;
friend class MemoryAllocator;
friend class MemoryChunkValidator;