src/share/vm/gc_implementation/g1/g1AllocRegion.inline.hpp

Thu, 22 Sep 2011 10:57:37 -0700

author
johnc
date
Thu, 22 Sep 2011 10:57:37 -0700
changeset 3175
4dfb2df418f2
parent 0
f90c822e73f8
child 6990
1526a938e670
permissions
-rw-r--r--

6484982: G1: process references during evacuation pauses
Summary: G1 now uses two reference processors - one is used by concurrent marking and the other is used by STW GCs (both full and incremental evacuation pauses). In an evacuation pause, the reference processor is embedded into the closures used to scan objects. Doing so causes causes reference objects to be 'discovered' by the reference processor. At the end of the evacuation pause, these discovered reference objects are processed - preserving (and copying) referent objects (and their reachable graphs) as appropriate.
Reviewed-by: ysr, jwilhelm, brutisso, stefank, tonyp

     1 /*
     2  * Copyright (c) 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCREGION_INLINE_HPP
    26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCREGION_INLINE_HPP
    28 #include "gc_implementation/g1/g1AllocRegion.hpp"
    30 inline HeapWord* G1AllocRegion::allocate(HeapRegion* alloc_region,
    31                                          size_t word_size,
    32                                          bool bot_updates) {
    33   assert(alloc_region != NULL, err_msg("pre-condition"));
    35   if (!bot_updates) {
    36     return alloc_region->allocate_no_bot_updates(word_size);
    37   } else {
    38     return alloc_region->allocate(word_size);
    39   }
    40 }
    42 inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region,
    43                                              size_t word_size,
    44                                              bool bot_updates) {
    45   assert(alloc_region != NULL, err_msg("pre-condition"));
    46   assert(!alloc_region->is_empty(), err_msg("pre-condition"));
    48   if (!bot_updates) {
    49     return alloc_region->par_allocate_no_bot_updates(word_size);
    50   } else {
    51     return alloc_region->par_allocate(word_size);
    52   }
    53 }
    55 inline HeapWord* G1AllocRegion::attempt_allocation(size_t word_size,
    56                                                    bool bot_updates) {
    57   assert(bot_updates == _bot_updates, ar_ext_msg(this, "pre-condition"));
    59   HeapRegion* alloc_region = _alloc_region;
    60   assert(alloc_region != NULL, ar_ext_msg(this, "not initialized properly"));
    62   HeapWord* result = par_allocate(alloc_region, word_size, bot_updates);
    63   if (result != NULL) {
    64     trace("alloc", word_size, result);
    65     return result;
    66   }
    67   trace("alloc failed", word_size);
    68   return NULL;
    69 }
    71 inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t word_size,
    72                                                           bool bot_updates) {
    73   // First we have to tedo the allocation, assuming we're holding the
    74   // appropriate lock, in case another thread changed the region while
    75   // we were waiting to get the lock.
    76   HeapWord* result = attempt_allocation(word_size, bot_updates);
    77   if (result != NULL) {
    78     return result;
    79   }
    81   retire(true /* fill_up */);
    82   result = new_alloc_region_and_allocate(word_size, false /* force */);
    83   if (result != NULL) {
    84     trace("alloc locked (second attempt)", word_size, result);
    85     return result;
    86   }
    87   trace("alloc locked failed", word_size);
    88   return NULL;
    89 }
    91 inline HeapWord* G1AllocRegion::attempt_allocation_force(size_t word_size,
    92                                                          bool bot_updates) {
    93   assert(bot_updates == _bot_updates, ar_ext_msg(this, "pre-condition"));
    94   assert(_alloc_region != NULL, ar_ext_msg(this, "not initialized properly"));
    96   trace("forcing alloc");
    97   HeapWord* result = new_alloc_region_and_allocate(word_size, true /* force */);
    98   if (result != NULL) {
    99     trace("alloc forced", word_size, result);
   100     return result;
   101   }
   102   trace("alloc forced failed", word_size);
   103   return NULL;
   104 }
   106 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCREGION_INLINE_HPP

mercurial