[heap] Adjust condition for AdjustLiveBytes to avoid concurrent access w/ sweeper
A concurrent sweeper thread can access the same markbit cell as the main thread during right trimming a fixed array, resulting in a data race on a markbit cell. Previously we checked whether we were currently marking incrementally, filtering out this case. The current check has the benefit of keeping live_bytes accurate (modulo other bugs) until the sweeper starts. BUG=chromium:576193 LOG=N Review URL: https://codereview.chromium.org/1576853002 Cr-Commit-Position: refs/heads/master@{#33203}
This commit is contained in:
parent
3ae141c121
commit
779aa924f6
@ -3109,6 +3109,7 @@ void Heap::AdjustLiveBytes(HeapObject* object, int by, InvocationMode mode) {
|
|||||||
// update while using HeapIterator because the iterator is temporarily
|
// update while using HeapIterator because the iterator is temporarily
|
||||||
// marking the whole object graph, without updating live bytes.
|
// marking the whole object graph, without updating live bytes.
|
||||||
if (!in_heap_iterator() &&
|
if (!in_heap_iterator() &&
|
||||||
|
!mark_compact_collector()->sweeping_in_progress() &&
|
||||||
Marking::IsBlack(Marking::MarkBitFrom(object->address()))) {
|
Marking::IsBlack(Marking::MarkBitFrom(object->address()))) {
|
||||||
if (mode == SEQUENTIAL_TO_SWEEPER) {
|
if (mode == SEQUENTIAL_TO_SWEEPER) {
|
||||||
MemoryChunk::IncrementLiveBytesFromGC(object, by);
|
MemoryChunk::IncrementLiveBytesFromGC(object, by);
|
||||||
|
@ -3982,6 +3982,7 @@ void MarkCompactCollector::SweepSpaces() {
|
|||||||
MoveEvacuationCandidatesToEndOfPagesList();
|
MoveEvacuationCandidatesToEndOfPagesList();
|
||||||
|
|
||||||
{
|
{
|
||||||
|
sweeping_in_progress_ = true;
|
||||||
{
|
{
|
||||||
GCTracer::Scope sweep_scope(heap()->tracer(),
|
GCTracer::Scope sweep_scope(heap()->tracer(),
|
||||||
GCTracer::Scope::MC_SWEEP_OLD);
|
GCTracer::Scope::MC_SWEEP_OLD);
|
||||||
@ -3997,7 +3998,6 @@ void MarkCompactCollector::SweepSpaces() {
|
|||||||
GCTracer::Scope::MC_SWEEP_MAP);
|
GCTracer::Scope::MC_SWEEP_MAP);
|
||||||
StartSweepSpace(heap()->map_space());
|
StartSweepSpace(heap()->map_space());
|
||||||
}
|
}
|
||||||
sweeping_in_progress_ = true;
|
|
||||||
if (FLAG_concurrent_sweeping) {
|
if (FLAG_concurrent_sweeping) {
|
||||||
StartSweeperThreads();
|
StartSweeperThreads();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user