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

changeset 2715
abdfc822206f
parent 0
f90c822e73f8
child 6990
1526a938e670
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/gc_implementation/g1/g1AllocRegion.inline.hpp	Wed Mar 30 10:26:59 2011 -0400
     1.3 @@ -0,0 +1,106 @@
     1.4 +/*
     1.5 + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCREGION_INLINE_HPP
    1.29 +#define SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCREGION_INLINE_HPP
    1.30 +
    1.31 +#include "gc_implementation/g1/g1AllocRegion.hpp"
    1.32 +
    1.33 +inline HeapWord* G1AllocRegion::allocate(HeapRegion* alloc_region,
    1.34 +                                         size_t word_size,
    1.35 +                                         bool bot_updates) {
    1.36 +  assert(alloc_region != NULL, err_msg("pre-condition"));
    1.37 +
    1.38 +  if (!bot_updates) {
    1.39 +    return alloc_region->allocate_no_bot_updates(word_size);
    1.40 +  } else {
    1.41 +    return alloc_region->allocate(word_size);
    1.42 +  }
    1.43 +}
    1.44 +
    1.45 +inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region,
    1.46 +                                             size_t word_size,
    1.47 +                                             bool bot_updates) {
    1.48 +  assert(alloc_region != NULL, err_msg("pre-condition"));
    1.49 +  assert(!alloc_region->is_empty(), err_msg("pre-condition"));
    1.50 +
    1.51 +  if (!bot_updates) {
    1.52 +    return alloc_region->par_allocate_no_bot_updates(word_size);
    1.53 +  } else {
    1.54 +    return alloc_region->par_allocate(word_size);
    1.55 +  }
    1.56 +}
    1.57 +
    1.58 +inline HeapWord* G1AllocRegion::attempt_allocation(size_t word_size,
    1.59 +                                                   bool bot_updates) {
    1.60 +  assert(bot_updates == _bot_updates, ar_ext_msg(this, "pre-condition"));
    1.61 +
    1.62 +  HeapRegion* alloc_region = _alloc_region;
    1.63 +  assert(alloc_region != NULL, ar_ext_msg(this, "not initialized properly"));
    1.64 +
    1.65 +  HeapWord* result = par_allocate(alloc_region, word_size, bot_updates);
    1.66 +  if (result != NULL) {
    1.67 +    trace("alloc", word_size, result);
    1.68 +    return result;
    1.69 +  }
    1.70 +  trace("alloc failed", word_size);
    1.71 +  return NULL;
    1.72 +}
    1.73 +
    1.74 +inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t word_size,
    1.75 +                                                          bool bot_updates) {
    1.76 +  // First we have to tedo the allocation, assuming we're holding the
    1.77 +  // appropriate lock, in case another thread changed the region while
    1.78 +  // we were waiting to get the lock.
    1.79 +  HeapWord* result = attempt_allocation(word_size, bot_updates);
    1.80 +  if (result != NULL) {
    1.81 +    return result;
    1.82 +  }
    1.83 +
    1.84 +  retire(true /* fill_up */);
    1.85 +  result = new_alloc_region_and_allocate(word_size, false /* force */);
    1.86 +  if (result != NULL) {
    1.87 +    trace("alloc locked (second attempt)", word_size, result);
    1.88 +    return result;
    1.89 +  }
    1.90 +  trace("alloc locked failed", word_size);
    1.91 +  return NULL;
    1.92 +}
    1.93 +
    1.94 +inline HeapWord* G1AllocRegion::attempt_allocation_force(size_t word_size,
    1.95 +                                                         bool bot_updates) {
    1.96 +  assert(bot_updates == _bot_updates, ar_ext_msg(this, "pre-condition"));
    1.97 +  assert(_alloc_region != NULL, ar_ext_msg(this, "not initialized properly"));
    1.98 +
    1.99 +  trace("forcing alloc");
   1.100 +  HeapWord* result = new_alloc_region_and_allocate(word_size, true /* force */);
   1.101 +  if (result != NULL) {
   1.102 +    trace("alloc forced", word_size, result);
   1.103 +    return result;
   1.104 +  }
   1.105 +  trace("alloc forced failed", word_size);
   1.106 +  return NULL;
   1.107 +}
   1.108 +
   1.109 +#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCREGION_INLINE_HPP

mercurial