src/share/vm/gc_implementation/shared/ageTable.cpp

Thu, 04 Oct 2012 10:40:23 -0700

author
jmasa
date
Thu, 04 Oct 2012 10:40:23 -0700
changeset 4131
097d78aaf2b5
parent 4129
22b8d3d181d9
child 4465
203f64878aab
permissions
-rw-r--r--

7198873: NPG: VM Does not unload classes with UseConcMarkSweepGC
Reviewed-by: johnc, mgerdin, jwilhelm

duke@435 1 /*
stefank@2314 2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #include "precompiled.hpp"
stefank@2314 26 #include "gc_implementation/shared/ageTable.hpp"
stefank@2314 27 #include "gc_implementation/shared/gcPolicyCounters.hpp"
stefank@2314 28 #include "memory/collectorPolicy.hpp"
stefank@2314 29 #include "memory/resourceArea.hpp"
stefank@2314 30 #include "memory/sharedHeap.hpp"
stefank@2314 31 #include "utilities/copy.hpp"
stefank@2314 32
trims@1907 33 /* Copyright (c) 1992-2009 Oracle and/or its affiliates, and Stanford University.
duke@435 34 See the LICENSE file for license information. */
duke@435 35
duke@435 36 ageTable::ageTable(bool global) {
duke@435 37
duke@435 38 clear();
duke@435 39
duke@435 40 if (UsePerfData && global) {
duke@435 41
duke@435 42 ResourceMark rm;
duke@435 43 EXCEPTION_MARK;
duke@435 44
duke@435 45 const char* agetable_ns = "generation.0.agetable";
duke@435 46 const char* bytes_ns = PerfDataManager::name_space(agetable_ns, "bytes");
duke@435 47
duke@435 48 for(int age = 0; age < table_size; age ++) {
duke@435 49 char age_name[10];
duke@435 50 jio_snprintf(age_name, sizeof(age_name), "%2.2d", age);
duke@435 51 const char* cname = PerfDataManager::counter_name(bytes_ns, age_name);
duke@435 52 _perf_sizes[age] = PerfDataManager::create_variable(SUN_GC, cname,
duke@435 53 PerfData::U_Bytes,
duke@435 54 CHECK);
duke@435 55 }
duke@435 56
duke@435 57 const char* cname = PerfDataManager::counter_name(agetable_ns, "size");
duke@435 58 PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_None,
duke@435 59 table_size, CHECK);
duke@435 60 }
duke@435 61 }
duke@435 62
duke@435 63 void ageTable::clear() {
duke@435 64 for (size_t* p = sizes; p < sizes + table_size; ++p) {
duke@435 65 *p = 0;
duke@435 66 }
duke@435 67 }
duke@435 68
duke@435 69 void ageTable::merge(ageTable* subTable) {
duke@435 70 for (int i = 0; i < table_size; i++) {
duke@435 71 sizes[i]+= subTable->sizes[i];
duke@435 72 }
duke@435 73 }
duke@435 74
apetrusenko@980 75 void ageTable::merge_par(ageTable* subTable) {
apetrusenko@980 76 for (int i = 0; i < table_size; i++) {
apetrusenko@980 77 Atomic::add_ptr(subTable->sizes[i], &sizes[i]);
apetrusenko@980 78 }
apetrusenko@980 79 }
apetrusenko@980 80
jwilhelm@4129 81 uint ageTable::compute_tenuring_threshold(size_t survivor_capacity) {
duke@435 82 size_t desired_survivor_size = (size_t)((((double) survivor_capacity)*TargetSurvivorRatio)/100);
duke@435 83 size_t total = 0;
jwilhelm@4129 84 uint age = 1;
duke@435 85 assert(sizes[0] == 0, "no objects with age zero should be recorded");
duke@435 86 while (age < table_size) {
duke@435 87 total += sizes[age];
duke@435 88 // check if including objects of age 'age' made us pass the desired
duke@435 89 // size, if so 'age' is the new threshold
duke@435 90 if (total > desired_survivor_size) break;
duke@435 91 age++;
duke@435 92 }
jwilhelm@4129 93 uint result = age < MaxTenuringThreshold ? age : MaxTenuringThreshold;
duke@435 94
duke@435 95 if (PrintTenuringDistribution || UsePerfData) {
duke@435 96
duke@435 97 if (PrintTenuringDistribution) {
duke@435 98 gclog_or_tty->cr();
jwilhelm@4129 99 gclog_or_tty->print_cr("Desired survivor size %ld bytes, new threshold %u (max %u)",
duke@435 100 desired_survivor_size*oopSize, result, MaxTenuringThreshold);
duke@435 101 }
duke@435 102
duke@435 103 total = 0;
duke@435 104 age = 1;
duke@435 105 while (age < table_size) {
duke@435 106 total += sizes[age];
duke@435 107 if (sizes[age] > 0) {
duke@435 108 if (PrintTenuringDistribution) {
jwilhelm@4129 109 gclog_or_tty->print_cr("- age %3u: %10ld bytes, %10ld total",
duke@435 110 age, sizes[age]*oopSize, total*oopSize);
duke@435 111 }
duke@435 112 }
duke@435 113 if (UsePerfData) {
duke@435 114 _perf_sizes[age]->set_value(sizes[age]*oopSize);
duke@435 115 }
duke@435 116 age++;
duke@435 117 }
duke@435 118 if (UsePerfData) {
duke@435 119 SharedHeap* sh = SharedHeap::heap();
duke@435 120 CollectorPolicy* policy = sh->collector_policy();
duke@435 121 GCPolicyCounters* gc_counters = policy->counters();
duke@435 122 gc_counters->tenuring_threshold()->set_value(result);
duke@435 123 gc_counters->desired_survivor_size()->set_value(
duke@435 124 desired_survivor_size*oopSize);
duke@435 125 }
duke@435 126 }
duke@435 127
duke@435 128 return result;
duke@435 129 }

mercurial