hotspot/src/share/vm/gc/g1/heapRegion.inline.hpp
author tschatzl
Fri, 02 Jun 2017 13:45:15 +0200
changeset 46517 14de3e5151a9
parent 40655 9f644073d3a0
child 46625 edefffab74e2
permissions -rw-r--r--
8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset Reviewed-by: kbarrett, sangheki, ehelin
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"
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    34
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    35
inline HeapWord* G1ContiguousSpace::allocate_impl(size_t min_word_size,
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    36
                                                  size_t desired_word_size,
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    37
                                                  size_t* actual_size) {
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    38
  HeapWord* obj = top();
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    39
  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
    40
  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
    41
  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
    42
    HeapWord* new_top = obj + want_to_allocate;
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    43
    set_top(new_top);
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    44
    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
    45
    *actual_size = want_to_allocate;
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    46
    return obj;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    47
  } else {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    48
    return NULL;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    49
  }
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
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    52
inline HeapWord* G1ContiguousSpace::par_allocate_impl(size_t min_word_size,
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    53
                                                      size_t desired_word_size,
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    54
                                                      size_t* actual_size) {
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    55
  do {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    56
    HeapWord* obj = top();
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    57
    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
    58
    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
    59
    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
    60
      HeapWord* new_top = obj + want_to_allocate;
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    61
      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
    62
      // result can be one of two:
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    63
      //  the old top value: the exchange succeeded
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    64
      //  otherwise: the new value of the top is returned.
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    65
      if (result == obj) {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    66
        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
    67
        *actual_size = want_to_allocate;
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    68
        return obj;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    69
      }
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    70
    } else {
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    71
      return NULL;
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
  } while (true);
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
    74
}
25361
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 12508
diff changeset
    75
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    76
inline HeapWord* G1ContiguousSpace::allocate(size_t min_word_size,
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    77
                                             size_t desired_word_size,
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    78
                                             size_t* actual_size) {
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    79
  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
    80
  if (res != NULL) {
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    81
    _bot_part.alloc_block(res, *actual_size);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    82
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    83
  return res;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    84
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    85
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    86
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
    87
  size_t temp;
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    88
  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
    89
}
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    90
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    91
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
    92
  size_t temp;
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    93
  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
    94
}
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    95
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    96
// 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
    97
// allocations, we sequentialize these with a lock.  Therefore, best if
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    98
// this is used for larger LAB allocations only.
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
    99
inline HeapWord* G1ContiguousSpace::par_allocate(size_t min_word_size,
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
   100
                                                 size_t desired_word_size,
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
   101
                                                 size_t* actual_size) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   102
  MutexLocker x(&_par_alloc_lock);
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   103
  return allocate(min_word_size, desired_word_size, actual_size);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   104
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   105
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
   106
inline HeapWord* G1ContiguousSpace::block_start(const void* p) {
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
   107
  return _bot_part.block_start(p);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   108
}
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
inline HeapWord*
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
   111
G1ContiguousSpace::block_start_const(const void* p) const {
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 33786
diff changeset
   112
  return _bot_part.block_start_const(p);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   113
}
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   114
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
   115
inline bool HeapRegion::is_obj_dead_with_size(const oop obj, G1CMBitMapRO* prev_bitmap, size_t* size) const {
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   116
  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
   117
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
  assert(addr < top(), "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
   119
  assert(!is_archive(), "Archive regions should not have references into interesting 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
   120
  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
   121
  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
   122
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
  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
   124
    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
   125
    *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
   126
  } 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
   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 = 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
   129
  }
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
  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
   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
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   133
inline bool
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   134
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
   135
  G1CollectedHeap* g1h = G1CollectedHeap::heap();
33786
ac8da6513351 8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents: 33105
diff changeset
   136
ac8da6513351 8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents: 33105
diff changeset
   137
  if (!this->is_in(p)) {
ac8da6513351 8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents: 33105
diff changeset
   138
    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
   139
    return (p == humongous_start_region()->bottom());
ac8da6513351 8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents: 33105
diff changeset
   140
  }
25908
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   141
  if (ClassUnloadingWithConcurrentMark) {
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   142
    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
   143
  }
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   144
  return p < top();
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   145
}
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   146
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
   147
inline size_t HeapRegion::block_size_using_bitmap(const HeapWord* addr, const G1CMBitMapRO* prev_bitmap) const {
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   148
  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
   149
         "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
   150
         "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
   151
         "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
   152
         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
   153
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
  // 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
   155
  // We need to find the next live object using the 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
   156
  HeapWord* next = prev_bitmap->getNextMarkedWordAddress(addr, prev_top_at_mark_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
   157
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   158
  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
   159
  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
   160
}
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
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
inline bool HeapRegion::is_obj_dead(const oop obj, const G1CMBitMapRO* prev_bitmap) const {
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
  assert(is_in_reserved(obj), "Object " PTR_FORMAT " must be in region", p2i(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
   164
  return !obj_allocated_since_prev_marking(obj) && !prev_bitmap->isMarked((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
   165
}
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   166
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 40655
diff changeset
   167
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
   168
  if (addr == top()) {
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   169
    return pointer_delta(end(), addr);
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   170
  }
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   171
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   172
  if (block_is_obj(addr)) {
8adb2fb6fc3c 8048269: Add flag to turn off class unloading after G1 concurrent mark
stefank
parents: 25492
diff changeset
   173
    return oop(addr)->size();
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
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
   176
  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
   177
}
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   178
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   179
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
   180
                                                         size_t desired_word_size,
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   181
                                                         size_t* actual_word_size) {
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   182
  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
   183
  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
   184
}
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   185
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   186
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
   187
  size_t temp;
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   188
  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
   189
}
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   190
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   191
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
   192
                                                     size_t desired_word_size,
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   193
                                                     size_t* actual_word_size) {
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   194
  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
   195
  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
   196
}
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25361
diff changeset
   197
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   198
inline void HeapRegion::note_start_of_marking() {
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   199
  _next_marked_bytes = 0;
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   200
  _next_top_at_mark_start = top();
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   201
}
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   202
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   203
inline void HeapRegion::note_end_of_marking() {
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   204
  _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
   205
  _prev_marked_bytes = _next_marked_bytes;
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   206
  _next_marked_bytes = 0;
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   207
}
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   208
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   209
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
   210
  if (is_survivor()) {
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   211
    // This is how we always allocate survivors.
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   212
    assert(_next_top_at_mark_start == bottom(), "invariant");
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   213
  } else {
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   214
    if (during_initial_mark) {
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   215
      // 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
   216
      // 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
   217
      // 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
   218
      // 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
   219
      // 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
   220
      // 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
   221
      // 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
   222
      _next_top_at_mark_start = end();
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   223
    } else {
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   224
      // 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
   225
      // 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
   226
      // 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
   227
      // 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
   228
      // 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
   229
      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
   230
    }
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   231
  }
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   232
}
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   233
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   234
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
   235
  if (is_survivor()) {
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   236
    // This is how we always allocate survivors.
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   237
    assert(_next_top_at_mark_start == bottom(), "invariant");
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   238
  } else {
e1df4d08a1f4 7127706: G1: re-enable survivors during the initial-mark pause
tonyp
parents: 11455
diff changeset
   239
    if (during_initial_mark) {
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   240
      // 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
   241
      // on this.
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   242
      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
   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
    } else {
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   245
      // 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
   246
      // on this.
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   247
      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
   248
    }
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   249
  }
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   250
}
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 8928
diff changeset
   251
29470
e34bbcd36e53 8030646: track collection set membership in one place
ehelin
parents: 29081
diff changeset
   252
inline bool HeapRegion::in_collection_set() const {
e34bbcd36e53 8030646: track collection set membership in one place
ehelin
parents: 29081
diff changeset
   253
  return G1CollectedHeap::heap()->is_in_cset(this);
e34bbcd36e53 8030646: track collection set membership in one place
ehelin
parents: 29081
diff changeset
   254
}
e34bbcd36e53 8030646: track collection set membership in one place
ehelin
parents: 29081
diff changeset
   255
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
   256
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
   257
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
   258
                                              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
   259
                                              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
   260
  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
   261
  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
   262
  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
   263
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
  // 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
   265
  // 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
   266
  // 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
   267
  // 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
   268
  // 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
   269
  // 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
   270
  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
   271
    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
   272
  }
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
  // 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
   275
  // 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
   276
  // 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
   277
  // 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
   278
  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
   279
    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
   280
      // 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
   281
      // 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
   282
      // 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
   283
      // 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
   284
      // 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
   285
      // 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
   286
      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
   287
    } 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
   288
      // 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
   289
      // 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
   290
      // 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
   291
      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
   292
    }
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
  }
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
  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
   295
}
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
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
   298
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
   299
                                                  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
   300
  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
   301
  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
   302
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
  // 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
   304
  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
   305
    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
   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
  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
   308
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
  // 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
   310
  // 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
   311
  // 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
   312
  // 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
   313
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
  // 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
   315
  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
   316
  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
   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
  // 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
   319
  // 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
   320
  // 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
   321
  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
   322
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
#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
   324
  {
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
    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
   326
           "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
   327
    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
   328
    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
   329
           "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
   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
#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
   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
  G1CMBitMapRO* bitmap = g1h->concurrent_mark()->prevMarkBitMap();
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
  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
   335
    oop obj = oop(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(obj->is_oop(true), "Not an oop 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
   337
    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
   338
           "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
   339
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
    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
   341
    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
   342
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
    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
   344
    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
   345
      // 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
   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
      // 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
   348
      // 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
   349
      // 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
   350
      // 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
   351
      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
   352
        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
   353
      } 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
   354
        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
   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
    }
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
  } 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
   358
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
  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
   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
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 29470
diff changeset
   362
#endif // SHARE_VM_GC_G1_HEAPREGION_INLINE_HPP