hotspot/src/share/vm/gc_implementation/g1/heapRegion.inline.hpp
author stefank
Wed, 06 Aug 2014 09:55:16 +0200
changeset 25908 8adb2fb6fc3c
parent 25492 d27050bdfb04
child 29081 c61eb4914428
permissions -rw-r--r--
8048269: Add flag to turn off class unloading after G1 concurrent mark Summary: Added -XX:+/-ClassUnloadingWithConcurrentMark Reviewed-by: jmasa, brutisso, mgerdin
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
/*
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
     2
 * Copyright (c) 2001, 2012, 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
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGION_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGION_INLINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
25361
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 12508
diff changeset
    28
#include "gc_implementation/g1/g1BlockOffsetTable.inline.hpp"
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    29
#include "gc_implementation/g1/g1CollectedHeap.hpp"
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    30
#include "gc_implementation/g1/heapRegion.hpp"
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    31
#include "memory/space.hpp"
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    32
#include "runtime/atomic.inline.hpp"
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    33
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    34
// This version requires locking.
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    35
inline HeapWord* G1OffsetTableContigSpace::allocate_impl(size_t size,
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    36
                                                HeapWord* const end_value) {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    37
  HeapWord* obj = top();
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    38
  if (pointer_delta(end_value, obj) >= size) {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    39
    HeapWord* new_top = obj + size;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    40
    set_top(new_top);
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    41
    assert(is_aligned(obj) && is_aligned(new_top), "checking alignment");
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    42
    return obj;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    43
  } else {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    44
    return NULL;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    45
  }
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
// This version is lock-free.
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    49
inline HeapWord* G1OffsetTableContigSpace::par_allocate_impl(size_t size,
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    50
                                                    HeapWord* const end_value) {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    51
  do {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    52
    HeapWord* obj = top();
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    53
    if (pointer_delta(end_value, obj) >= size) {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    54
      HeapWord* new_top = obj + size;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    55
      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
    56
      // result can be one of two:
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    57
      //  the old top value: the exchange succeeded
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    58
      //  otherwise: the new value of the top is returned.
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    59
      if (result == obj) {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    60
        assert(is_aligned(obj) && is_aligned(new_top), "checking alignment");
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    61
        return obj;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    62
      }
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    63
    } else {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    64
      return NULL;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    65
    }
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    66
  } while (true);
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    67
}
25361
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 12508
diff changeset
    68
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    69
inline HeapWord* G1OffsetTableContigSpace::allocate(size_t size) {
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    70
  HeapWord* res = allocate_impl(size, end());
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    71
  if (res != NULL) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    72
    _offsets.alloc_block(res, size);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    73
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    74
  return res;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    75
}
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
// 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
    78
// allocations, we sequentialize these with a lock.  Therefore, best if
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    79
// this is used for larger LAB allocations only.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    80
inline HeapWord* G1OffsetTableContigSpace::par_allocate(size_t size) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    81
  MutexLocker x(&_par_alloc_lock);
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    82
  return allocate(size);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    83
}
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
inline HeapWord* G1OffsetTableContigSpace::block_start(const void* p) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    86
  return _offsets.block_start(p);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    87
}
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
inline HeapWord*
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    90
G1OffsetTableContigSpace::block_start_const(const void* p) const {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    91
  return _offsets.block_start_const(p);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    92
}
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    93
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    94
inline bool
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    95
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
    96
  G1CollectedHeap* g1h = G1CollectedHeap::heap();
25908
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
    97
  if (ClassUnloadingWithConcurrentMark) {
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
    98
    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
    99
  }
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   100
  return p < top();
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   101
}
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
inline size_t
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   104
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
   105
  if (addr == top()) {
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   106
    return pointer_delta(end(), addr);
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   107
  }
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
  if (block_is_obj(addr)) {
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   110
    return oop(addr)->size();
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   111
  }
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
  assert(ClassUnloadingWithConcurrentMark,
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   114
      err_msg("All blocks should be objects if G1 Class Unloading isn't used. "
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   115
              "HR: ["PTR_FORMAT", "PTR_FORMAT", "PTR_FORMAT") "
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   116
              "addr: " PTR_FORMAT,
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   117
              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
   118
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   119
  // Old regions' dead objects may have dead classes
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   120
  // 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
   121
  // manner than getting the oop size
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   122
  G1CollectedHeap* g1h = G1CollectedHeap::heap();
25908
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   123
  HeapWord* next = g1h->concurrent_mark()->prevMarkBitMap()->
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   124
      getNextMarkedWordAddress(addr, prev_top_at_mark_start());
25492
d27050bdfb04 8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents: 25491
diff changeset
   125
25908
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   126
  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
   127
  return pointer_delta(next, addr);
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   128
}
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
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
   131
  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
   132
  return par_allocate_impl(word_size, end());
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   133
}
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
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
   136
  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
   137
  return allocate_impl(word_size, end());
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   138
}
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   139
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   140
inline void HeapRegion::note_start_of_marking() {
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   141
  _next_marked_bytes = 0;
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   142
  _next_top_at_mark_start = top();
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   143
}
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
inline void HeapRegion::note_end_of_marking() {
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   146
  _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
   147
  _prev_marked_bytes = _next_marked_bytes;
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   148
  _next_marked_bytes = 0;
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   149
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   150
  assert(_prev_marked_bytes <=
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   151
         (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
   152
         HeapWordSize, "invariant");
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   153
}
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
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
   156
  if (is_survivor()) {
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   157
    // This is how we always allocate survivors.
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   158
    assert(_next_top_at_mark_start == bottom(), "invariant");
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   159
  } else {
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   160
    if (during_initial_mark) {
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   161
      // 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
   162
      // 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
   163
      // 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
   164
      // 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
   165
      // 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
   166
      // 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
   167
      // 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
   168
      _next_top_at_mark_start = end();
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   169
    } else {
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   170
      // 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
   171
      // 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
   172
      // 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
   173
      // 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
   174
      // 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
   175
      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
   176
    }
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
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
   181
  if (is_survivor()) {
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   182
    // This is how we always allocate survivors.
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   183
    assert(_next_top_at_mark_start == bottom(), "invariant");
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   184
  } else {
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   185
    if (during_initial_mark) {
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   186
      // 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
   187
      // on this.
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   188
      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
   189
      _next_top_at_mark_start = top();
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   190
    } else {
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   191
      // 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
   192
      // on this.
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   193
      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
   194
    }
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
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   198
#endif // SHARE_VM_GC_IMPLEMENTATION_G1_HEAPREGION_INLINE_HPP