rev 4213 : 8008382: Remove redundant use of Atomic::add(jlong, jlong *) in create_new_gc_id()
Summary: There is no need to use atomics in create_new_gc_id() since it is not called by multiple threads in parallel. Also, Atomic::add(jlong, jlong *) is broken for ARM.
Reviewed-by:

   1 /*
   2  * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc_implementation/shared/gcHeapSummary.hpp"
  27 #include "gc_implementation/shared/gcTimer.hpp"
  28 #include "gc_implementation/shared/gcTrace.hpp"
  29 #include "memory/referenceProcessorStats.hpp"

  30 #include "utilities/globalDefinitions.hpp"
  31 
  32 #define assert_unset_gc_id() assert(_shared_gc_info.id() == SharedGCInfo::UNSET_GCID, "GC already started?")
  33 #define assert_set_gc_id() assert(_shared_gc_info.id() != SharedGCInfo::UNSET_GCID, "GC not started?")
  34 
  35 static jlong GCTracer_next_gc_id = 0;
  36 static GCId create_new_gc_id() {
  37   return GCTracer_next_gc_id++;
  38 }
  39 
  40 void GCTracer::report_gc_start_impl(GCCause::Cause cause, jlong timestamp) {
  41   assert_unset_gc_id();
  42 
  43   GCId gc_id = create_new_gc_id();
  44   _shared_gc_info.set_id(gc_id);
  45   _shared_gc_info.set_cause(cause);
  46   _shared_gc_info.set_start_timestamp(timestamp);
  47 }
  48 
  49 void GCTracer::report_gc_start(GCCause::Cause cause, jlong timestamp) {
  50   assert_unset_gc_id();
  51 
  52   report_gc_start_impl(cause, timestamp);
  53 }
  54 
  55 bool GCTracer::has_reported_gc_start() const {
  56   return _shared_gc_info.id() != SharedGCInfo::UNSET_GCID;
  57 }
  58 
  59 void GCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
  60   assert_set_gc_id();
  61 
  62   _shared_gc_info.set_sum_of_pauses(time_partitions->sum_of_pauses());
  63   _shared_gc_info.set_longest_pause(time_partitions->longest_pause());
  64   _shared_gc_info.set_end_timestamp(timestamp);
  65 
  66   send_phase_events(time_partitions);
  67   send_garbage_collection_event();
  68 }
  69 
  70 void GCTracer::report_gc_end(jlong timestamp, TimePartitions* time_partitions) {
  71   assert_set_gc_id();
  72 
  73   report_gc_end_impl(timestamp, time_partitions);
  74 
  75   _shared_gc_info.set_id(SharedGCInfo::UNSET_GCID);
  76 }
  77 
  78 void GCTracer::report_gc_reference_processing(const ReferenceProcessorStats& rps) const {
  79   assert_set_gc_id();
  80 
  81   send_reference_processing_event(REF_SOFT, rps.soft_count());
  82   send_reference_processing_event(REF_WEAK, rps.weak_count());
  83   send_reference_processing_event(REF_FINAL, rps.final_count());
  84   send_reference_processing_event(REF_PHANTOM, rps.phantom_count());
  85 }
  86 
  87 void GCTracer::report_gc_heap_summary(GCWhen::Type when, const GCHeapSummary& heap_summary, const PermGenSummary& perm_gen_summary) const {
  88   assert_set_gc_id();
  89 
  90   send_gc_heap_summary_event(when, heap_summary);
  91   send_perm_gen_summary_event(when, perm_gen_summary);
  92 }
  93 
  94 void YoungGCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
  95   assert_set_gc_id();
  96 
  97   GCTracer::report_gc_end_impl(timestamp, time_partitions);
  98   send_young_gc_event();
  99 }
 100 
 101 void YoungGCTracer::report_promotion_failed(size_t size, uint count) {
 102   assert_set_gc_id();
 103 
 104   young_gc_info().register_promotion_failed();
 105   send_promotion_failed_event(size, count);
 106 }
 107 
 108 
 109 void OldGCTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
 110   assert_set_gc_id();
 111 
 112   GCTracer::report_gc_end_impl(timestamp, time_partitions);
 113   send_old_gc_event();
 114 }
 115 
 116 void ParallelOldTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
 117   assert_set_gc_id();
 118 
 119   OldGCTracer::report_gc_end_impl(timestamp, time_partitions);
 120   send_parallel_old_event();
 121 }
 122 
 123 void ParallelOldTracer::report_dense_prefix(void* dense_prefix) {
 124   assert_set_gc_id();
 125 
 126   _parallel_old_gc_info.report_dense_prefix(dense_prefix);
 127 }
 128 
 129 #ifndef SERIALGC
 130 void G1NewTracer::report_yc_type(G1YCType type) {
 131   assert_set_gc_id();
 132 
 133   _g1_young_gc_info.set_type(type);
 134 }
 135 
 136 void G1NewTracer::report_gc_end_impl(jlong timestamp, TimePartitions* time_partitions) {
 137   assert_set_gc_id();
 138 
 139   YoungGCTracer::report_gc_end_impl(timestamp, time_partitions);
 140   send_g1_young_gc_event();
 141 }
 142 #endif
--- EOF ---