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

Sun, 13 Apr 2008 17:43:42 -0400

author
coleenp
date
Sun, 13 Apr 2008 17:43:42 -0400
changeset 548
ba764ed4b6f2
parent 435
a61af66fc99e
child 980
58054a18d735
permissions
-rw-r--r--

6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold

     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  */
    25 /* Copyright 1992 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 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;
    84   if (PrintTenuringDistribution || UsePerfData) {
    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     }
    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   }
   117   return result;
   118 }

mercurial