Commit 8ad99053 authored by Dominik Inführ's avatar Dominik Inführ Committed by Commit Bot

[heap] Move GCTracer::SampleAllocation() invocation into safepoint

OldGenerationAllocationCounter() needs to be invoked in safepoint,
otherwise invocation races with background threads incrementing the
counter.

First landed in https://crrev.com/c/2235544 and relanded in https://crrev.com/c/2259854 because of regressions. This CL also invokes UpdateNewSpaceAllocationCounter() in the safepoint.

Bug: v8:10315
Change-Id: I6104bed0aad848250feecfe51d6d849b184a8842
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2260560
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68614}
parent 7043ffa2
...@@ -228,10 +228,6 @@ void GCTracer::Start(GarbageCollector collector, ...@@ -228,10 +228,6 @@ void GCTracer::Start(GarbageCollector collector,
if (start_counter_ != 1) return; if (start_counter_ != 1) return;
previous_ = current_; previous_ = current_;
double start_time = heap_->MonotonicallyIncreasingTimeInMs();
SampleAllocation(start_time, heap_->NewSpaceAllocationCounter(),
heap_->OldGenerationAllocationCounter(),
heap_->EmbedderAllocationCounter());
switch (collector) { switch (collector) {
case SCAVENGER: case SCAVENGER:
...@@ -252,7 +248,7 @@ void GCTracer::Start(GarbageCollector collector, ...@@ -252,7 +248,7 @@ void GCTracer::Start(GarbageCollector collector,
} }
current_.reduce_memory = heap_->ShouldReduceMemory(); current_.reduce_memory = heap_->ShouldReduceMemory();
current_.start_time = start_time; current_.start_time = heap_->MonotonicallyIncreasingTimeInMs();
current_.start_object_size = 0; current_.start_object_size = 0;
current_.start_memory_size = 0; current_.start_memory_size = 0;
current_.start_holes_size = 0; current_.start_holes_size = 0;
...@@ -281,6 +277,10 @@ void GCTracer::Start(GarbageCollector collector, ...@@ -281,6 +277,10 @@ void GCTracer::Start(GarbageCollector collector,
} }
void GCTracer::StartInSafepoint() { void GCTracer::StartInSafepoint() {
SampleAllocation(current_.start_time, heap_->NewSpaceAllocationCounter(),
heap_->OldGenerationAllocationCounter(),
heap_->EmbedderAllocationCounter());
current_.start_object_size = heap_->SizeOfObjects(); current_.start_object_size = heap_->SizeOfObjects();
current_.start_memory_size = heap_->memory_allocator()->Size(); current_.start_memory_size = heap_->memory_allocator()->Size();
current_.start_holes_size = CountTotalHolesSize(heap_); current_.start_holes_size = CountTotalHolesSize(heap_);
......
...@@ -862,7 +862,6 @@ void Heap::GarbageCollectionPrologue() { ...@@ -862,7 +862,6 @@ void Heap::GarbageCollectionPrologue() {
} else { } else {
maximum_size_scavenges_ = 0; maximum_size_scavenges_ = 0;
} }
UpdateNewSpaceAllocationCounter();
if (FLAG_track_retaining_path) { if (FLAG_track_retaining_path) {
retainer_.clear(); retainer_.clear();
ephemeron_retainer_.clear(); ephemeron_retainer_.clear();
...@@ -872,6 +871,7 @@ void Heap::GarbageCollectionPrologue() { ...@@ -872,6 +871,7 @@ void Heap::GarbageCollectionPrologue() {
} }
void Heap::GarbageCollectionPrologueInSafepoint() { void Heap::GarbageCollectionPrologueInSafepoint() {
UpdateNewSpaceAllocationCounter();
CheckNewSpaceExpansionCriteria(); CheckNewSpaceExpansionCriteria();
} }
......
...@@ -97,9 +97,6 @@ ...@@ -97,9 +97,6 @@
# BUG(3742). # BUG(3742).
'test-mark-compact/MarkCompactCollector': [PASS, ['arch==arm', NO_VARIANTS]], 'test-mark-compact/MarkCompactCollector': [PASS, ['arch==arm', NO_VARIANTS]],
# BUG(10637).
'test-concurrent-allocation/ConcurrentAllocationInOldSpace': [SKIP],
# Test that serialization with unknown external reference fails. # Test that serialization with unknown external reference fails.
'test-serialize/SnapshotCreatorUnknownExternalReferences': [FAIL], 'test-serialize/SnapshotCreatorUnknownExternalReferences': [FAIL],
'test-serialize/SnapshotCreatorUnknownHandles': [FAIL], 'test-serialize/SnapshotCreatorUnknownHandles': [FAIL],
......
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