annotate src/share/vm/gc_implementation/shared/ageTable.cpp @ 1972:f95d63e2154a

6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
author stefank
date Tue, 23 Nov 2010 13:22:55 -0800
parents c18cbe5936b8
children 22b8d3d181d9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 1997, 2010, 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
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "gc_implementation/shared/ageTable.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "gc_implementation/shared/gcPolicyCounters.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "memory/collectorPolicy.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "memory/resourceArea.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "memory/sharedHeap.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #include "utilities/copy.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 579
diff changeset
33 /* Copyright (c) 1992-2009 Oracle and/or its affiliates, and Stanford University.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
34 See the LICENSE file for license information. */
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 ageTable::ageTable(bool global) {
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 clear();
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 if (UsePerfData && global) {
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 EXCEPTION_MARK;
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 const char* agetable_ns = "generation.0.agetable";
a61af66fc99e Initial load
duke
parents:
diff changeset
46 const char* bytes_ns = PerfDataManager::name_space(agetable_ns, "bytes");
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 for(int age = 0; age < table_size; age ++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 char age_name[10];
a61af66fc99e Initial load
duke
parents:
diff changeset
50 jio_snprintf(age_name, sizeof(age_name), "%2.2d", age);
a61af66fc99e Initial load
duke
parents:
diff changeset
51 const char* cname = PerfDataManager::counter_name(bytes_ns, age_name);
a61af66fc99e Initial load
duke
parents:
diff changeset
52 _perf_sizes[age] = PerfDataManager::create_variable(SUN_GC, cname,
a61af66fc99e Initial load
duke
parents:
diff changeset
53 PerfData::U_Bytes,
a61af66fc99e Initial load
duke
parents:
diff changeset
54 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 const char* cname = PerfDataManager::counter_name(agetable_ns, "size");
a61af66fc99e Initial load
duke
parents:
diff changeset
58 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_None,
a61af66fc99e Initial load
duke
parents:
diff changeset
59 table_size, CHECK);
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
a61af66fc99e Initial load
duke
parents:
diff changeset
61 }
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 void ageTable::clear() {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 for (size_t* p = sizes; p < sizes + table_size; ++p) {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 *p = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 }
a61af66fc99e Initial load
duke
parents:
diff changeset
67 }
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 void ageTable::merge(ageTable* subTable) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 for (int i = 0; i < table_size; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 sizes[i]+= subTable->sizes[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74
545
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 0
diff changeset
75 void ageTable::merge_par(ageTable* subTable) {
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 0
diff changeset
76 for (int i = 0; i < table_size; i++) {
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 0
diff changeset
77 Atomic::add_ptr(subTable->sizes[i], &sizes[i]);
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 0
diff changeset
78 }
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 0
diff changeset
79 }
58054a18d735 6484959: G1: introduce survivor spaces
apetrusenko
parents: 0
diff changeset
80
0
a61af66fc99e Initial load
duke
parents:
diff changeset
81 int ageTable::compute_tenuring_threshold(size_t survivor_capacity) {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 size_t desired_survivor_size = (size_t)((((double) survivor_capacity)*TargetSurvivorRatio)/100);
a61af66fc99e Initial load
duke
parents:
diff changeset
83 size_t total = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 int age = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
85 assert(sizes[0] == 0, "no objects with age zero should be recorded");
a61af66fc99e Initial load
duke
parents:
diff changeset
86 while (age < table_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 total += sizes[age];
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // check if including objects of age 'age' made us pass the desired
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // size, if so 'age' is the new threshold
a61af66fc99e Initial load
duke
parents:
diff changeset
90 if (total > desired_survivor_size) break;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 age++;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 }
a61af66fc99e Initial load
duke
parents:
diff changeset
93 int result = age < MaxTenuringThreshold ? age : MaxTenuringThreshold;
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 if (PrintTenuringDistribution || UsePerfData) {
a61af66fc99e Initial load
duke
parents:
diff changeset
96
a61af66fc99e Initial load
duke
parents:
diff changeset
97 if (PrintTenuringDistribution) {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 gclog_or_tty->cr();
a61af66fc99e Initial load
duke
parents:
diff changeset
99 gclog_or_tty->print_cr("Desired survivor size %ld bytes, new threshold %d (max %d)",
a61af66fc99e Initial load
duke
parents:
diff changeset
100 desired_survivor_size*oopSize, result, MaxTenuringThreshold);
a61af66fc99e Initial load
duke
parents:
diff changeset
101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 total = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 age = 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
105 while (age < table_size) {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 total += sizes[age];
a61af66fc99e Initial load
duke
parents:
diff changeset
107 if (sizes[age] > 0) {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 if (PrintTenuringDistribution) {
a61af66fc99e Initial load
duke
parents:
diff changeset
109 gclog_or_tty->print_cr("- age %3d: %10ld bytes, %10ld total",
a61af66fc99e Initial load
duke
parents:
diff changeset
110 age, sizes[age]*oopSize, total*oopSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
111 }
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 _perf_sizes[age]->set_value(sizes[age]*oopSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }
a61af66fc99e Initial load
duke
parents:
diff changeset
116 age++;
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118 if (UsePerfData) {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 SharedHeap* sh = SharedHeap::heap();
a61af66fc99e Initial load
duke
parents:
diff changeset
120 CollectorPolicy* policy = sh->collector_policy();
a61af66fc99e Initial load
duke
parents:
diff changeset
121 GCPolicyCounters* gc_counters = policy->counters();
a61af66fc99e Initial load
duke
parents:
diff changeset
122 gc_counters->tenuring_threshold()->set_value(result);
a61af66fc99e Initial load
duke
parents:
diff changeset
123 gc_counters->desired_survivor_size()->set_value(
a61af66fc99e Initial load
duke
parents:
diff changeset
124 desired_survivor_size*oopSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
125 }
a61af66fc99e Initial load
duke
parents:
diff changeset
126 }
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 return result;
a61af66fc99e Initial load
duke
parents:
diff changeset
129 }