Revert "[heap] Invoke OldGenerationAllocationCounter in Safepoint"
This reverts commit 8bdd4e86ad997e3aab75be4dc6520d99cfbbc6cf.
Reason for revert: Caused multiple regressions.
Original change's description:
> [heap] Invoke OldGenerationAllocationCounter in Safepoint
>
> OldGenerationAllocationCounter() needs to be invoked in safepoint,
> otherwise invocation races with background threads incrementing the
> counter.
>
> Bug: v8:10315
> Change-Id: Iab005582bab7ebf63e7a5a796b25690f499a99eb
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2235544
> Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#68250}
TBR=ulan@chromium.org,dinfuehr@chromium.org
# Not skipping CQ checks because original CL landed > 1 day ago.
Bug: v8:10315, chromium:1095475, chromium:1094968, chromium:1094965
Change-Id: Ib221a907bf3e6a096398c42e74f78f9f48647063
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2259854
Commit-Queue: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: Dominik Inführ <dinfuehr@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68482}
diff --git a/src/heap/gc-tracer.cc b/src/heap/gc-tracer.cc
index 873ff57..ce682f9 100644
--- a/src/heap/gc-tracer.cc
+++ b/src/heap/gc-tracer.cc
@@ -228,6 +228,10 @@
   if (start_counter_ != 1) return;
 
   previous_ = current_;
+  double start_time = heap_->MonotonicallyIncreasingTimeInMs();
+  SampleAllocation(start_time, heap_->NewSpaceAllocationCounter(),
+                   heap_->OldGenerationAllocationCounter(),
+                   heap_->EmbedderAllocationCounter());
 
   switch (collector) {
     case SCAVENGER:
@@ -248,7 +252,7 @@
   }
 
   current_.reduce_memory = heap_->ShouldReduceMemory();
-  current_.start_time = heap_->MonotonicallyIncreasingTimeInMs();
+  current_.start_time = start_time;
   current_.start_object_size = 0;
   current_.start_memory_size = 0;
   current_.start_holes_size = 0;
@@ -277,10 +281,6 @@
 }
 
 void GCTracer::StartInSafepoint() {
-  SampleAllocation(current_.start_time, heap_->NewSpaceAllocationCounter(),
-                   heap_->OldGenerationAllocationCounter(),
-                   heap_->EmbedderAllocationCounter());
-
   current_.start_object_size = heap_->SizeOfObjects();
   current_.start_memory_size = heap_->memory_allocator()->Size();
   current_.start_holes_size = CountTotalHolesSize(heap_);