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

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

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

mercurial