annotate src/share/vm/memory/specialized_oop_closures.cpp @ 1716:be3f9c242c9d

6948538: CMS: BOT walkers can fall into object allocation and initialization cracks Summary: GC workers now recognize an intermediate transient state of blocks which are allocated but have not yet completed initialization. blk_start() calls do not attempt to determine the size of a block in the transient state, rather waiting for the block to become initialized so that it is safe to query its size. Audited and ensured the order of initialization of object fields (klass, free bit and size) to respect block state transition protocol. Also included some new assertion checking code enabled in debug mode. Reviewed-by: chrisphi, johnc, poonam
author ysr
date Mon, 16 Aug 2010 15:58:42 -0700
parents c18cbe5936b8
children f95d63e2154a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 2001, 2003, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 # include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 # include "incls/_specialized_oop_closures.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // For keeping stats on effectiveness.
a61af66fc99e Initial load
duke
parents:
diff changeset
29 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
30 #if ENABLE_SPECIALIZATION_STATS
a61af66fc99e Initial load
duke
parents:
diff changeset
31
a61af66fc99e Initial load
duke
parents:
diff changeset
32 int SpecializationStats::_numCallsAll;
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 int SpecializationStats::_numCallsTotal[NUM_Kinds];
a61af66fc99e Initial load
duke
parents:
diff changeset
35 int SpecializationStats::_numCalls_nv[NUM_Kinds];
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 int SpecializationStats::_numDoOopCallsTotal[NUM_Kinds];
a61af66fc99e Initial load
duke
parents:
diff changeset
38 int SpecializationStats::_numDoOopCalls_nv[NUM_Kinds];
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 void SpecializationStats::clear() {
a61af66fc99e Initial load
duke
parents:
diff changeset
41 _numCallsAll = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 for (int k = ik; k < NUM_Kinds; k++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
43 _numCallsTotal[k] = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 _numCalls_nv[k] = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 _numDoOopCallsTotal[k] = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 _numDoOopCalls_nv[k] = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 }
a61af66fc99e Initial load
duke
parents:
diff changeset
49 }
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 void SpecializationStats::print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 const char* header_format = " %20s %10s %11s %10s";
a61af66fc99e Initial load
duke
parents:
diff changeset
53 const char* line_format = " %20s %10d %11d %9.2f%%";
a61af66fc99e Initial load
duke
parents:
diff changeset
54 int all_numCallsTotal =
a61af66fc99e Initial load
duke
parents:
diff changeset
55 _numCallsTotal[ik] + _numCallsTotal[irk] + _numCallsTotal[oa];
a61af66fc99e Initial load
duke
parents:
diff changeset
56 int all_numCalls_nv =
a61af66fc99e Initial load
duke
parents:
diff changeset
57 _numCalls_nv[ik] + _numCalls_nv[irk] + _numCalls_nv[oa];
a61af66fc99e 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).",
a61af66fc99e Initial load
duke
parents:
diff changeset
59 _numCallsAll, all_numCallsTotal,
a61af66fc99e Initial load
duke
parents:
diff changeset
60 100.0 * (float)all_numCallsTotal / (float)_numCallsAll);
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // irk calls are double-counted.
a61af66fc99e Initial load
duke
parents:
diff changeset
62 int real_ik_numCallsTotal = _numCallsTotal[ik] - _numCallsTotal[irk];
a61af66fc99e Initial load
duke
parents:
diff changeset
63 int real_ik_numCalls_nv = _numCalls_nv[ik] - _numCalls_nv[irk];
a61af66fc99e Initial load
duke
parents:
diff changeset
64 gclog_or_tty->print_cr("");
a61af66fc99e Initial load
duke
parents:
diff changeset
65 gclog_or_tty->print_cr(header_format, "oop_oop_iterate:", "calls", "non-virtual", "pct");
a61af66fc99e Initial load
duke
parents:
diff changeset
66 gclog_or_tty->print_cr(header_format,
a61af66fc99e Initial load
duke
parents:
diff changeset
67 "----------",
a61af66fc99e Initial load
duke
parents:
diff changeset
68 "----------",
a61af66fc99e Initial load
duke
parents:
diff changeset
69 "-----------",
a61af66fc99e Initial load
duke
parents:
diff changeset
70 "----------");
a61af66fc99e Initial load
duke
parents:
diff changeset
71 gclog_or_tty->print_cr(line_format, "all",
a61af66fc99e Initial load
duke
parents:
diff changeset
72 all_numCallsTotal,
a61af66fc99e Initial load
duke
parents:
diff changeset
73 all_numCalls_nv,
a61af66fc99e Initial load
duke
parents:
diff changeset
74 100.0 * (float)all_numCalls_nv / (float)all_numCallsTotal);
a61af66fc99e Initial load
duke
parents:
diff changeset
75 gclog_or_tty->print_cr(line_format, "ik",
a61af66fc99e Initial load
duke
parents:
diff changeset
76 real_ik_numCallsTotal, real_ik_numCalls_nv,
a61af66fc99e Initial load
duke
parents:
diff changeset
77 100.0 * (float)real_ik_numCalls_nv /
a61af66fc99e Initial load
duke
parents:
diff changeset
78 (float)real_ik_numCallsTotal);
a61af66fc99e Initial load
duke
parents:
diff changeset
79 gclog_or_tty->print_cr(line_format, "irk",
a61af66fc99e Initial load
duke
parents:
diff changeset
80 _numCallsTotal[irk], _numCalls_nv[irk],
a61af66fc99e Initial load
duke
parents:
diff changeset
81 100.0 * (float)_numCalls_nv[irk] / (float)_numCallsTotal[irk]);
a61af66fc99e Initial load
duke
parents:
diff changeset
82 gclog_or_tty->print_cr(line_format, "oa",
a61af66fc99e Initial load
duke
parents:
diff changeset
83 _numCallsTotal[oa], _numCalls_nv[oa],
a61af66fc99e Initial load
duke
parents:
diff changeset
84 100.0 * (float)_numCalls_nv[oa] / (float)_numCallsTotal[oa]);
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 gclog_or_tty->print_cr("");
a61af66fc99e Initial load
duke
parents:
diff changeset
88 gclog_or_tty->print_cr(header_format, "do_oop:", "calls", "non-virtual", "pct");
a61af66fc99e Initial load
duke
parents:
diff changeset
89 gclog_or_tty->print_cr(header_format,
a61af66fc99e Initial load
duke
parents:
diff changeset
90 "----------",
a61af66fc99e Initial load
duke
parents:
diff changeset
91 "----------",
a61af66fc99e Initial load
duke
parents:
diff changeset
92 "-----------",
a61af66fc99e Initial load
duke
parents:
diff changeset
93 "----------");
a61af66fc99e Initial load
duke
parents:
diff changeset
94 int all_numDoOopCallsTotal =
a61af66fc99e Initial load
duke
parents:
diff changeset
95 _numDoOopCallsTotal[ik] + _numDoOopCallsTotal[irk] + _numDoOopCallsTotal[oa];
a61af66fc99e Initial load
duke
parents:
diff changeset
96 int all_numDoOopCalls_nv =
a61af66fc99e Initial load
duke
parents:
diff changeset
97 _numDoOopCalls_nv[ik] + _numDoOopCalls_nv[irk] + _numDoOopCalls_nv[oa];
a61af66fc99e Initial load
duke
parents:
diff changeset
98 gclog_or_tty->print_cr(line_format, "all",
a61af66fc99e Initial load
duke
parents:
diff changeset
99 all_numDoOopCallsTotal, all_numDoOopCalls_nv,
a61af66fc99e Initial load
duke
parents:
diff changeset
100 100.0 * (float)all_numDoOopCalls_nv /
a61af66fc99e Initial load
duke
parents:
diff changeset
101 (float)all_numDoOopCallsTotal);
a61af66fc99e Initial load
duke
parents:
diff changeset
102 const char* kind_names[] = { "ik", "irk", "oa" };
a61af66fc99e Initial load
duke
parents:
diff changeset
103 for (int k = ik; k < NUM_Kinds; k++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 gclog_or_tty->print_cr(line_format, kind_names[k],
a61af66fc99e Initial load
duke
parents:
diff changeset
105 _numDoOopCallsTotal[k], _numDoOopCalls_nv[k],
a61af66fc99e Initial load
duke
parents:
diff changeset
106 (_numDoOopCallsTotal[k] > 0 ?
a61af66fc99e Initial load
duke
parents:
diff changeset
107 100.0 * (float)_numDoOopCalls_nv[k] /
a61af66fc99e Initial load
duke
parents:
diff changeset
108 (float)_numDoOopCallsTotal[k]
a61af66fc99e Initial load
duke
parents:
diff changeset
109 : 0.0));
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 #endif // ENABLE_SPECIALIZATION_STATS
a61af66fc99e Initial load
duke
parents:
diff changeset
114 #endif // !PRODUCT