hotspot/src/share/vm/memory/specialized_oop_closures.cpp
author ysr
Tue, 01 Jul 2008 11:59:44 -0700
changeset 1383 3a216aa862b7
parent 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2001-2003 Sun Microsystems, Inc.  All Rights Reserved.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
# include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
# include "incls/_specialized_oop_closures.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// For keeping stats on effectiveness.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
#if ENABLE_SPECIALIZATION_STATS
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
int SpecializationStats::_numCallsAll;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
int SpecializationStats::_numCallsTotal[NUM_Kinds];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
int SpecializationStats::_numCalls_nv[NUM_Kinds];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
int SpecializationStats::_numDoOopCallsTotal[NUM_Kinds];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
int SpecializationStats::_numDoOopCalls_nv[NUM_Kinds];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
void SpecializationStats::clear() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  _numCallsAll = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  for (int k = ik; k < NUM_Kinds; k++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    _numCallsTotal[k] = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
    _numCalls_nv[k] = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    _numDoOopCallsTotal[k] = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
    _numDoOopCalls_nv[k] = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
void SpecializationStats::print() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  const char* header_format = "    %20s %10s %11s %10s";
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  const char* line_format   = "    %20s %10d %11d %9.2f%%";
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  int all_numCallsTotal =
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    _numCallsTotal[ik] + _numCallsTotal[irk] + _numCallsTotal[oa];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  int all_numCalls_nv =
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
    _numCalls_nv[ik] + _numCalls_nv[irk] + _numCalls_nv[oa];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  gclog_or_tty->print_cr("\nOf %d oop_oop_iterate calls %d (%6.3f%%) are in (ik, irk, oa).",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
                _numCallsAll, all_numCallsTotal,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
                100.0 * (float)all_numCallsTotal / (float)_numCallsAll);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  // irk calls are double-counted.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  int real_ik_numCallsTotal = _numCallsTotal[ik] - _numCallsTotal[irk];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  int real_ik_numCalls_nv   = _numCalls_nv[ik]   - _numCalls_nv[irk];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  gclog_or_tty->print_cr("");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  gclog_or_tty->print_cr(header_format, "oop_oop_iterate:", "calls", "non-virtual", "pct");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  gclog_or_tty->print_cr(header_format,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
                "----------",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
                "----------",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
                "-----------",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
                "----------");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  gclog_or_tty->print_cr(line_format, "all",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
                all_numCallsTotal,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
                all_numCalls_nv,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
                100.0 * (float)all_numCalls_nv / (float)all_numCallsTotal);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  gclog_or_tty->print_cr(line_format, "ik",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
                real_ik_numCallsTotal, real_ik_numCalls_nv,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
                100.0 * (float)real_ik_numCalls_nv /
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
                (float)real_ik_numCallsTotal);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  gclog_or_tty->print_cr(line_format, "irk",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
                _numCallsTotal[irk], _numCalls_nv[irk],
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
                100.0 * (float)_numCalls_nv[irk] / (float)_numCallsTotal[irk]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  gclog_or_tty->print_cr(line_format, "oa",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
                _numCallsTotal[oa], _numCalls_nv[oa],
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
                100.0 * (float)_numCalls_nv[oa] / (float)_numCallsTotal[oa]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  gclog_or_tty->print_cr("");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  gclog_or_tty->print_cr(header_format, "do_oop:", "calls", "non-virtual", "pct");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  gclog_or_tty->print_cr(header_format,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
                "----------",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
                "----------",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
                "-----------",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
                "----------");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  int all_numDoOopCallsTotal =
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    _numDoOopCallsTotal[ik] + _numDoOopCallsTotal[irk] + _numDoOopCallsTotal[oa];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  int all_numDoOopCalls_nv =
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    _numDoOopCalls_nv[ik] + _numDoOopCalls_nv[irk] + _numDoOopCalls_nv[oa];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  gclog_or_tty->print_cr(line_format, "all",
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
                all_numDoOopCallsTotal, all_numDoOopCalls_nv,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
                100.0 * (float)all_numDoOopCalls_nv /
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
                (float)all_numDoOopCallsTotal);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  const char* kind_names[] = { "ik", "irk", "oa" };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  for (int k = ik; k < NUM_Kinds; k++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    gclog_or_tty->print_cr(line_format, kind_names[k],
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
                  _numDoOopCallsTotal[k], _numDoOopCalls_nv[k],
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
                  (_numDoOopCallsTotal[k] > 0 ?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
                   100.0 * (float)_numDoOopCalls_nv[k] /
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
                   (float)_numDoOopCallsTotal[k]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
                   : 0.0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
#endif  // ENABLE_SPECIALIZATION_STATS
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
#endif  // !PRODUCT