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

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

mercurial