hotspot/src/share/vm/gc/g1/heapRegion.inline.hpp
author tschatzl
Thu, 06 Aug 2015 15:49:50 +0200
changeset 32185 49a57ff2c3cb
parent 31592 43f48e165466
child 32389 626f27450e12
permissions -rw-r--r--
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp Summary: Fix naming of G1ParGCAllocator, decrease dependencies between G1CollectedHeap, G1Allocator and G1AllocRegion, additional documentation. Reviewed-by: mgerdin, jmasa, kbarrett
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
/*
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 25908
diff changeset
     2
 * Copyright (c) 2001, 2015, 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: 1374
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1374
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: 1374
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
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29470
diff changeset
    25
#ifndef SHARE_VM_GC_G1_HEAPREGION_INLINE_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29470
diff changeset
    26
#define SHARE_VM_GC_G1_HEAPREGION_INLINE_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29470
diff changeset
    28
#include "gc/g1/g1BlockOffsetTable.inline.hpp"
32185
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31592
diff changeset
    29
#include "gc/g1/g1CollectedHeap.inline.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29470
diff changeset
    30
#include "gc/g1/heapRegion.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29470
diff changeset
    31
#include "gc/shared/space.hpp"
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 25908
diff changeset
    32
#include "oops/oop.inline.hpp"
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    33
#include "runtime/atomic.inline.hpp"
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    34
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    35
// This version requires locking.
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    36
inline HeapWord* G1OffsetTableContigSpace::allocate_impl(size_t size,
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    37
                                                HeapWord* const end_value) {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    38
  HeapWord* obj = top();
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    39
  if (pointer_delta(end_value, obj) >= size) {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    40
    HeapWord* new_top = obj + size;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    41
    set_top(new_top);
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    42
    assert(is_aligned(obj) && is_aligned(new_top), "checking alignment");
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    43
    return obj;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    44
  } else {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    45
    return NULL;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    46
  }
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    47
}
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    48
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    49
// This version is lock-free.
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    50
inline HeapWord* G1OffsetTableContigSpace::par_allocate_impl(size_t size,
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    51
                                                    HeapWord* const end_value) {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    52
  do {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    53
    HeapWord* obj = top();
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    54
    if (pointer_delta(end_value, obj) >= size) {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    55
      HeapWord* new_top = obj + size;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    56
      HeapWord* result = (HeapWord*)Atomic::cmpxchg_ptr(new_top, top_addr(), obj);
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    57
      // result can be one of two:
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    58
      //  the old top value: the exchange succeeded
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    59
      //  otherwise: the new value of the top is returned.
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    60
      if (result == obj) {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    61
        assert(is_aligned(obj) && is_aligned(new_top), "checking alignment");
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    62
        return obj;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    63
      }
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    64
    } else {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    65
      return NULL;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    66
    }
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    67
  } while (true);
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    68
}
25361
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 12508
diff changeset
    69
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    70
inline HeapWord* G1OffsetTableContigSpace::allocate(size_t size) {
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    71
  HeapWord* res = allocate_impl(size, end());
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    72
  if (res != NULL) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    73
    _offsets.alloc_block(res, size);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    74
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    75
  return res;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    76
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    77
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    78
// Because of the requirement of keeping "_offsets" up to date with the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    79
// allocations, we sequentialize these with a lock.  Therefore, best if
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    80
// this is used for larger LAB allocations only.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    81
inline HeapWord* G1OffsetTableContigSpace::par_allocate(size_t size) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    82
  MutexLocker x(&_par_alloc_lock);
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    83
  return allocate(size);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    84
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    85
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    86
inline HeapWord* G1OffsetTableContigSpace::block_start(const void* p) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    87
  return _offsets.block_start(p);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    88
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    89
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    90
inline HeapWord*
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    91
G1OffsetTableContigSpace::block_start_const(const void* p) const {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    92
  return _offsets.block_start_const(p);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    93
}
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    94
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    95
inline bool
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    96
HeapRegion::block_is_obj(const HeapWord* p) const {
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
    97
  G1CollectedHeap* g1h = G1CollectedHeap::heap();
25908
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
    98
  if (ClassUnloadingWithConcurrentMark) {
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
    99
    return !g1h->is_obj_dead(oop(p), this);
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   100
  }
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   101
  return p < top();
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   102
}
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   103
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   104
inline size_t
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   105
HeapRegion::block_size(const HeapWord *addr) const {
25908
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   106
  if (addr == top()) {
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   107
    return pointer_delta(end(), addr);
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   108
  }
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   109
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   110
  if (block_is_obj(addr)) {
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   111
    return oop(addr)->size();
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   112
  }
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   113
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   114
  assert(ClassUnloadingWithConcurrentMark,
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   115
      err_msg("All blocks should be objects if G1 Class Unloading isn't used. "
31592
43f48e165466 8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents: 30764
diff changeset
   116
              "HR: [" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT ") "
25908
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   117
              "addr: " PTR_FORMAT,
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   118
              p2i(bottom()), p2i(top()), p2i(end()), p2i(addr)));
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   119
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   120
  // Old regions' dead objects may have dead classes
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   121
  // We need to find the next live object in some other
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   122
  // manner than getting the oop size
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   123
  G1CollectedHeap* g1h = G1CollectedHeap::heap();
25908
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   124
  HeapWord* next = g1h->concurrent_mark()->prevMarkBitMap()->
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   125
      getNextMarkedWordAddress(addr, prev_top_at_mark_start());
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   126
25908
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   127
  assert(next > addr, "must get the next live object");
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   128
  return pointer_delta(next, addr);
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   129
}
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   130
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   131
inline HeapWord* HeapRegion::par_allocate_no_bot_updates(size_t word_size) {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   132
  assert(is_young(), "we can only skip BOT updates on young regions");
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   133
  return par_allocate_impl(word_size, end());
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   134
}
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   135
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   136
inline HeapWord* HeapRegion::allocate_no_bot_updates(size_t word_size) {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   137
  assert(is_young(), "we can only skip BOT updates on young regions");
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   138
  return allocate_impl(word_size, end());
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   139
}
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   140
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   141
inline void HeapRegion::note_start_of_marking() {
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   142
  _next_marked_bytes = 0;
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   143
  _next_top_at_mark_start = top();
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   144
}
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   145
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   146
inline void HeapRegion::note_end_of_marking() {
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   147
  _prev_top_at_mark_start = _next_top_at_mark_start;
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   148
  _prev_marked_bytes = _next_marked_bytes;
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   149
  _next_marked_bytes = 0;
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   150
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   151
  assert(_prev_marked_bytes <=
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   152
         (size_t) pointer_delta(prev_top_at_mark_start(), bottom()) *
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   153
         HeapWordSize, "invariant");
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   154
}
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   155
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   156
inline void HeapRegion::note_start_of_copying(bool during_initial_mark) {
11584
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   157
  if (is_survivor()) {
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   158
    // This is how we always allocate survivors.
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   159
    assert(_next_top_at_mark_start == bottom(), "invariant");
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   160
  } else {
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   161
    if (during_initial_mark) {
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   162
      // During initial-mark we'll explicitly mark any objects on old
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   163
      // regions that are pointed to by roots. Given that explicit
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   164
      // marks only make sense under NTAMS it'd be nice if we could
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   165
      // check that condition if we wanted to. Given that we don't
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   166
      // know where the top of this region will end up, we simply set
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   167
      // NTAMS to the end of the region so all marks will be below
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   168
      // NTAMS. We'll set it to the actual top when we retire this region.
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   169
      _next_top_at_mark_start = end();
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   170
    } else {
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   171
      // We could have re-used this old region as to-space over a
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   172
      // couple of GCs since the start of the concurrent marking
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   173
      // cycle. This means that [bottom,NTAMS) will contain objects
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   174
      // copied up to and including initial-mark and [NTAMS, top)
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   175
      // will contain objects copied during the concurrent marking cycle.
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   176
      assert(top() >= _next_top_at_mark_start, "invariant");
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   177
    }
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   178
  }
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   179
}
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   180
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   181
inline void HeapRegion::note_end_of_copying(bool during_initial_mark) {
11584
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   182
  if (is_survivor()) {
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   183
    // This is how we always allocate survivors.
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   184
    assert(_next_top_at_mark_start == bottom(), "invariant");
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   185
  } else {
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   186
    if (during_initial_mark) {
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   187
      // See the comment for note_start_of_copying() for the details
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   188
      // on this.
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   189
      assert(_next_top_at_mark_start == end(), "pre-condition");
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   190
      _next_top_at_mark_start = top();
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   191
    } else {
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   192
      // See the comment for note_start_of_copying() for the details
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   193
      // on this.
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   194
      assert(top() >= _next_top_at_mark_start, "invariant");
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   195
    }
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   196
  }
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   197
}
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   198
29470
e34bbcd36e53 8030646: track collection set membership in one place
ehelin
parents: 29081
diff changeset
   199
inline bool HeapRegion::in_collection_set() const {
e34bbcd36e53 8030646: track collection set membership in one place
ehelin
parents: 29081
diff changeset
   200
  return G1CollectedHeap::heap()->is_in_cset(this);
e34bbcd36e53 8030646: track collection set membership in one place
ehelin
parents: 29081
diff changeset
   201
}
e34bbcd36e53 8030646: track collection set membership in one place
ehelin
parents: 29081
diff changeset
   202
32185
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31592
diff changeset
   203
inline HeapRegion* HeapRegion::next_in_collection_set() const {
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31592
diff changeset
   204
  assert(in_collection_set(), "should only invoke on member of CS.");
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31592
diff changeset
   205
  assert(_next_in_special_set == NULL ||
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31592
diff changeset
   206
         _next_in_special_set->in_collection_set(),
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31592
diff changeset
   207
         "Malformed CS.");
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31592
diff changeset
   208
  return _next_in_special_set;
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31592
diff changeset
   209
}
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31592
diff changeset
   210
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31592
diff changeset
   211
void HeapRegion::set_next_in_collection_set(HeapRegion* r) {
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31592
diff changeset
   212
  assert(in_collection_set(), "should only invoke on member of CS.");
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31592
diff changeset
   213
  assert(r == NULL || r->in_collection_set(), "Malformed CS.");
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31592
diff changeset
   214
  _next_in_special_set = r;
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31592
diff changeset
   215
}
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31592
diff changeset
   216
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29470
diff changeset
   217
#endif // SHARE_VM_GC_G1_HEAPREGION_INLINE_HPP