hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.inline.hpp
author tonyp
Tue, 07 Dec 2010 16:47:42 -0500
changeset 7416 cfe3bfab7d48
parent 7398 e4aa6d9bda09
child 7905 cc7740616b03
permissions -rw-r--r--
6994056: G1: when GC locker is active, extend the Eden instead of allocating into the old gen Summary: Allow the eden to the expanded up to a point when the GC locker is active. Reviewed-by: jwilhelm, johnc, ysr, jcoomes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6260
diff changeset
     2
 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     4
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     8
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    13
 * accompanied this code).
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    14
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2742
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2742
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2742
diff changeset
    21
 * questions.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    22
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    23
 */
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6260
diff changeset
    25
#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6260
diff changeset
    26
#define SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6260
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6260
diff changeset
    28
#include "gc_implementation/g1/concurrentMark.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6260
diff changeset
    29
#include "gc_implementation/g1/g1CollectedHeap.hpp"
7398
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    30
#include "gc_implementation/g1/g1CollectorPolicy.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6260
diff changeset
    31
#include "gc_implementation/g1/heapRegionSeq.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6260
diff changeset
    32
#include "utilities/taskqueue.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6260
diff changeset
    33
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    34
// Inline functions for G1CollectedHeap
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    35
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    36
inline HeapRegion*
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    37
G1CollectedHeap::heap_region_containing(const void* addr) const {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    38
  HeapRegion* hr = _hrs->addr_to_region(addr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    39
  // hr can be null if addr in perm_gen
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    40
  if (hr != NULL && hr->continuesHumongous()) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    41
    hr = hr->humongous_start_region();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    42
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    43
  return hr;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    44
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    45
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    46
inline HeapRegion*
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    47
G1CollectedHeap::heap_region_containing_raw(const void* addr) const {
1902
bf5f0a3beffe 6484956: G1: improve evacuation pause efficiency
tonyp
parents: 1374
diff changeset
    48
  assert(_g1_reserved.contains(addr), "invariant");
2742
5e88fa844ba0 6833576: G1: assert illegal index, growableArray.hpp:186
johnc
parents: 2105
diff changeset
    49
  size_t index = pointer_delta(addr, _g1_reserved.start(), 1)
5e88fa844ba0 6833576: G1: assert illegal index, growableArray.hpp:186
johnc
parents: 2105
diff changeset
    50
                                        >> HeapRegion::LogOfHRGrainBytes;
5e88fa844ba0 6833576: G1: assert illegal index, growableArray.hpp:186
johnc
parents: 2105
diff changeset
    51
1902
bf5f0a3beffe 6484956: G1: improve evacuation pause efficiency
tonyp
parents: 1374
diff changeset
    52
  HeapRegion* res = _hrs->at(index);
bf5f0a3beffe 6484956: G1: improve evacuation pause efficiency
tonyp
parents: 1374
diff changeset
    53
  assert(res == _hrs->addr_to_region(addr), "sanity");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    54
  return res;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    55
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    56
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    57
inline bool G1CollectedHeap::obj_in_cs(oop obj) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    58
  HeapRegion* r = _hrs->addr_to_region(obj);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    59
  return r != NULL && r->in_collection_set();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    60
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    61
7398
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    62
// See the comment in the .hpp file about the locking protocol and
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    63
// assumptions of this method (and other related ones).
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    64
inline HeapWord*
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    65
G1CollectedHeap::allocate_from_cur_alloc_region(HeapRegion* cur_alloc_region,
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    66
                                                size_t word_size) {
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    67
  assert_heap_locked_and_not_at_safepoint();
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    68
  assert(cur_alloc_region != NULL, "pre-condition of the method");
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    69
  assert(cur_alloc_region == _cur_alloc_region, "pre-condition of the method");
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    70
  assert(cur_alloc_region->is_young(),
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    71
         "we only support young current alloc regions");
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    72
  assert(!isHumongous(word_size), "allocate_from_cur_alloc_region() "
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    73
         "should not be used for humongous allocations");
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    74
  assert(!cur_alloc_region->isHumongous(), "Catch a regression of this bug.");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    75
7398
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    76
  assert(!cur_alloc_region->is_empty(),
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    77
         err_msg("region ["PTR_FORMAT","PTR_FORMAT"] should not be empty",
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    78
                 cur_alloc_region->bottom(), cur_alloc_region->end()));
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    79
  // This allocate method does BOT updates and we don't need them in
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    80
  // the young generation. This will be fixed in the near future by
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    81
  // CR 6994297.
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    82
  HeapWord* result = cur_alloc_region->allocate(word_size);
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    83
  if (result != NULL) {
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    84
    assert(is_in(result), "result should be in the heap");
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    85
    Heap_lock->unlock();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    86
7398
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    87
    // Do the dirtying after we release the Heap_lock.
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    88
    dirty_young_block(result, word_size);
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    89
    return result;
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    90
  }
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    91
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    92
  assert_heap_locked();
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    93
  return NULL;
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    94
}
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    95
7398
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    96
// See the comment in the .hpp file about the locking protocol and
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    97
// assumptions of this method (and other related ones).
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    98
inline HeapWord*
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
    99
G1CollectedHeap::attempt_allocation(size_t word_size) {
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   100
  assert_heap_locked_and_not_at_safepoint();
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   101
  assert(!isHumongous(word_size), "attempt_allocation() should not be called "
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   102
         "for humongous allocation requests");
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   103
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   104
  HeapRegion* cur_alloc_region = _cur_alloc_region;
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   105
  if (cur_alloc_region != NULL) {
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   106
    HeapWord* result = allocate_from_cur_alloc_region(cur_alloc_region,
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   107
                                                      word_size);
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   108
    if (result != NULL) {
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   109
      assert_heap_not_locked();
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   110
      return result;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   111
    }
6260
fba83fd3adc7 6974928: G1: sometimes humongous objects are allocated in young regions
tonyp
parents: 6251
diff changeset
   112
7398
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   113
    assert_heap_locked();
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   114
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   115
    // Since we couldn't successfully allocate into it, retire the
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   116
    // current alloc region.
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   117
    retire_cur_alloc_region(cur_alloc_region);
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   118
  }
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   119
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   120
  // Try to get a new region and allocate out of it
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   121
  HeapWord* result = replace_cur_alloc_region_and_allocate(word_size,
7416
cfe3bfab7d48 6994056: G1: when GC locker is active, extend the Eden instead of allocating into the old gen
tonyp
parents: 7398
diff changeset
   122
                                                     false, /* at_safepoint */
cfe3bfab7d48 6994056: G1: when GC locker is active, extend the Eden instead of allocating into the old gen
tonyp
parents: 7398
diff changeset
   123
                                                     true,  /* do_dirtying */
cfe3bfab7d48 6994056: G1: when GC locker is active, extend the Eden instead of allocating into the old gen
tonyp
parents: 7398
diff changeset
   124
                                                     false  /* can_expand */);
7398
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   125
  if (result != NULL) {
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   126
    assert_heap_not_locked();
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   127
    return result;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   128
  }
7398
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   129
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   130
  assert_heap_locked();
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   131
  return NULL;
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   132
}
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   133
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   134
inline void
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   135
G1CollectedHeap::retire_cur_alloc_region_common(HeapRegion* cur_alloc_region) {
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   136
  assert_heap_locked_or_at_safepoint();
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   137
  assert(cur_alloc_region != NULL && cur_alloc_region == _cur_alloc_region,
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   138
         "pre-condition of the call");
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   139
  assert(cur_alloc_region->is_young(),
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   140
         "we only support young current alloc regions");
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   141
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   142
  // The region is guaranteed to be young
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   143
  g1_policy()->add_region_to_incremental_cset_lhs(cur_alloc_region);
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   144
  _summary_bytes_used += cur_alloc_region->used();
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   145
  _cur_alloc_region = NULL;
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   146
}
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   147
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   148
// It dirties the cards that cover the block so that so that the post
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   149
// write barrier never queues anything when updating objects on this
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   150
// block. It is assumed (and in fact we assert) that the block
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   151
// belongs to a young region.
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   152
inline void
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   153
G1CollectedHeap::dirty_young_block(HeapWord* start, size_t word_size) {
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   154
  assert_heap_not_locked();
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   155
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   156
  // Assign the containing region to containing_hr so that we don't
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   157
  // have to keep calling heap_region_containing_raw() in the
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   158
  // asserts below.
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   159
  DEBUG_ONLY(HeapRegion* containing_hr = heap_region_containing_raw(start);)
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   160
  assert(containing_hr != NULL && start != NULL && word_size > 0,
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   161
         "pre-condition");
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   162
  assert(containing_hr->is_in(start), "it should contain start");
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   163
  assert(containing_hr->is_young(), "it should be young");
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   164
  assert(!containing_hr->isHumongous(), "it should not be humongous");
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   165
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   166
  HeapWord* end = start + word_size;
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   167
  assert(containing_hr->is_in(end - 1), "it should also contain end - 1");
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   168
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   169
  MemRegion mr(start, end);
e4aa6d9bda09 6974966: G1: unnecessary direct-to-old allocations
tonyp
parents: 7397
diff changeset
   170
  ((CardTableModRefBS*)_g1h->barrier_set())->dirty(mr);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   171
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   172
6251
90e562b9f1cc 6966222: G1: simplify TaskQueue overflow handling
jcoomes
parents: 5547
diff changeset
   173
inline RefToScanQueue* G1CollectedHeap::task_queue(int i) const {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   174
  return _task_queues->queue(i);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   175
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   176
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   177
inline  bool G1CollectedHeap::isMarkedPrev(oop obj) const {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   178
  return _cm->prevMarkBitMap()->isMarked((HeapWord *)obj);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   179
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   180
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   181
inline bool G1CollectedHeap::isMarkedNext(oop obj) const {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   182
  return _cm->nextMarkBitMap()->isMarked((HeapWord *)obj);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   183
}
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6260
diff changeset
   184
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6260
diff changeset
   185
#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP