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

Mon, 09 Mar 2009 13:28:46 -0700

author
xdono
date
Mon, 09 Mar 2009 13:28:46 -0700
changeset 1014
0fbdb4381b99
parent 980
58054a18d735
child 1907
c18cbe5936b8
permissions
-rw-r--r--

6814575: Update copyright year
Summary: Update copyright for files that have been modified in 2009, up to 03/09
Reviewed-by: katleman, tbell, ohair

     1 /*
     2  * Copyright 1997-2009 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  */
    25 /* Copyright 1992-2009 Sun Microsystems, Inc. and Stanford University.
    26    See the LICENSE file for license information. */
    28 # include "incls/_precompiled.incl"
    29 # include "incls/_ageTable.cpp.incl"
    31 ageTable::ageTable(bool global) {
    33   clear();
    35   if (UsePerfData && global) {
    37     ResourceMark rm;
    38     EXCEPTION_MARK;
    40     const char* agetable_ns = "generation.0.agetable";
    41     const char* bytes_ns = PerfDataManager::name_space(agetable_ns, "bytes");
    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     }
    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 }
    58 void ageTable::clear() {
    59   for (size_t* p = sizes; p < sizes + table_size; ++p) {
    60     *p = 0;
    61   }
    62 }
    64 void ageTable::merge(ageTable* subTable) {
    65   for (int i = 0; i < table_size; i++) {
    66     sizes[i]+= subTable->sizes[i];
    67   }
    68 }
    70 void ageTable::merge_par(ageTable* subTable) {
    71   for (int i = 0; i < table_size; i++) {
    72     Atomic::add_ptr(subTable->sizes[i], &sizes[i]);
    73   }
    74 }
    76 int ageTable::compute_tenuring_threshold(size_t survivor_capacity) {
    77   size_t desired_survivor_size = (size_t)((((double) survivor_capacity)*TargetSurvivorRatio)/100);
    78   size_t total = 0;
    79   int age = 1;
    80   assert(sizes[0] == 0, "no objects with age zero should be recorded");
    81   while (age < table_size) {
    82     total += sizes[age];
    83     // check if including objects of age 'age' made us pass the desired
    84     // size, if so 'age' is the new threshold
    85     if (total > desired_survivor_size) break;
    86     age++;
    87   }
    88   int result = age < MaxTenuringThreshold ? age : MaxTenuringThreshold;
    90   if (PrintTenuringDistribution || UsePerfData) {
    92     if (PrintTenuringDistribution) {
    93       gclog_or_tty->cr();
    94       gclog_or_tty->print_cr("Desired survivor size %ld bytes, new threshold %d (max %d)",
    95         desired_survivor_size*oopSize, result, MaxTenuringThreshold);
    96     }
    98     total = 0;
    99     age = 1;
   100     while (age < table_size) {
   101       total += sizes[age];
   102       if (sizes[age] > 0) {
   103         if (PrintTenuringDistribution) {
   104           gclog_or_tty->print_cr("- age %3d: %10ld bytes, %10ld total",
   105             age, sizes[age]*oopSize, total*oopSize);
   106         }
   107       }
   108       if (UsePerfData) {
   109         _perf_sizes[age]->set_value(sizes[age]*oopSize);
   110       }
   111       age++;
   112     }
   113     if (UsePerfData) {
   114       SharedHeap* sh = SharedHeap::heap();
   115       CollectorPolicy* policy = sh->collector_policy();
   116       GCPolicyCounters* gc_counters = policy->counters();
   117       gc_counters->tenuring_threshold()->set_value(result);
   118       gc_counters->desired_survivor_size()->set_value(
   119         desired_survivor_size*oopSize);
   120     }
   121   }
   123   return result;
   124 }

mercurial