src/hotspot/share/gc/g1/heapRegion.inline.hpp
author tschatzl
Fri, 22 Nov 2019 10:03:38 +0100
changeset 59218 a1155217a563
parent 58980 47c20fc6a517
child 59252 623722a6aeb9
permissions -rw-r--r--
8233306: Sort members in G1's HeapRegion after removal of Space dependency Reviewed-by: sangheki, sjohanss
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
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52875
diff changeset
     2
 * Copyright (c) 2001, 2019, 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
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52875
diff changeset
    25
#ifndef SHARE_GC_G1_HEAPREGION_INLINE_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52875
diff changeset
    26
#define SHARE_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"
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
    30
#include "gc/g1/g1ConcurrentMarkBitMap.inline.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29470
diff changeset
    31
#include "gc/g1/heapRegion.hpp"
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 25908
diff changeset
    32
#include "oops/oop.inline.hpp"
40655
9f644073d3a0 8157907: Incorrect inclusion of atomic.hpp instead of atomic.inline.hpp
dholmes
parents: 39698
diff changeset
    33
#include "runtime/atomic.hpp"
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
    34
#include "runtime/prefetch.inline.hpp"
46625
edefffab74e2 8183552: Move align functions to align.hpp
stefank
parents: 46517
diff changeset
    35
#include "utilities/align.hpp"
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
    36
#include "utilities/globalDefinitions.hpp"
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    37
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
    38
inline HeapWord* HeapRegion::allocate_impl(size_t min_word_size,
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
    39
                                           size_t desired_word_size,
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
    40
                                           size_t* actual_size) {
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    41
  HeapWord* obj = top();
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    42
  size_t available = pointer_delta(end(), obj);
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    43
  size_t want_to_allocate = MIN2(available, desired_word_size);
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    44
  if (want_to_allocate >= min_word_size) {
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    45
    HeapWord* new_top = obj + want_to_allocate;
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    46
    set_top(new_top);
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
    47
    assert(is_object_aligned(obj) && is_object_aligned(new_top), "checking alignment");
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    48
    *actual_size = want_to_allocate;
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    49
    return obj;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    50
  } else {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    51
    return NULL;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    52
  }
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    53
}
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    54
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
    55
inline HeapWord* HeapRegion::par_allocate_impl(size_t min_word_size,
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
    56
                                               size_t desired_word_size,
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
    57
                                               size_t* actual_size) {
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    58
  do {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    59
    HeapWord* obj = top();
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    60
    size_t available = pointer_delta(end(), obj);
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    61
    size_t want_to_allocate = MIN2(available, desired_word_size);
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    62
    if (want_to_allocate >= min_word_size) {
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    63
      HeapWord* new_top = obj + want_to_allocate;
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
    64
      HeapWord* result = Atomic::cmpxchg(new_top, &_top, obj);
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    65
      // result can be one of two:
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    66
      //  the old top value: the exchange succeeded
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    67
      //  otherwise: the new value of the top is returned.
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    68
      if (result == obj) {
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
    69
        assert(is_object_aligned(obj) && is_object_aligned(new_top), "checking alignment");
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    70
        *actual_size = want_to_allocate;
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    71
        return obj;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    72
      }
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    73
    } else {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    74
      return NULL;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    75
    }
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    76
  } while (true);
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    77
}
25361
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 12508
diff changeset
    78
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
    79
inline HeapWord* HeapRegion::allocate(size_t min_word_size,
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
    80
                                      size_t desired_word_size,
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
    81
                                      size_t* actual_size) {
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    82
  HeapWord* res = allocate_impl(min_word_size, desired_word_size, actual_size);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    83
  if (res != NULL) {
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    84
    _bot_part.alloc_block(res, *actual_size);
1374
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
  return res;
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
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
    89
inline HeapWord* HeapRegion::allocate(size_t word_size) {
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    90
  size_t temp;
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    91
  return allocate(word_size, word_size, &temp);
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    92
}
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    93
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
    94
inline HeapWord* HeapRegion::par_allocate(size_t word_size) {
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    95
  size_t temp;
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    96
  return par_allocate(word_size, word_size, &temp);
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    97
}
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    98
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    99
// 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
   100
// allocations, we sequentialize these with a lock.  Therefore, best if
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   101
// this is used for larger LAB allocations only.
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
   102
inline HeapWord* HeapRegion::par_allocate(size_t min_word_size,
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
   103
                                          size_t desired_word_size,
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
   104
                                          size_t* actual_size) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   105
  MutexLocker x(&_par_alloc_lock);
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   106
  return allocate(min_word_size, desired_word_size, actual_size);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   107
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   108
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
   109
inline HeapWord* HeapRegion::block_start(const void* p) {
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
   110
  return _bot_part.block_start(p);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   111
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   112
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
   113
inline HeapWord* HeapRegion::block_start_const(const void* p) const {
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
   114
  return _bot_part.block_start_const(p);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   115
}
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   116
46750
bcab0128a16f 8184346: Clean up G1CMBitmap
tschatzl
parents: 46625
diff changeset
   117
inline bool HeapRegion::is_obj_dead_with_size(const oop obj, const G1CMBitMap* const prev_bitmap, size_t* size) const {
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   118
  HeapWord* addr = (HeapWord*) obj;
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   119
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   120
  assert(addr < top(), "must be");
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46750
diff changeset
   121
  assert(!is_closed_archive(),
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46750
diff changeset
   122
         "Closed archive regions should not have references into other regions");
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   123
  assert(!is_humongous(), "Humongous objects not handled here");
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   124
  bool obj_is_dead = is_obj_dead(obj, prev_bitmap);
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   125
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   126
  if (ClassUnloadingWithConcurrentMark && obj_is_dead) {
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   127
    assert(!block_is_obj(addr), "must be");
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   128
    *size = block_size_using_bitmap(addr, prev_bitmap);
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   129
  } else {
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   130
    assert(block_is_obj(addr), "must be");
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   131
    *size = obj->size();
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   132
  }
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   133
  return obj_is_dead;
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   134
}
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   135
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
   136
inline bool 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
   137
  G1CollectedHeap* g1h = G1CollectedHeap::heap();
33786
ac8da6513351 8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents: 33105
diff changeset
   138
ac8da6513351 8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents: 33105
diff changeset
   139
  if (!this->is_in(p)) {
ac8da6513351 8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents: 33105
diff changeset
   140
    assert(is_continues_humongous(), "This case can only happen for humongous regions");
ac8da6513351 8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents: 33105
diff changeset
   141
    return (p == humongous_start_region()->bottom());
ac8da6513351 8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents: 33105
diff changeset
   142
  }
25908
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   143
  if (ClassUnloadingWithConcurrentMark) {
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   144
    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
   145
  }
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   146
  return p < top();
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   147
}
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   148
46750
bcab0128a16f 8184346: Clean up G1CMBitmap
tschatzl
parents: 46625
diff changeset
   149
inline size_t HeapRegion::block_size_using_bitmap(const HeapWord* addr, const G1CMBitMap* const prev_bitmap) const {
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   150
  assert(ClassUnloadingWithConcurrentMark,
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   151
         "All blocks should be objects if class unloading isn't used, so this method should not be called. "
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   152
         "HR: [" PTR_FORMAT ", " PTR_FORMAT ", " PTR_FORMAT ") "
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   153
         "addr: " PTR_FORMAT,
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   154
         p2i(bottom()), p2i(top()), p2i(end()), p2i(addr));
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   155
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   156
  // Old regions' dead objects may have dead classes
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   157
  // We need to find the next live object using the bitmap
46750
bcab0128a16f 8184346: Clean up G1CMBitmap
tschatzl
parents: 46625
diff changeset
   158
  HeapWord* next = prev_bitmap->get_next_marked_addr(addr, prev_top_at_mark_start());
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   159
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   160
  assert(next > addr, "must get the next live object");
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   161
  return pointer_delta(next, addr);
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   162
}
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   163
46750
bcab0128a16f 8184346: Clean up G1CMBitmap
tschatzl
parents: 46625
diff changeset
   164
inline bool HeapRegion::is_obj_dead(const oop obj, const G1CMBitMap* const prev_bitmap) const {
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   165
  assert(is_in_reserved(obj), "Object " PTR_FORMAT " must be in region", p2i(obj));
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46750
diff changeset
   166
  return !obj_allocated_since_prev_marking(obj) &&
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46750
diff changeset
   167
         !prev_bitmap->is_marked((HeapWord*)obj) &&
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46750
diff changeset
   168
         !is_open_archive();
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   169
}
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   170
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   171
inline size_t 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
   172
  if (addr == top()) {
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   173
    return pointer_delta(end(), addr);
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   174
  }
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   175
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   176
  if (block_is_obj(addr)) {
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   177
    return oop(addr)->size();
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   178
  }
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   179
47678
c84eeb55c55e 8184667: Clean up G1ConcurrentMark files
tschatzl
parents: 47634
diff changeset
   180
  return block_size_using_bitmap(addr, G1CollectedHeap::heap()->concurrent_mark()->prev_mark_bitmap());
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   181
}
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   182
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   183
inline void HeapRegion::complete_compaction() {
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   184
  // Reset space and bot after compaction is complete if needed.
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   185
  reset_after_compaction();
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
   186
  if (is_empty()) {
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   187
    reset_bot();
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   188
  }
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   189
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   190
  // After a compaction the mark bitmap is invalid, so we must
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   191
  // treat all objects as being inside the unmarked area.
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   192
  zero_marked_bytes();
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   193
  init_top_at_mark_start();
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   194
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   195
  // Clear unused heap memory in debug builds.
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   196
  if (ZapUnusedHeapArea) {
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   197
    mangle_unused_area();
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   198
  }
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   199
}
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   200
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   201
template<typename ApplyToMarkedClosure>
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   202
inline void HeapRegion::apply_to_marked_objects(G1CMBitMap* bitmap, ApplyToMarkedClosure* closure) {
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 55607
diff changeset
   203
  HeapWord* limit = top();
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   204
  HeapWord* next_addr = bottom();
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   205
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   206
  while (next_addr < limit) {
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   207
    Prefetch::write(next_addr, PrefetchScanIntervalInBytes);
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   208
    // This explicit is_marked check is a way to avoid
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   209
    // some extra work done by get_next_marked_addr for
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   210
    // the case where next_addr is marked.
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   211
    if (bitmap->is_marked(next_addr)) {
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   212
      oop current = oop(next_addr);
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   213
      next_addr += closure->apply(current);
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   214
    } else {
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   215
      next_addr = bitmap->get_next_marked_addr(next_addr, limit);
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   216
    }
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   217
  }
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   218
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   219
  assert(next_addr == limit, "Should stop the scan at the limit.");
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   220
}
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47678
diff changeset
   221
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   222
inline HeapWord* HeapRegion::par_allocate_no_bot_updates(size_t min_word_size,
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   223
                                                         size_t desired_word_size,
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   224
                                                         size_t* actual_word_size) {
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   225
  assert(is_young(), "we can only skip BOT updates on young regions");
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   226
  return par_allocate_impl(min_word_size, desired_word_size, actual_word_size);
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   227
}
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   228
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   229
inline HeapWord* HeapRegion::allocate_no_bot_updates(size_t word_size) {
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   230
  size_t temp;
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   231
  return allocate_no_bot_updates(word_size, word_size, &temp);
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   232
}
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   233
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   234
inline HeapWord* HeapRegion::allocate_no_bot_updates(size_t min_word_size,
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   235
                                                     size_t desired_word_size,
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   236
                                                     size_t* actual_word_size) {
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   237
  assert(is_young(), "we can only skip BOT updates on young regions");
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   238
  return allocate_impl(min_word_size, desired_word_size, actual_word_size);
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   239
}
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   240
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   241
inline void HeapRegion::note_start_of_marking() {
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   242
  _next_marked_bytes = 0;
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   243
  _next_top_at_mark_start = top();
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   244
}
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   245
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   246
inline void HeapRegion::note_end_of_marking() {
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   247
  _prev_top_at_mark_start = _next_top_at_mark_start;
49664
9a04cc89dde0 8200234: Cleanup Remark and Cleanup pause code
tschatzl
parents: 47885
diff changeset
   248
  _next_top_at_mark_start = bottom();
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   249
  _prev_marked_bytes = _next_marked_bytes;
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   250
  _next_marked_bytes = 0;
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   251
}
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   252
29470
e34bbcd36e53 8030646: track collection set membership in one place
ehelin
parents: 29081
diff changeset
   253
inline bool HeapRegion::in_collection_set() const {
e34bbcd36e53 8030646: track collection set membership in one place
ehelin
parents: 29081
diff changeset
   254
  return G1CollectedHeap::heap()->is_in_cset(this);
e34bbcd36e53 8030646: track collection set membership in one place
ehelin
parents: 29081
diff changeset
   255
}
e34bbcd36e53 8030646: track collection set membership in one place
ehelin
parents: 29081
diff changeset
   256
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   257
template <class Closure, bool is_gc_active>
55607
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   258
HeapWord* HeapRegion::do_oops_on_memregion_in_humongous(MemRegion mr,
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   259
                                                        Closure* cl,
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   260
                                                        G1CollectedHeap* g1h) {
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   261
  assert(is_humongous(), "precondition");
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   262
  HeapRegion* sr = humongous_start_region();
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   263
  oop obj = oop(sr->bottom());
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   264
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   265
  // If concurrent and klass_or_null is NULL, then space has been
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   266
  // allocated but the object has not yet been published by setting
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   267
  // the klass.  That can only happen if the card is stale.  However,
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   268
  // we've already set the card clean, so we must return failure,
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   269
  // since the allocating thread could have performed a write to the
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   270
  // card that might be missed otherwise.
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   271
  if (!is_gc_active && (obj->klass_or_null_acquire() == NULL)) {
55607
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   272
    return NULL;
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   273
  }
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   274
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   275
  // We have a well-formed humongous object at the start of sr.
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   276
  // Only filler objects follow a humongous object in the containing
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   277
  // regions, and we can ignore those.  So only process the one
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   278
  // humongous object.
55607
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   279
  if (g1h->is_obj_dead(obj, sr)) {
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   280
    // The object is dead. There can be no other object in this region, so return
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   281
    // the end of that region.
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   282
    return end();
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   283
  }
55607
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   284
  if (obj->is_objArray() || (sr->bottom() < mr.start())) {
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   285
    // objArrays are always marked precisely, so limit processing
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   286
    // with mr.  Non-objArrays might be precisely marked, and since
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   287
    // it's humongous it's worthwhile avoiding full processing.
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   288
    // However, the card could be stale and only cover filler
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   289
    // objects.  That should be rare, so not worth checking for;
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   290
    // instead let it fall out from the bounded iteration.
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   291
    obj->oop_iterate(cl, mr);
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   292
    return mr.end();
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   293
  } else {
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   294
    // If obj is not an objArray and mr contains the start of the
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   295
    // obj, then this could be an imprecise mark, and we need to
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   296
    // process the entire object.
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   297
    int size = obj->oop_iterate_size(cl);
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   298
    // We have scanned to the end of the object, but since there can be no objects
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   299
    // after this humongous object in the region, we can return the end of the
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   300
    // region if it is greater.
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   301
    return MAX2((HeapWord*)obj + size, mr.end());
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   302
  }
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   303
}
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   304
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   305
template <bool is_gc_active, class Closure>
55607
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   306
HeapWord* HeapRegion::oops_on_memregion_seq_iterate_careful(MemRegion mr,
59218
a1155217a563 8233306: Sort members in G1's HeapRegion after removal of Space dependency
tschatzl
parents: 58980
diff changeset
   307
                                                            Closure* cl) {
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   308
  assert(MemRegion(bottom(), end()).contains(mr), "Card region not in heap region");
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   309
  G1CollectedHeap* g1h = G1CollectedHeap::heap();
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   310
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   311
  // Special handling for humongous regions.
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   312
  if (is_humongous()) {
55607
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   313
    return do_oops_on_memregion_in_humongous<Closure, is_gc_active>(mr, cl, g1h);
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   314
  }
51494
1906adbef2dc 8208498: Put archive regions into a first-class HeapRegionSet
tschatzl
parents: 49664
diff changeset
   315
  assert(is_old() || is_archive(), "Wrongly trying to iterate over region %u type %s", _hrm_index, get_type_str());
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   316
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   317
  // Because mr has been trimmed to what's been allocated in this
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   318
  // region, the parts of the heap that are examined here are always
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   319
  // parsable; there's no need to use klass_or_null to detect
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   320
  // in-progress allocation.
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   321
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   322
  // Cache the boundaries of the memory region in some const locals
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   323
  HeapWord* const start = mr.start();
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   324
  HeapWord* const end = mr.end();
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   325
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   326
  // Find the obj that extends onto mr.start().
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   327
  // Update BOT as needed while finding start of (possibly dead)
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   328
  // object containing the start of the region.
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   329
  HeapWord* cur = block_start(start);
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   330
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   331
#ifdef ASSERT
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   332
  {
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   333
    assert(cur <= start,
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   334
           "cur: " PTR_FORMAT ", start: " PTR_FORMAT, p2i(cur), p2i(start));
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   335
    HeapWord* next = cur + block_size(cur);
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   336
    assert(start < next,
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   337
           "start: " PTR_FORMAT ", next: " PTR_FORMAT, p2i(start), p2i(next));
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   338
  }
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   339
#endif
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   340
47678
c84eeb55c55e 8184667: Clean up G1ConcurrentMark files
tschatzl
parents: 47634
diff changeset
   341
  const G1CMBitMap* const bitmap = g1h->concurrent_mark()->prev_mark_bitmap();
55607
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   342
  while (true) {
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   343
    oop obj = oop(cur);
46968
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   344
    assert(oopDesc::is_oop(obj, true), "Not an oop at " PTR_FORMAT, p2i(cur));
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   345
    assert(obj->klass_or_null() != NULL,
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   346
           "Unparsable heap at " PTR_FORMAT, p2i(cur));
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   347
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   348
    size_t size;
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   349
    bool is_dead = is_obj_dead_with_size(obj, bitmap, &size);
55607
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   350
    bool is_precise = false;
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   351
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   352
    cur += size;
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   353
    if (!is_dead) {
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   354
      // Process live object's references.
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   355
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   356
      // Non-objArrays are usually marked imprecise at the object
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   357
      // start, in which case we need to iterate over them in full.
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   358
      // objArrays are precisely marked, but can still be iterated
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   359
      // over in full if completely covered.
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   360
      if (!obj->is_objArray() || (((HeapWord*)obj) >= start && cur <= end)) {
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   361
        obj->oop_iterate(cl);
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   362
      } else {
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   363
        obj->oop_iterate(cl, mr);
55607
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   364
        is_precise = true;
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   365
      }
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   366
    }
55607
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   367
    if (cur >= end) {
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   368
      return is_precise ? end : cur;
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   369
    }
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 53244
diff changeset
   370
  }
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   371
}
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   372
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52875
diff changeset
   373
#endif // SHARE_GC_G1_HEAPREGION_INLINE_HPP