Merge

Fri, 18 May 2012 10:27:13 -0700

author
jcoomes
date
Fri, 18 May 2012 10:27:13 -0700
changeset 3768
cdeda3fd141e
parent 3761
de0cc3dd9f10
parent 3767
9d679effd28c
child 3769
14b0e07ab9a6

Merge

src/share/vm/runtime/arguments.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Thu May 17 09:50:59 2012 -0700
     1.2 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp	Fri May 18 10:27:13 2012 -0700
     1.3 @@ -6332,10 +6332,10 @@
     1.4    )
     1.5  }
     1.6  
     1.7 -void CMSCollector::do_CMS_operation(CMS_op_type op) {
     1.8 +void CMSCollector::do_CMS_operation(CMS_op_type op, GCCause::Cause gc_cause) {
     1.9    gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps);
    1.10    TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
    1.11 -  TraceTime t("GC", PrintGC, !PrintGCDetails, gclog_or_tty);
    1.12 +  TraceTime t(GCCauseString("GC", gc_cause), PrintGC, !PrintGCDetails, gclog_or_tty);
    1.13    TraceCollectorStats tcs(counters());
    1.14  
    1.15    switch (op) {
     2.1 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp	Thu May 17 09:50:59 2012 -0700
     2.2 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp	Fri May 18 10:27:13 2012 -0700
     2.3 @@ -717,7 +717,7 @@
     2.4      CMS_op_checkpointRootsFinal
     2.5    };
     2.6  
     2.7 -  void do_CMS_operation(CMS_op_type op);
     2.8 +  void do_CMS_operation(CMS_op_type op, GCCause::Cause gc_cause);
     2.9    bool stop_world_and_do(CMS_op_type op);
    2.10  
    2.11    OopTaskQueueSet* task_queues() { return _task_queues; }
     3.1 --- a/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp	Thu May 17 09:50:59 2012 -0700
     3.2 +++ b/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp	Fri May 18 10:27:13 2012 -0700
     3.3 @@ -146,7 +146,7 @@
     3.4    VM_CMS_Operation::verify_before_gc();
     3.5  
     3.6    IsGCActiveMark x; // stop-world GC active
     3.7 -  _collector->do_CMS_operation(CMSCollector::CMS_op_checkpointRootsInitial);
     3.8 +  _collector->do_CMS_operation(CMSCollector::CMS_op_checkpointRootsInitial, gch->gc_cause());
     3.9  
    3.10    VM_CMS_Operation::verify_after_gc();
    3.11  #ifndef USDT2
    3.12 @@ -178,7 +178,7 @@
    3.13    VM_CMS_Operation::verify_before_gc();
    3.14  
    3.15    IsGCActiveMark x; // stop-world GC active
    3.16 -  _collector->do_CMS_operation(CMSCollector::CMS_op_checkpointRootsFinal);
    3.17 +  _collector->do_CMS_operation(CMSCollector::CMS_op_checkpointRootsFinal, gch->gc_cause());
    3.18  
    3.19    VM_CMS_Operation::verify_after_gc();
    3.20  #ifndef USDT2
     4.1 --- a/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Thu May 17 09:50:59 2012 -0700
     4.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp	Fri May 18 10:27:13 2012 -0700
     4.3 @@ -1252,10 +1252,7 @@
     4.4      gclog_or_tty->date_stamp(G1Log::fine() && PrintGCDateStamps);
     4.5      TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty);
     4.6  
     4.7 -    char verbose_str[128];
     4.8 -    sprintf(verbose_str, "Full GC (%s)", GCCause::to_string(gc_cause()));
     4.9 -    TraceTime t(verbose_str, G1Log::fine(), true, gclog_or_tty);
    4.10 -
    4.11 +    TraceTime t(GCCauseString("Full GC", gc_cause()), G1Log::fine(), true, gclog_or_tty);
    4.12      TraceCollectorStats tcs(g1mm()->full_collection_counters());
    4.13      TraceMemoryManagerStats tms(true /* fullGC */, gc_cause());
    4.14  
    4.15 @@ -3600,12 +3597,10 @@
    4.16      gclog_or_tty->date_stamp(G1Log::fine() && PrintGCDateStamps);
    4.17      TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty);
    4.18  
    4.19 -    char verbose_str[128];
    4.20 -    sprintf(verbose_str, "GC pause (%s) (%s)%s",
    4.21 -      GCCause::to_string(gc_cause()),
    4.22 -      g1_policy()->gcs_are_young() ? "young" : "mixed",
    4.23 -      g1_policy()->during_initial_mark_pause() ? " (initial-mark)" : "");
    4.24 -    TraceTime t(verbose_str, G1Log::fine() && !G1Log::finer(), true, gclog_or_tty);
    4.25 +    GCCauseString gc_cause_str = GCCauseString("GC pause", gc_cause())
    4.26 +      .append(g1_policy()->gcs_are_young() ? " (young)" : " (mixed)")
    4.27 +      .append(g1_policy()->during_initial_mark_pause() ? " (initial-mark)" : "");
    4.28 +    TraceTime t(gc_cause_str, G1Log::fine() && !G1Log::finer(), true, gclog_or_tty);
    4.29  
    4.30      TraceCollectorStats tcs(g1mm()->incremental_collection_counters());
    4.31      TraceMemoryManagerStats tms(false /* fullGC */, gc_cause());
    4.32 @@ -5502,7 +5497,7 @@
    4.33    if (evacuation_failed()) {
    4.34      remove_self_forwarding_pointers();
    4.35      if (G1Log::finer()) {
    4.36 -      gclog_or_tty->print(" (to-space overflow)");
    4.37 +      gclog_or_tty->print(" (to-space exhausted)");
    4.38      } else if (G1Log::fine()) {
    4.39        gclog_or_tty->print("--");
    4.40      }
     5.1 --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Thu May 17 09:50:59 2012 -0700
     5.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.cpp	Fri May 18 10:27:13 2012 -0700
     5.3 @@ -886,9 +886,8 @@
     5.4                                                        size_t start_used) {
     5.5    if (G1Log::finer()) {
     5.6      gclog_or_tty->stamp(PrintGCTimeStamps);
     5.7 -    gclog_or_tty->print("[GC pause (%s) (%s)",
     5.8 -      GCCause::to_string(_g1->gc_cause()),
     5.9 -      gcs_are_young() ? "young" : "mixed");
    5.10 +    gclog_or_tty->print("[%s", (const char*)GCCauseString("GC pause", _g1->gc_cause())
    5.11 +      .append(gcs_are_young() ? " (young)" : " (mixed)"));
    5.12    }
    5.13  
    5.14    // We only need to do this here as the policy will only be applied
    5.15 @@ -1010,7 +1009,8 @@
    5.16  
    5.17  void G1CollectorPolicy::print_par_stats(int level,
    5.18                                          const char* str,
    5.19 -                                        double* data) {
    5.20 +                                        double* data,
    5.21 +                                        bool showDecimals) {
    5.22    double min = data[0], max = data[0];
    5.23    double total = 0.0;
    5.24    LineBuffer buf(level);
    5.25 @@ -1023,7 +1023,11 @@
    5.26        max = val;
    5.27      total += val;
    5.28      if (G1Log::finest()) {
    5.29 -      buf.append("  %.1lf", val);
    5.30 +      if (showDecimals) {
    5.31 +        buf.append("  %.1lf", val);
    5.32 +      } else {
    5.33 +        buf.append("  %d", (int)val);
    5.34 +      }
    5.35      }
    5.36    }
    5.37  
    5.38 @@ -1031,36 +1035,26 @@
    5.39      buf.append_and_print_cr("");
    5.40    }
    5.41    double avg = total / (double) no_of_gc_threads();
    5.42 -  buf.append_and_print_cr(" Avg: %.1lf Min: %.1lf Max: %.1lf Diff: %.1lf]",
    5.43 -    avg, min, max, max - min);
    5.44 -}
    5.45 -
    5.46 -void G1CollectorPolicy::print_par_sizes(int level,
    5.47 -                                        const char* str,
    5.48 -                                        double* data) {
    5.49 -  double min = data[0], max = data[0];
    5.50 -  double total = 0.0;
    5.51 -  LineBuffer buf(level);
    5.52 -  buf.append("[%s :", str);
    5.53 -  for (uint i = 0; i < no_of_gc_threads(); ++i) {
    5.54 -    double val = data[i];
    5.55 -    if (val < min)
    5.56 -      min = val;
    5.57 -    if (val > max)
    5.58 -      max = val;
    5.59 -    total += val;
    5.60 -    buf.append(" %d", (int) val);
    5.61 +  if (showDecimals) {
    5.62 +    buf.append_and_print_cr(" Min: %.1lf, Avg: %.1lf, Max: %.1lf, Diff: %.1lf, Sum: %.1lf]",
    5.63 +      min, avg, max, max - min, total);
    5.64 +  } else {
    5.65 +    buf.append_and_print_cr(" Min: %d, Avg: %d, Max: %d, Diff: %d, Sum: %d]",
    5.66 +      (int)min, (int)avg, (int)max, (int)max - (int)min, (int)total);
    5.67    }
    5.68 -  buf.append_and_print_cr("");
    5.69 -  double avg = total / (double) no_of_gc_threads();
    5.70 -  buf.append_and_print_cr(" Sum: %d, Avg: %d, Min: %d, Max: %d, Diff: %d]",
    5.71 -    (int)total, (int)avg, (int)min, (int)max, (int)max - (int)min);
    5.72  }
    5.73  
    5.74  void G1CollectorPolicy::print_stats(int level,
    5.75                                      const char* str,
    5.76                                      double value) {
    5.77 -  LineBuffer(level).append_and_print_cr("[%s: %5.1lf ms]", str, value);
    5.78 +  LineBuffer(level).append_and_print_cr("[%s: %.1lf ms]", str, value);
    5.79 +}
    5.80 +
    5.81 +void G1CollectorPolicy::print_stats(int level,
    5.82 +                                    const char* str,
    5.83 +                                    double value,
    5.84 +                                    int workers) {
    5.85 +  LineBuffer(level).append_and_print_cr("[%s: %.1lf ms, GC Workers: %d]", str, value, workers);
    5.86  }
    5.87  
    5.88  void G1CollectorPolicy::print_stats(int level,
    5.89 @@ -1373,7 +1367,7 @@
    5.90        print_stats(1, "Root Region Scan Waiting", _root_region_scan_wait_time_ms);
    5.91      }
    5.92      if (parallel) {
    5.93 -      print_stats(1, "Parallel Time", _cur_collection_par_time_ms);
    5.94 +      print_stats(1, "Parallel Time", _cur_collection_par_time_ms, no_of_gc_threads);
    5.95        print_par_stats(2, "GC Worker Start", _par_last_gc_worker_start_times_ms);
    5.96        print_par_stats(2, "Ext Root Scanning", _par_last_ext_root_scan_times_ms);
    5.97        if (print_marking_info) {
    5.98 @@ -1381,13 +1375,15 @@
    5.99        }
   5.100        print_par_stats(2, "Update RS", _par_last_update_rs_times_ms);
   5.101        if (G1Log::finest()) {
   5.102 -        print_par_sizes(3, "Processed Buffers", _par_last_update_rs_processed_buffers);
   5.103 +        print_par_stats(3, "Processed Buffers", _par_last_update_rs_processed_buffers,
   5.104 +          false /* showDecimals */);
   5.105        }
   5.106        print_par_stats(2, "Scan RS", _par_last_scan_rs_times_ms);
   5.107        print_par_stats(2, "Object Copy", _par_last_obj_copy_times_ms);
   5.108        print_par_stats(2, "Termination", _par_last_termination_times_ms);
   5.109        if (G1Log::finest()) {
   5.110 -        print_par_sizes(3, "Termination Attempts", _par_last_termination_attempts);
   5.111 +        print_par_stats(3, "Termination Attempts", _par_last_termination_attempts,
   5.112 +          false /* showDecimals */);
   5.113        }
   5.114  
   5.115        for (int i = 0; i < _parallel_gc_threads; i++) {
   5.116 @@ -1601,9 +1597,9 @@
   5.117    _collectionSetChooser->verify();
   5.118  }
   5.119  
   5.120 -#define EXT_SIZE_FORMAT "%d%s"
   5.121 +#define EXT_SIZE_FORMAT "%.1f%s"
   5.122  #define EXT_SIZE_PARAMS(bytes)                                  \
   5.123 -  byte_size_in_proper_unit((bytes)),                            \
   5.124 +  byte_size_in_proper_unit((double)(bytes)),                    \
   5.125    proper_unit_for_byte_size((bytes))
   5.126  
   5.127  void G1CollectorPolicy::print_heap_transition() {
     6.1 --- a/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp	Thu May 17 09:50:59 2012 -0700
     6.2 +++ b/src/share/vm/gc_implementation/g1/g1CollectorPolicy.hpp	Fri May 18 10:27:13 2012 -0700
     6.3 @@ -552,10 +552,10 @@
     6.4  
     6.5  private:
     6.6    void print_stats(int level, const char* str, double value);
     6.7 +  void print_stats(int level, const char* str, double value, int workers);
     6.8    void print_stats(int level, const char* str, int value);
     6.9  
    6.10 -  void print_par_stats(int level, const char* str, double* data);
    6.11 -  void print_par_sizes(int level, const char* str, double* data);
    6.12 +  void print_par_stats(int level, const char* str, double* data, bool showDecimals = true);
    6.13  
    6.14    void check_other_times(int level,
    6.15                           NumberSeq* other_times_ms,
     7.1 --- a/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp	Thu May 17 09:50:59 2012 -0700
     7.2 +++ b/src/share/vm/gc_implementation/g1/vm_operations_g1.cpp	Fri May 18 10:27:13 2012 -0700
     7.3 @@ -42,6 +42,7 @@
     7.4  
     7.5  void VM_G1CollectForAllocation::doit() {
     7.6    G1CollectedHeap* g1h = G1CollectedHeap::heap();
     7.7 +  GCCauseSetter x(g1h, _gc_cause);
     7.8    _result = g1h->satisfy_failed_allocation(_word_size, &_pause_succeeded);
     7.9    assert(_result == NULL || _pause_succeeded,
    7.10           "if we get back a result, the pause should have succeeded");
     8.1 --- a/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp	Thu May 17 09:50:59 2012 -0700
     8.2 +++ b/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp	Fri May 18 10:27:13 2012 -0700
     8.3 @@ -916,7 +916,7 @@
     8.4      size_policy->minor_collection_begin();
     8.5    }
     8.6  
     8.7 -  TraceTime t1("GC", PrintGC && !PrintGCDetails, true, gclog_or_tty);
     8.8 +  TraceTime t1(GCCauseString("GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, gclog_or_tty);
     8.9    // Capture heap used before collection (for printing).
    8.10    size_t gch_prev_used = gch->used();
    8.11  
     9.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp	Thu May 17 09:50:59 2012 -0700
     9.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psMarkSweep.cpp	Fri May 18 10:27:13 2012 -0700
     9.3 @@ -160,16 +160,10 @@
     9.4  
     9.5    {
     9.6      HandleMark hm;
     9.7 -    const bool is_system_gc = gc_cause == GCCause::_java_lang_system_gc;
     9.8 -    // This is useful for debugging but don't change the output the
     9.9 -    // the customer sees.
    9.10 -    const char* gc_cause_str = "Full GC";
    9.11 -    if (is_system_gc && PrintGCDetails) {
    9.12 -      gc_cause_str = "Full GC (System)";
    9.13 -    }
    9.14 +
    9.15      gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps);
    9.16      TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
    9.17 -    TraceTime t1(gc_cause_str, PrintGC, !PrintGCDetails, gclog_or_tty);
    9.18 +    TraceTime t1(GCCauseString("Full GC", gc_cause), PrintGC, !PrintGCDetails, gclog_or_tty);
    9.19      TraceCollectorStats tcs(counters());
    9.20      TraceMemoryManagerStats tms(true /* Full GC */,gc_cause);
    9.21  
    10.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Thu May 17 09:50:59 2012 -0700
    10.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp	Fri May 18 10:27:13 2012 -0700
    10.3 @@ -2047,17 +2047,9 @@
    10.4      gc_task_manager()->task_idle_workers();
    10.5      heap->set_par_threads(gc_task_manager()->active_workers());
    10.6  
    10.7 -    const bool is_system_gc = gc_cause == GCCause::_java_lang_system_gc;
    10.8 -
    10.9 -    // This is useful for debugging but don't change the output the
   10.10 -    // the customer sees.
   10.11 -    const char* gc_cause_str = "Full GC";
   10.12 -    if (is_system_gc && PrintGCDetails) {
   10.13 -      gc_cause_str = "Full GC (System)";
   10.14 -    }
   10.15      gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps);
   10.16      TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
   10.17 -    TraceTime t1(gc_cause_str, PrintGC, !PrintGCDetails, gclog_or_tty);
   10.18 +    TraceTime t1(GCCauseString("Full GC", gc_cause), PrintGC, !PrintGCDetails, gclog_or_tty);
   10.19      TraceCollectorStats tcs(counters());
   10.20      TraceMemoryManagerStats tms(true /* Full GC */,gc_cause);
   10.21  
   10.22 @@ -2090,7 +2082,8 @@
   10.23      }
   10.24  #endif  // #ifndef PRODUCT
   10.25  
   10.26 -    bool max_on_system_gc = UseMaximumCompactionOnSystemGC && is_system_gc;
   10.27 +    bool max_on_system_gc = UseMaximumCompactionOnSystemGC
   10.28 +      && gc_cause == GCCause::_java_lang_system_gc;
   10.29      summary_phase(vmthread_cm, maximum_heap_compaction || max_on_system_gc);
   10.30  
   10.31      COMPILER2_PRESENT(assert(DerivedPointerTable::is_active(), "Sanity"));
    11.1 --- a/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp	Thu May 17 09:50:59 2012 -0700
    11.2 +++ b/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp	Fri May 18 10:27:13 2012 -0700
    11.3 @@ -325,7 +325,7 @@
    11.4  
    11.5      gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps);
    11.6      TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
    11.7 -    TraceTime t1("GC", PrintGC, !PrintGCDetails, gclog_or_tty);
    11.8 +    TraceTime t1(GCCauseString("GC", gc_cause), PrintGC, !PrintGCDetails, gclog_or_tty);
    11.9      TraceCollectorStats tcs(counters());
   11.10      TraceMemoryManagerStats tms(false /* not full GC */,gc_cause);
   11.11  
    12.1 --- a/src/share/vm/gc_implementation/shared/gcUtil.cpp	Thu May 17 09:50:59 2012 -0700
    12.2 +++ b/src/share/vm/gc_implementation/shared/gcUtil.cpp	Fri May 18 10:27:13 2012 -0700
    12.3 @@ -31,9 +31,15 @@
    12.4                                                          float average) {
    12.5    // We smooth the samples by not using weight() directly until we've
    12.6    // had enough data to make it meaningful. We'd like the first weight
    12.7 -  // used to be 1, the second to be 1/2, etc until we have 100/weight
    12.8 -  // samples.
    12.9 -  unsigned count_weight = 100/count();
   12.10 +  // used to be 1, the second to be 1/2, etc until we have
   12.11 +  // OLD_THRESHOLD/weight samples.
   12.12 +  unsigned count_weight = 0;
   12.13 +
   12.14 +  // Avoid division by zero if the counter wraps (7158457)
   12.15 +  if (!is_old()) {
   12.16 +    count_weight = OLD_THRESHOLD/count();
   12.17 +  }
   12.18 +
   12.19    unsigned adaptive_weight = (MAX2(weight(), count_weight));
   12.20  
   12.21    float new_avg = exp_avg(average, new_sample, adaptive_weight);
   12.22 @@ -43,8 +49,6 @@
   12.23  
   12.24  void AdaptiveWeightedAverage::sample(float new_sample) {
   12.25    increment_count();
   12.26 -  assert(count() != 0,
   12.27 -         "Wraparound -- history would be incorrectly discarded");
   12.28  
   12.29    // Compute the new weighted average
   12.30    float new_avg = compute_adaptive_average(new_sample, average());
    13.1 --- a/src/share/vm/gc_implementation/shared/gcUtil.hpp	Thu May 17 09:50:59 2012 -0700
    13.2 +++ b/src/share/vm/gc_implementation/shared/gcUtil.hpp	Fri May 18 10:27:13 2012 -0700
    13.3 @@ -50,11 +50,20 @@
    13.4    unsigned         _weight;         // The weight used to smooth the averages
    13.5                                      //   A higher weight favors the most
    13.6                                      //   recent data.
    13.7 +  bool             _is_old;         // Has enough historical data
    13.8 +
    13.9 +  const static unsigned OLD_THRESHOLD = 100;
   13.10  
   13.11   protected:
   13.12    float            _last_sample;    // The last value sampled.
   13.13  
   13.14 -  void  increment_count()       { _sample_count++;       }
   13.15 +  void  increment_count() {
   13.16 +    _sample_count++;
   13.17 +    if (!_is_old && _sample_count > OLD_THRESHOLD) {
   13.18 +      _is_old = true;
   13.19 +    }
   13.20 +  }
   13.21 +
   13.22    void  set_average(float avg)  { _average = avg;        }
   13.23  
   13.24    // Helper function, computes an adaptive weighted average
   13.25 @@ -64,13 +73,15 @@
   13.26   public:
   13.27    // Input weight must be between 0 and 100
   13.28    AdaptiveWeightedAverage(unsigned weight, float avg = 0.0) :
   13.29 -    _average(avg), _sample_count(0), _weight(weight), _last_sample(0.0) {
   13.30 +    _average(avg), _sample_count(0), _weight(weight), _last_sample(0.0),
   13.31 +    _is_old(false) {
   13.32    }
   13.33  
   13.34    void clear() {
   13.35      _average = 0;
   13.36      _sample_count = 0;
   13.37      _last_sample = 0;
   13.38 +    _is_old = false;
   13.39    }
   13.40  
   13.41    // Useful for modifying static structures after startup.
   13.42 @@ -84,7 +95,8 @@
   13.43    float    average() const       { return _average;       }
   13.44    unsigned weight()  const       { return _weight;        }
   13.45    unsigned count()   const       { return _sample_count;  }
   13.46 -  float    last_sample() const   { return _last_sample; }
   13.47 +  float    last_sample() const   { return _last_sample;   }
   13.48 +  bool     is_old()  const       { return _is_old;        }
   13.49  
   13.50    // Update data with a new sample.
   13.51    void sample(float new_sample);
    14.1 --- a/src/share/vm/gc_interface/gcCause.hpp	Thu May 17 09:50:59 2012 -0700
    14.2 +++ b/src/share/vm/gc_interface/gcCause.hpp	Fri May 18 10:27:13 2012 -0700
    14.3 @@ -88,4 +88,36 @@
    14.4    static const char* to_string(GCCause::Cause cause);
    14.5  };
    14.6  
    14.7 +// Helper class for doing logging that includes the GC Cause
    14.8 +// as a string.
    14.9 +class GCCauseString : StackObj {
   14.10 + private:
   14.11 +   static const int _length = 128;
   14.12 +   char _buffer[_length];
   14.13 +   int _position;
   14.14 +
   14.15 + public:
   14.16 +   GCCauseString(const char* prefix, GCCause::Cause cause) {
   14.17 +     if (PrintGCCause) {
   14.18 +      _position = jio_snprintf(_buffer, _length, "%s (%s)", prefix, GCCause::to_string(cause));
   14.19 +     } else {
   14.20 +      _position = jio_snprintf(_buffer, _length, "%s", prefix);
   14.21 +     }
   14.22 +     assert(_position >= 0 && _position <= _length,
   14.23 +       err_msg("Need to increase the buffer size in GCCauseString? %d", _position));
   14.24 +   }
   14.25 +
   14.26 +   GCCauseString& append(const char* str) {
   14.27 +     int res = jio_snprintf(_buffer + _position, _length - _position, "%s", str);
   14.28 +     _position += res;
   14.29 +     assert(res >= 0 && _position <= _length,
   14.30 +       err_msg("Need to increase the buffer size in GCCauseString? %d", res));
   14.31 +     return *this;
   14.32 +   }
   14.33 +
   14.34 +   operator const char*() {
   14.35 +     return _buffer;
   14.36 +   }
   14.37 +};
   14.38 +
   14.39  #endif // SHARE_VM_GC_INTERFACE_GCCAUSE_HPP
    15.1 --- a/src/share/vm/memory/defNewGeneration.cpp	Thu May 17 09:50:59 2012 -0700
    15.2 +++ b/src/share/vm/memory/defNewGeneration.cpp	Fri May 18 10:27:13 2012 -0700
    15.3 @@ -548,7 +548,7 @@
    15.4  
    15.5    init_assuming_no_promotion_failure();
    15.6  
    15.7 -  TraceTime t1("GC", PrintGC && !PrintGCDetails, true, gclog_or_tty);
    15.8 +  TraceTime t1(GCCauseString("GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, gclog_or_tty);
    15.9    // Capture heap used before collection (for printing).
   15.10    size_t gch_prev_used = gch->used();
   15.11  
    16.1 --- a/src/share/vm/memory/genCollectedHeap.cpp	Thu May 17 09:50:59 2012 -0700
    16.2 +++ b/src/share/vm/memory/genCollectedHeap.cpp	Fri May 18 10:27:13 2012 -0700
    16.3 @@ -480,26 +480,15 @@
    16.4    const size_t perm_prev_used = perm_gen()->used();
    16.5  
    16.6    print_heap_before_gc();
    16.7 -  if (Verbose) {
    16.8 -    gclog_or_tty->print_cr("GC Cause: %s", GCCause::to_string(gc_cause()));
    16.9 -  }
   16.10  
   16.11    {
   16.12      FlagSetting fl(_is_gc_active, true);
   16.13  
   16.14      bool complete = full && (max_level == (n_gens()-1));
   16.15 -    const char* gc_cause_str = "GC ";
   16.16 -    if (complete) {
   16.17 -      GCCause::Cause cause = gc_cause();
   16.18 -      if (cause == GCCause::_java_lang_system_gc) {
   16.19 -        gc_cause_str = "Full GC (System) ";
   16.20 -      } else {
   16.21 -        gc_cause_str = "Full GC ";
   16.22 -      }
   16.23 -    }
   16.24 +    const char* gc_cause_prefix = complete ? "Full GC" : "GC";
   16.25      gclog_or_tty->date_stamp(PrintGC && PrintGCDateStamps);
   16.26      TraceCPUTime tcpu(PrintGCDetails, true, gclog_or_tty);
   16.27 -    TraceTime t(gc_cause_str, PrintGCDetails, false, gclog_or_tty);
   16.28 +    TraceTime t(GCCauseString(gc_cause_prefix, gc_cause()), PrintGCDetails, false, gclog_or_tty);
   16.29  
   16.30      gc_prologue(complete);
   16.31      increment_total_collections(complete);
    17.1 --- a/src/share/vm/memory/genMarkSweep.cpp	Thu May 17 09:50:59 2012 -0700
    17.2 +++ b/src/share/vm/memory/genMarkSweep.cpp	Fri May 18 10:27:13 2012 -0700
    17.3 @@ -76,7 +76,7 @@
    17.4    _ref_processor = rp;
    17.5    rp->setup_policy(clear_all_softrefs);
    17.6  
    17.7 -  TraceTime t1("Full GC", PrintGC && !PrintGCDetails, true, gclog_or_tty);
    17.8 +  TraceTime t1(GCCauseString("Full GC", gch->gc_cause()), PrintGC && !PrintGCDetails, true, gclog_or_tty);
    17.9  
   17.10    // When collecting the permanent generation methodOops may be moving,
   17.11    // so we either have to flush all bcp data or convert it into bci.
    18.1 --- a/src/share/vm/runtime/arguments.cpp	Thu May 17 09:50:59 2012 -0700
    18.2 +++ b/src/share/vm/runtime/arguments.cpp	Fri May 18 10:27:13 2012 -0700
    18.3 @@ -3092,6 +3092,14 @@
    18.4      PrintGC = true;
    18.5    }
    18.6  
    18.7 +  if (!JDK_Version::is_gte_jdk18x_version()) {
    18.8 +    // To avoid changing the log format for 7 updates this flag is only
    18.9 +    // true by default in JDK8 and above.
   18.10 +    if (FLAG_IS_DEFAULT(PrintGCCause)) {
   18.11 +      FLAG_SET_DEFAULT(PrintGCCause, false);
   18.12 +    }
   18.13 +  }
   18.14 +
   18.15    // Set object alignment values.
   18.16    set_object_alignment();
   18.17  
    19.1 --- a/src/share/vm/runtime/globals.hpp	Thu May 17 09:50:59 2012 -0700
    19.2 +++ b/src/share/vm/runtime/globals.hpp	Fri May 18 10:27:13 2012 -0700
    19.3 @@ -3902,7 +3902,10 @@
    19.4            " of this flag is true for JDK 6 and earlier")                    \
    19.5                                                                              \
    19.6    diagnostic(bool, WhiteBoxAPI, false,                                      \
    19.7 -          "Enable internal testing APIs")
    19.8 +          "Enable internal testing APIs")                                   \
    19.9 +                                                                            \
   19.10 +  product(bool, PrintGCCause, true,                                         \
   19.11 +          "Include GC cause in GC logging")
   19.12  
   19.13  /*
   19.14   *  Macros for factoring of globals
    20.1 --- a/src/share/vm/runtime/java.hpp	Thu May 17 09:50:59 2012 -0700
    20.2 +++ b/src/share/vm/runtime/java.hpp	Fri May 18 10:27:13 2012 -0700
    20.3 @@ -206,6 +206,10 @@
    20.4      return current().compare_major(7) == 0;
    20.5    }
    20.6  
    20.7 +  static bool is_jdk18x_version() {
    20.8 +    return current().compare_major(8) == 0;
    20.9 +  }
   20.10 +
   20.11    static bool is_gte_jdk13x_version() {
   20.12      return current().compare_major(3) >= 0;
   20.13    }
   20.14 @@ -225,6 +229,10 @@
   20.15    static bool is_gte_jdk17x_version() {
   20.16      return current().compare_major(7) >= 0;
   20.17    }
   20.18 +
   20.19 +  static bool is_gte_jdk18x_version() {
   20.20 +    return current().compare_major(8) >= 0;
   20.21 +  }
   20.22  };
   20.23  
   20.24  #endif // SHARE_VM_RUNTIME_JAVA_HPP
    21.1 --- a/src/share/vm/utilities/globalDefinitions.hpp	Thu May 17 09:50:59 2012 -0700
    21.2 +++ b/src/share/vm/utilities/globalDefinitions.hpp	Fri May 18 10:27:13 2012 -0700
    21.3 @@ -1,5 +1,5 @@
    21.4  /*
    21.5 - * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
    21.6 + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
    21.7   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    21.8   *
    21.9   * This code is free software; you can redistribute it and/or modify it
   21.10 @@ -179,6 +179,11 @@
   21.11  const jint  NANOSECS_PER_MILLISEC = 1000000;
   21.12  
   21.13  inline const char* proper_unit_for_byte_size(size_t s) {
   21.14 +#ifdef _LP64
   21.15 +  if (s >= 10*G) {
   21.16 +    return "G";
   21.17 +  }
   21.18 +#endif
   21.19    if (s >= 10*M) {
   21.20      return "M";
   21.21    } else if (s >= 10*K) {
   21.22 @@ -188,17 +193,22 @@
   21.23    }
   21.24  }
   21.25  
   21.26 -inline size_t byte_size_in_proper_unit(size_t s) {
   21.27 +template <class T>
   21.28 +inline T byte_size_in_proper_unit(T s) {
   21.29 +#ifdef _LP64
   21.30 +  if (s >= 10*G) {
   21.31 +    return (T)(s/G);
   21.32 +  }
   21.33 +#endif
   21.34    if (s >= 10*M) {
   21.35 -    return s/M;
   21.36 +    return (T)(s/M);
   21.37    } else if (s >= 10*K) {
   21.38 -    return s/K;
   21.39 +    return (T)(s/K);
   21.40    } else {
   21.41      return s;
   21.42    }
   21.43  }
   21.44  
   21.45 -
   21.46  //----------------------------------------------------------------------------------------------------
   21.47  // VM type definitions
   21.48  

mercurial