changeset 4235:f82f0250456f

8008382: Remove redundant use of Atomic::add(jlong, jlong *) in create_new_gc_id() Summary: Moving register_gc_start() in to the CMS VM operation makes sure that create_new_gc_id() is not called by multiple threads in parallel. This removes the need for atomics in create_new_gc_d(). Also, Atomic::add(jlong, jlong *) is unimplemented for ARM. Reviewed-by: stefank, dholmes, ehelin
author brutisso
date Mon, 18 Feb 2013 14:13:52 +0100
parents 5624724e4454
children 5e48fb5e9625
files src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp src/share/vm/gc_implementation/shared/gcTrace.cpp
diffstat 3 files changed, 3 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Mon Feb 18 12:49:53 2013 +0100
+++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Mon Feb 18 14:13:52 2013 +0100
@@ -2285,8 +2285,6 @@
         {
           ReleaseForegroundGC x(this);
           stats().record_cms_begin();
-          register_gc_start(GCCause::_cms_concurrent_mark);
-
           VM_CMS_Initial_Mark initial_mark_op(this);
           VMThread::execute(&initial_mark_op);
         }
@@ -2423,7 +2421,6 @@
 
 void CMSCollector::register_gc_start(GCCause::Cause cause) {
   _cms_start_registered = true;
-  CollectedHeap* heap = GenCollectedHeap::heap();
   _gc_timer_cm->register_gc_start(os::elapsed_counter());
   _gc_tracer_cm->report_gc_start(cause, _gc_timer_cm->gc_start());
 }
--- a/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp	Mon Feb 18 12:49:53 2013 +0100
+++ b/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp	Mon Feb 18 14:13:52 2013 +0100
@@ -145,6 +145,7 @@
                                 );
 #endif /* USDT2 */
 
+  _collector->register_gc_start(GCCause::_cms_concurrent_mark);
   _collector->_gc_timer_cm->register_gc_pause_start("Initial Mark", os::elapsed_counter());
 
   GenCollectedHeap* gch = GenCollectedHeap::heap();
--- a/src/share/vm/gc_implementation/shared/gcTrace.cpp	Mon Feb 18 12:49:53 2013 +0100
+++ b/src/share/vm/gc_implementation/shared/gcTrace.cpp	Mon Feb 18 14:13:52 2013 +0100
@@ -27,15 +27,14 @@
 #include "gc_implementation/shared/gcTimer.hpp"
 #include "gc_implementation/shared/gcTrace.hpp"
 #include "memory/referenceProcessorStats.hpp"
-#include "runtime/atomic.hpp"
 #include "utilities/globalDefinitions.hpp"
 
 #define assert_unset_gc_id() assert(_shared_gc_info.id() == SharedGCInfo::UNSET_GCID, "GC already started?")
 #define assert_set_gc_id() assert(_shared_gc_info.id() != SharedGCInfo::UNSET_GCID, "GC not started?")
 
-static volatile jlong GCTracer_next_gc_id = 0;
+static jlong GCTracer_next_gc_id = 0;
 static GCId create_new_gc_id() {
-  return Atomic::add((jlong)1, &GCTracer_next_gc_id);
+  return GCTracer_next_gc_id++;
 }
 
 void GCTracer::report_gc_start_impl(GCCause::Cause cause, jlong timestamp) {