Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/shared/ageTable.cpp @ 0:a61af66fc99e jdk7-b24
Initial load
author | duke |
---|---|
date | Sat, 01 Dec 2007 00:00:00 +0000 |
parents | |
children | 58054a18d735 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a61af66fc99e |
---|---|
1 /* | |
2 * Copyright 1997-2004 Sun Microsystems, Inc. All Rights Reserved. | |
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 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 /* Copyright 1992 Sun Microsystems, Inc. and Stanford University. | |
26 See the LICENSE file for license information. */ | |
27 | |
28 # include "incls/_precompiled.incl" | |
29 # include "incls/_ageTable.cpp.incl" | |
30 | |
31 ageTable::ageTable(bool global) { | |
32 | |
33 clear(); | |
34 | |
35 if (UsePerfData && global) { | |
36 | |
37 ResourceMark rm; | |
38 EXCEPTION_MARK; | |
39 | |
40 const char* agetable_ns = "generation.0.agetable"; | |
41 const char* bytes_ns = PerfDataManager::name_space(agetable_ns, "bytes"); | |
42 | |
43 for(int age = 0; age < table_size; age ++) { | |
44 char age_name[10]; | |
45 jio_snprintf(age_name, sizeof(age_name), "%2.2d", age); | |
46 const char* cname = PerfDataManager::counter_name(bytes_ns, age_name); | |
47 _perf_sizes[age] = PerfDataManager::create_variable(SUN_GC, cname, | |
48 PerfData::U_Bytes, | |
49 CHECK); | |
50 } | |
51 | |
52 const char* cname = PerfDataManager::counter_name(agetable_ns, "size"); | |
53 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_None, | |
54 table_size, CHECK); | |
55 } | |
56 } | |
57 | |
58 void ageTable::clear() { | |
59 for (size_t* p = sizes; p < sizes + table_size; ++p) { | |
60 *p = 0; | |
61 } | |
62 } | |
63 | |
64 void ageTable::merge(ageTable* subTable) { | |
65 for (int i = 0; i < table_size; i++) { | |
66 sizes[i]+= subTable->sizes[i]; | |
67 } | |
68 } | |
69 | |
70 int ageTable::compute_tenuring_threshold(size_t survivor_capacity) { | |
71 size_t desired_survivor_size = (size_t)((((double) survivor_capacity)*TargetSurvivorRatio)/100); | |
72 size_t total = 0; | |
73 int age = 1; | |
74 assert(sizes[0] == 0, "no objects with age zero should be recorded"); | |
75 while (age < table_size) { | |
76 total += sizes[age]; | |
77 // check if including objects of age 'age' made us pass the desired | |
78 // size, if so 'age' is the new threshold | |
79 if (total > desired_survivor_size) break; | |
80 age++; | |
81 } | |
82 int result = age < MaxTenuringThreshold ? age : MaxTenuringThreshold; | |
83 | |
84 if (PrintTenuringDistribution || UsePerfData) { | |
85 | |
86 if (PrintTenuringDistribution) { | |
87 gclog_or_tty->cr(); | |
88 gclog_or_tty->print_cr("Desired survivor size %ld bytes, new threshold %d (max %d)", | |
89 desired_survivor_size*oopSize, result, MaxTenuringThreshold); | |
90 } | |
91 | |
92 total = 0; | |
93 age = 1; | |
94 while (age < table_size) { | |
95 total += sizes[age]; | |
96 if (sizes[age] > 0) { | |
97 if (PrintTenuringDistribution) { | |
98 gclog_or_tty->print_cr("- age %3d: %10ld bytes, %10ld total", | |
99 age, sizes[age]*oopSize, total*oopSize); | |
100 } | |
101 } | |
102 if (UsePerfData) { | |
103 _perf_sizes[age]->set_value(sizes[age]*oopSize); | |
104 } | |
105 age++; | |
106 } | |
107 if (UsePerfData) { | |
108 SharedHeap* sh = SharedHeap::heap(); | |
109 CollectorPolicy* policy = sh->collector_policy(); | |
110 GCPolicyCounters* gc_counters = policy->counters(); | |
111 gc_counters->tenuring_threshold()->set_value(result); | |
112 gc_counters->desired_survivor_size()->set_value( | |
113 desired_survivor_size*oopSize); | |
114 } | |
115 } | |
116 | |
117 return result; | |
118 } |