author | brutisso |
Thu, 02 Apr 2015 16:08:41 +0200 | |
changeset 30154 | 39cd4e2ccf1c |
parent 30147 | af9a41999c6e |
permissions | -rw-r--r-- |
1 | 1 |
/* |
23506
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
2 |
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
1 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2105
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2105
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2105
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
26 |
#include "gc_implementation/shared/ageTable.hpp" |
|
27 |
#include "gc_implementation/shared/gcPolicyCounters.hpp" |
|
30154 | 28 |
#include "gc_interface/collectedHeap.hpp" |
7397 | 29 |
#include "memory/collectorPolicy.hpp" |
30 |
#include "memory/resourceArea.hpp" |
|
25351
7c198a690050
8044775: Improve usage of umbrella header atomic.inline.hpp.
goetz
parents:
24424
diff
changeset
|
31 |
#include "runtime/atomic.inline.hpp" |
7397 | 32 |
#include "utilities/copy.hpp" |
33 |
||
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2105
diff
changeset
|
34 |
/* Copyright (c) 1992-2009 Oracle and/or its affiliates, and Stanford University. |
1 | 35 |
See the LICENSE file for license information. */ |
36 |
||
37 |
ageTable::ageTable(bool global) { |
|
38 |
||
39 |
clear(); |
|
40 |
||
41 |
if (UsePerfData && global) { |
|
42 |
||
43 |
ResourceMark rm; |
|
44 |
EXCEPTION_MARK; |
|
45 |
||
46 |
const char* agetable_ns = "generation.0.agetable"; |
|
47 |
const char* bytes_ns = PerfDataManager::name_space(agetable_ns, "bytes"); |
|
48 |
||
49 |
for(int age = 0; age < table_size; age ++) { |
|
50 |
char age_name[10]; |
|
51 |
jio_snprintf(age_name, sizeof(age_name), "%2.2d", age); |
|
52 |
const char* cname = PerfDataManager::counter_name(bytes_ns, age_name); |
|
53 |
_perf_sizes[age] = PerfDataManager::create_variable(SUN_GC, cname, |
|
54 |
PerfData::U_Bytes, |
|
55 |
CHECK); |
|
56 |
} |
|
57 |
||
58 |
const char* cname = PerfDataManager::counter_name(agetable_ns, "size"); |
|
59 |
PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_None, |
|
60 |
table_size, CHECK); |
|
61 |
} |
|
62 |
} |
|
63 |
||
64 |
void ageTable::clear() { |
|
65 |
for (size_t* p = sizes; p < sizes + table_size; ++p) { |
|
66 |
*p = 0; |
|
67 |
} |
|
68 |
} |
|
69 |
||
70 |
void ageTable::merge(ageTable* subTable) { |
|
71 |
for (int i = 0; i < table_size; i++) { |
|
72 |
sizes[i]+= subTable->sizes[i]; |
|
73 |
} |
|
74 |
} |
|
75 |
||
2009 | 76 |
void ageTable::merge_par(ageTable* subTable) { |
77 |
for (int i = 0; i < table_size; i++) { |
|
78 |
Atomic::add_ptr(subTable->sizes[i], &sizes[i]); |
|
79 |
} |
|
80 |
} |
|
81 |
||
30147
af9a41999c6e
8076314: Remove the static instance variable SharedHeap:: _sh
brutisso
parents:
25351
diff
changeset
|
82 |
uint ageTable::compute_tenuring_threshold(size_t survivor_capacity, GCPolicyCounters* gc_counters) { |
1 | 83 |
size_t desired_survivor_size = (size_t)((((double) survivor_capacity)*TargetSurvivorRatio)/100); |
23506
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
84 |
uint result; |
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
85 |
|
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
86 |
if (AlwaysTenure || NeverTenure) { |
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
87 |
assert(MaxTenuringThreshold == 0 || MaxTenuringThreshold == markOopDesc::max_age + 1, |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23506
diff
changeset
|
88 |
err_msg("MaxTenuringThreshold should be 0 or markOopDesc::max_age + 1, but is " UINTX_FORMAT, MaxTenuringThreshold)); |
23506
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
89 |
result = MaxTenuringThreshold; |
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
90 |
} else { |
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
91 |
size_t total = 0; |
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
92 |
uint age = 1; |
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
93 |
assert(sizes[0] == 0, "no objects with age zero should be recorded"); |
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
94 |
while (age < table_size) { |
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
95 |
total += sizes[age]; |
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
96 |
// check if including objects of age 'age' made us pass the desired |
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
97 |
// size, if so 'age' is the new threshold |
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
98 |
if (total > desired_survivor_size) break; |
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
99 |
age++; |
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
100 |
} |
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
101 |
result = age < MaxTenuringThreshold ? age : MaxTenuringThreshold; |
1 | 102 |
} |
103 |
||
104 |
if (PrintTenuringDistribution || UsePerfData) { |
|
105 |
||
106 |
if (PrintTenuringDistribution) { |
|
107 |
gclog_or_tty->cr(); |
|
23506
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
108 |
gclog_or_tty->print_cr("Desired survivor size " SIZE_FORMAT " bytes, new threshold " |
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
109 |
UINTX_FORMAT " (max threshold " UINTX_FORMAT ")", |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23506
diff
changeset
|
110 |
desired_survivor_size*oopSize, (uintx) result, MaxTenuringThreshold); |
1 | 111 |
} |
112 |
||
23506
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
113 |
size_t total = 0; |
9b98355e9060
6521376: MaxTenuringThreshold and AlwayTenure/NeverTenure consistency
tamao
parents:
15228
diff
changeset
|
114 |
uint age = 1; |
1 | 115 |
while (age < table_size) { |
116 |
total += sizes[age]; |
|
117 |
if (sizes[age] > 0) { |
|
118 |
if (PrintTenuringDistribution) { |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23506
diff
changeset
|
119 |
gclog_or_tty->print_cr("- age %3u: " SIZE_FORMAT_W(10) " bytes, " SIZE_FORMAT_W(10) " total", |
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
23506
diff
changeset
|
120 |
age, sizes[age]*oopSize, total*oopSize); |
1 | 121 |
} |
122 |
} |
|
123 |
if (UsePerfData) { |
|
124 |
_perf_sizes[age]->set_value(sizes[age]*oopSize); |
|
125 |
} |
|
126 |
age++; |
|
127 |
} |
|
128 |
if (UsePerfData) { |
|
129 |
gc_counters->tenuring_threshold()->set_value(result); |
|
130 |
gc_counters->desired_survivor_size()->set_value( |
|
131 |
desired_survivor_size*oopSize); |
|
132 |
} |
|
133 |
} |
|
134 |
||
135 |
return result; |
|
136 |
} |