src/hotspot/share/gc/g1/heapRegion.inline.hpp
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 46968 hotspot/src/share/vm/gc/g1/heapRegion.inline.hpp@9119841280f4
child 47634 6a0c42c40cd1
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
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
/*
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
     2
 * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     4
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     8
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    13
 * accompanied this code).
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    14
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1374
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1374
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1374
diff changeset
    21
 * questions.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    22
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    23
 */
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    24
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29470
diff changeset
    25
#ifndef SHARE_VM_GC_G1_HEAPREGION_INLINE_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29470
diff changeset
    26
#define SHARE_VM_GC_G1_HEAPREGION_INLINE_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29470
diff changeset
    28
#include "gc/g1/g1BlockOffsetTable.inline.hpp"
32185
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31592
diff changeset
    29
#include "gc/g1/g1CollectedHeap.inline.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29470
diff changeset
    30
#include "gc/g1/heapRegion.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29470
diff changeset
    31
#include "gc/shared/space.hpp"
29081
c61eb4914428 8072911: Remove includes of oop.inline.hpp from .hpp files
stefank
parents: 25908
diff changeset
    32
#include "oops/oop.inline.hpp"
40655
9f644073d3a0 8157907: Incorrect inclusion of atomic.hpp instead of atomic.inline.hpp
dholmes
parents: 39698
diff changeset
    33
#include "runtime/atomic.hpp"
46625
edefffab74e2 8183552: Move align functions to align.hpp
stefank
parents: 46517
diff changeset
    34
#include "utilities/align.hpp"
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    35
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    36
inline HeapWord* G1ContiguousSpace::allocate_impl(size_t min_word_size,
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    37
                                                  size_t desired_word_size,
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    38
                                                  size_t* actual_size) {
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    39
  HeapWord* obj = top();
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    40
  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
    41
  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
    42
  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
    43
    HeapWord* new_top = obj + want_to_allocate;
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    44
    set_top(new_top);
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    45
    assert(is_aligned(obj) && is_aligned(new_top), "checking alignment");
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    46
    *actual_size = want_to_allocate;
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    47
    return obj;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    48
  } else {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    49
    return NULL;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    50
  }
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    51
}
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    52
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    53
inline HeapWord* G1ContiguousSpace::par_allocate_impl(size_t min_word_size,
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    54
                                                      size_t desired_word_size,
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    55
                                                      size_t* actual_size) {
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    56
  do {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    57
    HeapWord* obj = top();
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    58
    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
    59
    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
    60
    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
    61
      HeapWord* new_top = obj + want_to_allocate;
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    62
      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
    63
      // result can be one of two:
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    64
      //  the old top value: the exchange succeeded
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    65
      //  otherwise: the new value of the top is returned.
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    66
      if (result == obj) {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    67
        assert(is_aligned(obj) && is_aligned(new_top), "checking alignment");
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    68
        *actual_size = want_to_allocate;
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    69
        return obj;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    70
      }
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    71
    } else {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    72
      return NULL;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    73
    }
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    74
  } while (true);
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    75
}
25361
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 12508
diff changeset
    76
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    77
inline HeapWord* G1ContiguousSpace::allocate(size_t min_word_size,
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    78
                                             size_t desired_word_size,
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    79
                                             size_t* actual_size) {
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    80
  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
    81
  if (res != NULL) {
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    82
    _bot_part.alloc_block(res, *actual_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
  return res;
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
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    87
inline HeapWord* G1ContiguousSpace::allocate(size_t word_size) {
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    88
  size_t temp;
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    89
  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
    90
}
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    91
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    92
inline HeapWord* G1ContiguousSpace::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
    93
  size_t temp;
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    94
  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
    95
}
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    96
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    97
// 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
    98
// allocations, we sequentialize these with a lock.  Therefore, best if
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    99
// this is used for larger LAB allocations only.
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
   100
inline HeapWord* G1ContiguousSpace::par_allocate(size_t min_word_size,
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
   101
                                                 size_t desired_word_size,
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
   102
                                                 size_t* actual_size) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   103
  MutexLocker x(&_par_alloc_lock);
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   104
  return allocate(min_word_size, desired_word_size, actual_size);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   105
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   106
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
   107
inline HeapWord* G1ContiguousSpace::block_start(const void* p) {
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
   108
  return _bot_part.block_start(p);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   109
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   110
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   111
inline HeapWord*
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
   112
G1ContiguousSpace::block_start_const(const void* p) const {
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
   113
  return _bot_part.block_start_const(p);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   114
}
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   115
46750
bcab0128a16f 8184346: Clean up G1CMBitmap
tschatzl
parents: 46625
diff changeset
   116
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
   117
  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
   118
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
  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
   120
  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
   121
         "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
   122
  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
   123
  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
   124
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
  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
   126
    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
   127
    *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
   128
  } 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
   129
    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
   130
    *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
   131
  }
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
  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
   133
}
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
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   135
inline bool
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   136
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
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
   180
  return block_size_using_bitmap(addr, G1CollectedHeap::heap()->concurrent_mark()->prevMarkBitMap());
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
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   183
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
   184
                                                         size_t desired_word_size,
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   185
                                                         size_t* actual_word_size) {
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   186
  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
   187
  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
   188
}
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   189
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   190
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
   191
  size_t temp;
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   192
  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
   193
}
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   194
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   195
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
   196
                                                     size_t desired_word_size,
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   197
                                                     size_t* actual_word_size) {
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   198
  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
   199
  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
   200
}
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   201
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   202
inline void HeapRegion::note_start_of_marking() {
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   203
  _next_marked_bytes = 0;
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   204
  _next_top_at_mark_start = top();
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   205
}
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   206
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   207
inline void HeapRegion::note_end_of_marking() {
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   208
  _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
   209
  _prev_marked_bytes = _next_marked_bytes;
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   210
  _next_marked_bytes = 0;
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   211
}
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   212
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   213
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
   214
  if (is_survivor()) {
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   215
    // This is how we always allocate survivors.
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   216
    assert(_next_top_at_mark_start == bottom(), "invariant");
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   217
  } else {
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   218
    if (during_initial_mark) {
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   219
      // 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
   220
      // 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
   221
      // 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
   222
      // 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
   223
      // 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
   224
      // 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
   225
      // 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
   226
      _next_top_at_mark_start = end();
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   227
    } else {
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   228
      // 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
   229
      // 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
   230
      // 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
   231
      // 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
   232
      // 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
   233
      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
   234
    }
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   235
  }
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   236
}
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   237
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   238
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
   239
  if (is_survivor()) {
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   240
    // This is how we always allocate survivors.
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   241
    assert(_next_top_at_mark_start == bottom(), "invariant");
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   242
  } else {
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   243
    if (during_initial_mark) {
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   244
      // 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
   245
      // on this.
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   246
      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
   247
      _next_top_at_mark_start = top();
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   248
    } else {
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   249
      // 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
   250
      // on this.
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   251
      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
   252
    }
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   253
  }
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   254
}
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   255
29470
e34bbcd36e53 8030646: track collection set membership in one place
ehelin
parents: 29081
diff changeset
   256
inline bool HeapRegion::in_collection_set() const {
e34bbcd36e53 8030646: track collection set membership in one place
ehelin
parents: 29081
diff changeset
   257
  return G1CollectedHeap::heap()->is_in_cset(this);
e34bbcd36e53 8030646: track collection set membership in one place
ehelin
parents: 29081
diff changeset
   258
}
e34bbcd36e53 8030646: track collection set membership in one place
ehelin
parents: 29081
diff changeset
   259
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
   260
template <class Closure, bool is_gc_active>
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
bool HeapRegion::do_oops_on_card_in_humongous(MemRegion mr,
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
                                              Closure* 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
   263
                                              G1CollectedHeap* g1h) {
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
  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
   265
  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
   266
  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
   267
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
  // 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
   269
  // 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
   270
  // 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
   271
  // 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
   272
  // 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
   273
  // 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
   274
  if (!is_gc_active && (obj->klass_or_null_acquire() == 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
   275
    return false;
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
  }
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
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
  // 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
   279
  // 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
   280
  // 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
   281
  // humongous 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
   282
  if (!g1h->is_obj_dead(obj, 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
   283
    if (obj->is_objArray() || (sr->bottom() < 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
   284
      // objArrays are always marked precisely, so limit processing
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   285
      // with mr.  Non-objArrays might be precisely marked, and since
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   286
      // it's humongous it's worthwhile avoiding full processing.
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   287
      // However, the card could be stale and only cover filler
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   288
      // objects.  That should be rare, so not worth checking for;
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   289
      // instead let it fall out from the bounded iteration.
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   290
      obj->oop_iterate(cl, mr);
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   291
    } 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
   292
      // If obj is not an objArray and mr contains the start of 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
   293
      // obj, then this could be an imprecise mark, and we need to
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   294
      // process the entire 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
   295
      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
   296
    }
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   297
  }
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   298
  return true;
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   299
}
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   300
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   301
template <bool is_gc_active, class Closure>
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   302
bool HeapRegion::oops_on_card_seq_iterate_careful(MemRegion mr,
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
                                                  Closure* 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
   304
  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
   305
  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
   306
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   307
  // 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
   308
  if (is_humongous()) {
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
    return do_oops_on_card_in_humongous<Closure, is_gc_active>(mr, cl, g1h);
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
  assert(is_old(), "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
   312
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   313
  // 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
   314
  // 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
   315
  // 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
   316
  // 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
   317
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
  // 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
   319
  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
   320
  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
   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
  // 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
   323
  // 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
   324
  // 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
   325
  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
   326
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
#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
   328
  {
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
    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
   330
           "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
   331
    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
   332
    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
   333
           "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
   334
  }
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
#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
   336
46750
bcab0128a16f 8184346: Clean up G1CMBitmap
tschatzl
parents: 46625
diff changeset
   337
  const G1CMBitMap* const bitmap = g1h->concurrent_mark()->prevMarkBitMap();
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
   338
  do {
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
    oop obj = oop(cur);
46968
9119841280f4 8160399: is_oop_or_null involves undefined behavior
coleenp
parents: 46810
diff changeset
   340
    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
   341
    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
   342
           "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
   343
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   344
    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
   345
    bool is_dead = is_obj_dead_with_size(obj, bitmap, &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
   346
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
    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
   348
    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
   349
      // 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
   350
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
      // 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
   352
      // 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
   353
      // 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
   354
      // 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
   355
      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
   356
        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
   357
      } 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
   358
        obj->oop_iterate(cl, mr);
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
      }
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
    }
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
  } while (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
   362
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
  return true;
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   364
}
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
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29470
diff changeset
   366
#endif // SHARE_VM_GC_G1_HEAPREGION_INLINE_HPP