hotspot/src/share/vm/gc_implementation/g1/g1AllocRegion.inline.hpp
author mlarsson
Tue, 07 Oct 2014 14:54:53 +0200
changeset 27009 e7e723732b6b
parent 25481 1427aa24638c
permissions -rw-r--r--
8058298: Separate heap region iterator claim values from the data structures iterated over Reviewed-by: tschatzl, brutisso
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8928
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
     1
/*
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
     2
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
     4
 *
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
     8
 *
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    13
 * accompanied this code).
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    14
 *
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    18
 *
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    21
 * questions.
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    22
 *
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    23
 */
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    24
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    25
#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCREGION_INLINE_HPP
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    26
#define SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCREGION_INLINE_HPP
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    27
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    28
#include "gc_implementation/g1/g1AllocRegion.hpp"
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 22551
diff changeset
    29
#include "gc_implementation/g1/heapRegion.inline.hpp"
8928
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    30
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    31
inline HeapWord* G1AllocRegion::allocate(HeapRegion* alloc_region,
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    32
                                         size_t word_size,
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    33
                                         bool bot_updates) {
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    34
  assert(alloc_region != NULL, err_msg("pre-condition"));
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    35
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    36
  if (!bot_updates) {
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    37
    return alloc_region->allocate_no_bot_updates(word_size);
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    38
  } else {
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    39
    return alloc_region->allocate(word_size);
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    40
  }
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    41
}
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    42
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    43
inline HeapWord* G1AllocRegion::par_allocate(HeapRegion* alloc_region,
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    44
                                             size_t word_size,
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    45
                                             bool bot_updates) {
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    46
  assert(alloc_region != NULL, err_msg("pre-condition"));
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    47
  assert(!alloc_region->is_empty(), err_msg("pre-condition"));
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    48
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    49
  if (!bot_updates) {
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    50
    return alloc_region->par_allocate_no_bot_updates(word_size);
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    51
  } else {
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    52
    return alloc_region->par_allocate(word_size);
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    53
  }
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    54
}
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    55
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    56
inline HeapWord* G1AllocRegion::attempt_allocation(size_t word_size,
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    57
                                                   bool bot_updates) {
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    58
  assert(bot_updates == _bot_updates, ar_ext_msg(this, "pre-condition"));
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    59
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    60
  HeapRegion* alloc_region = _alloc_region;
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    61
  assert(alloc_region != NULL, ar_ext_msg(this, "not initialized properly"));
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    62
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    63
  HeapWord* result = par_allocate(alloc_region, word_size, bot_updates);
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    64
  if (result != NULL) {
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    65
    trace("alloc", word_size, result);
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    66
    return result;
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    67
  }
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    68
  trace("alloc failed", word_size);
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    69
  return NULL;
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    70
}
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    71
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    72
inline HeapWord* G1AllocRegion::attempt_allocation_locked(size_t word_size,
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    73
                                                          bool bot_updates) {
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 8928
diff changeset
    74
  // First we have to redo the allocation, assuming we're holding the
8928
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    75
  // appropriate lock, in case another thread changed the region while
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    76
  // we were waiting to get the lock.
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    77
  HeapWord* result = attempt_allocation(word_size, bot_updates);
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    78
  if (result != NULL) {
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    79
    return result;
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    80
  }
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    81
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    82
  retire(true /* fill_up */);
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    83
  result = new_alloc_region_and_allocate(word_size, false /* force */);
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    84
  if (result != NULL) {
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    85
    trace("alloc locked (second attempt)", word_size, result);
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    86
    return result;
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    87
  }
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    88
  trace("alloc locked failed", word_size);
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    89
  return NULL;
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    90
}
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    91
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    92
inline HeapWord* G1AllocRegion::attempt_allocation_force(size_t word_size,
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    93
                                                         bool bot_updates) {
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    94
  assert(bot_updates == _bot_updates, ar_ext_msg(this, "pre-condition"));
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    95
  assert(_alloc_region != NULL, ar_ext_msg(this, "not initialized properly"));
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    96
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    97
  trace("forcing alloc");
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    98
  HeapWord* result = new_alloc_region_and_allocate(word_size, true /* force */);
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
    99
  if (result != NULL) {
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
   100
    trace("alloc forced", word_size, result);
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
   101
    return result;
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
   102
  }
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
   103
  trace("alloc forced failed", word_size);
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
   104
  return NULL;
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
   105
}
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
   106
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents:
diff changeset
   107
#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1ALLOCREGION_INLINE_HPP