annotate src/share/vm/gc_implementation/shared/ageTable.cpp @ 1842:6e0aac35bfa9

6980838: G1: guarantee(false) failed: thread has an unexpected active value in its SATB queue Summary: Under certain circumstances a safepoint could happen between a JavaThread object being created and that object being added to the Java threads list. This could cause the active field of that thread's SATB queue to get out-of-sync with respect to the other Java threads. The solution is to activate the SATB queue, when necessary, before adding the thread to the Java threads list, not when the JavaThread object is created. The changeset also includes a small fix to rename the surrogate locker thread from "Surrogate Locker Thread (CMS)" to "Surrogate Locker Thread (Concurrent GC)" since it's also used in G1. Reviewed-by: iveresov, ysr, johnc, jcoomes
author tonyp
date Fri, 01 Oct 2010 16:43:05 -0400
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: 579
diff changeset
2 * Copyright (c) 1997, 2009, 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: 579
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 579
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: 579
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
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 579
diff changeset
25 /* Copyright (c) 1992-2009 Oracle and/or its affiliates, and Stanford University.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
26 See the LICENSE file for license information. */
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 # include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
29 # include "incls/_ageTable.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 ageTable::ageTable(bool global) {
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 if (UsePerfData && global) {
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 EXCEPTION_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 const char* agetable_ns = "generation.0.agetable";
a61af66fc99e Initial load
duke
parents:
diff changeset
41 const char* bytes_ns = PerfDataManager::name_space(agetable_ns, "bytes");
a61af66fc99e Initial load
duke
parents:
diff changeset
42
a61af66fc99e Initial load
duke
parents:
diff changeset
43 for(int age = 0; age < table_size; age ++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
44 char age_name[10];
a61af66fc99e Initial load
duke
parents:
diff changeset
45 jio_snprintf(age_name, sizeof(age_name), "%2.2d", age);
a61af66fc99e Initial load
duke
parents:
diff changeset
46 const char* cname = PerfDataManager::counter_name(bytes_ns, age_name);
a61af66fc99e Initial load
duke
parents:
diff changeset
47 _perf_sizes[age] = PerfDataManager::create_variable(SUN_GC, cname,
a61af66fc99e Initial load
duke
parents:
diff changeset
48 PerfData::U_Bytes,
a61af66fc99e Initial load
duke
parents:
diff changeset
49 CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
50 }
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 const char* cname = PerfDataManager::counter_name(agetable_ns, "size");
a61af66fc99e Initial load
duke
parents:
diff changeset
53 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_None,
a61af66fc99e Initial load
duke
parents:
diff changeset
54 table_size, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
55 }
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 void ageTable::clear() {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 for (size_t* p = sizes; p < sizes + table_size; ++p) {
a61af66fc99e Initial load
duke
parents:
diff changeset
60 *p = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 }
a61af66fc99e Initial load
duke
parents:
diff changeset
62 }
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 void ageTable::merge(ageTable* subTable) {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 for (int i = 0; i < table_size; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 sizes[i]+= subTable->sizes[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
67 }
a61af66fc99e Initial load
duke
parents:
diff changeset
68 }
a61af66fc99e Initial load
duke
parents:
diff changeset
69
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 0
diff changeset
70 void ageTable::merge_par(ageTable* subTable) {
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 0
diff changeset
71 for (int i = 0; i < table_size; i++) {
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 0
diff changeset
72 Atomic::add_ptr(subTable->sizes[i], &sizes[i]);
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 0
diff changeset
73 }
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 0
diff changeset
74 }
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 0
diff changeset
75
0
a61af66fc99e Initial load
duke
parents:
diff changeset
76 int ageTable::compute_tenuring_threshold(size_t survivor_capacity) {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 size_t desired_survivor_size = (size_t)((((double) survivor_capacity)*TargetSurvivorRatio)/100);
a61af66fc99e Initial load
duke
parents:
diff changeset
78 size_t total = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 int age = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
80 assert(sizes[0] == 0, "no objects with age zero should be recorded");
a61af66fc99e Initial load
duke
parents:
diff changeset
81 while (age < table_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 total += sizes[age];
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // check if including objects of age 'age' made us pass the desired
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // size, if so 'age' is the new threshold
a61af66fc99e Initial load
duke
parents:
diff changeset
85 if (total > desired_survivor_size) break;
a61af66fc99e Initial load
duke
parents:
diff changeset
86 age++;
a61af66fc99e Initial load
duke
parents:
diff changeset
87 }
a61af66fc99e Initial load
duke
parents:
diff changeset
88 int result = age < MaxTenuringThreshold ? age : MaxTenuringThreshold;
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 if (PrintTenuringDistribution || UsePerfData) {
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 if (PrintTenuringDistribution) {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 gclog_or_tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
94 gclog_or_tty->print_cr("Desired survivor size %ld bytes, new threshold %d (max %d)",
a61af66fc99e Initial load
duke
parents:
diff changeset
95 desired_survivor_size*oopSize, result, MaxTenuringThreshold);
a61af66fc99e Initial load
duke
parents:
diff changeset
96 }
a61af66fc99e Initial load
duke
parents:
diff changeset
97
a61af66fc99e Initial load
duke
parents:
diff changeset
98 total = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
99 age = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 while (age < table_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
101 total += sizes[age];
a61af66fc99e Initial load
duke
parents:
diff changeset
102 if (sizes[age] > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 if (PrintTenuringDistribution) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 gclog_or_tty->print_cr("- age %3d: %10ld bytes, %10ld total",
a61af66fc99e Initial load
duke
parents:
diff changeset
105 age, sizes[age]*oopSize, total*oopSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108 if (UsePerfData) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 _perf_sizes[age]->set_value(sizes[age]*oopSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 }
a61af66fc99e Initial load
duke
parents:
diff changeset
111 age++;
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113 if (UsePerfData) {
a61af66fc99e Initial load
duke
parents:
diff changeset
114 SharedHeap* sh = SharedHeap::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
115 CollectorPolicy* policy = sh->collector_policy();
a61af66fc99e Initial load
duke
parents:
diff changeset
116 GCPolicyCounters* gc_counters = policy->counters();
a61af66fc99e Initial load
duke
parents:
diff changeset
117 gc_counters->tenuring_threshold()->set_value(result);
a61af66fc99e Initial load
duke
parents:
diff changeset
118 gc_counters->desired_survivor_size()->set_value(
a61af66fc99e Initial load
duke
parents:
diff changeset
119 desired_survivor_size*oopSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121 }
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }