src/hotspot/share/gc/g1/heapRegion.hpp
author sangheki
Wed, 13 Nov 2019 10:49:12 -0800
changeset 59060 fce1fa1bdc91
parent 58980 47c20fc6a517
child 59218 a1155217a563
permissions -rw-r--r--
8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3) Reviewed-by: kbarrett, sjohanss, tschatzl, pliden
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52897
diff changeset
     2
 * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     4
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     8
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    13
 * accompanied this code).
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    14
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5350
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5350
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: 5350
diff changeset
    21
 * questions.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    22
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    23
 */
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52897
diff changeset
    25
#ifndef SHARE_GC_G1_HEAPREGION_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52897
diff changeset
    26
#define SHARE_GC_G1_HEAPREGION_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30265
diff changeset
    28
#include "gc/g1/g1BlockOffsetTable.hpp"
36098
e056a98ac7ca 8149650: Create a trace event for G1 heap region type transitions
david
parents: 35507
diff changeset
    29
#include "gc/g1/g1HeapRegionTraceType.hpp"
e056a98ac7ca 8149650: Create a trace event for G1 heap region type transitions
david
parents: 35507
diff changeset
    30
#include "gc/g1/heapRegionTracer.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30265
diff changeset
    31
#include "gc/g1/heapRegionType.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30265
diff changeset
    32
#include "gc/g1/survRateGroup.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30265
diff changeset
    33
#include "gc/shared/ageTable.hpp"
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    34
#include "gc/shared/spaceDecorator.hpp"
54781
f3f07c76d3d1 8223619: Move VerifyOption out of Universe
stefank
parents: 54465
diff changeset
    35
#include "gc/shared/verifyOption.hpp"
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    36
#include "runtime/mutex.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 13756
diff changeset
    37
#include "utilities/macros.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    38
30265
609384e91c30 8078048: Fix non-pch build after "8076457: Fix includes of inline.hpp in GC code"
goetz
parents: 30175
diff changeset
    39
class G1CollectedHeap;
46750
bcab0128a16f 8184346: Clean up G1CMBitmap
tschatzl
parents: 46520
diff changeset
    40
class G1CMBitMap;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    41
class HeapRegionRemSet;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    42
class HeapRegion;
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
    43
class HeapRegionSetBase;
19339
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 15482
diff changeset
    44
class nmethod;
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
    45
31592
43f48e165466 8081202: Hotspot compile warning: "Invalid suffix on literal; C++11 requires a space between literal and identifier"
bpittore
parents: 31346
diff changeset
    46
#define HR_FORMAT "%u:(%s)[" PTR_FORMAT "," PTR_FORMAT "," PTR_FORMAT "]"
9989
305a76435cf1 7045330: G1: Simplify/fix the HeapRegionSeq class
tonyp
parents: 9418
diff changeset
    47
#define HR_FORMAT_PARAMS(_hr_) \
26316
93f6b40c038b 8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents: 26157
diff changeset
    48
                (_hr_)->hrm_index(), \
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents: 26422
diff changeset
    49
                (_hr_)->get_short_type_str(), \
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23471
diff changeset
    50
                p2i((_hr_)->bottom()), p2i((_hr_)->top()), p2i((_hr_)->end())
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    51
26316
93f6b40c038b 8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents: 26157
diff changeset
    52
// sentinel value for hrm_index
93f6b40c038b 8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents: 26157
diff changeset
    53
#define G1_NO_HRM_INDEX ((uint) -1)
12381
1438e0fbfa27 7157073: G1: type change size_t -> uint for region counts / indexes
tonyp
parents: 12379
diff changeset
    54
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    55
// A HeapRegion is the smallest piece of a G1CollectedHeap that
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    56
// can be collected independently.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    57
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    58
// Each heap region is self contained. top() and end() can never
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    59
// be set beyond the end of the region. For humongous objects,
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    60
// the first region is a StartsHumongous region. If the humongous
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    61
// object is larger than a heap region, the following regions will
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    62
// be of type ContinuesHumongous. In this case the top() of the
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    63
// StartHumongous region and all ContinuesHumongous regions except
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    64
// the last will point to their own end. The last ContinuesHumongous
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    65
// region may have top() equal the end of object if there isn't
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    66
// room for filler objects to pad out to the end of the region.
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    67
class HeapRegion : public CHeapObj<mtGC> {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    68
  friend class VMStructs;
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    69
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    70
  HeapWord* _bottom;
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    71
  HeapWord* _end;
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    72
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
    73
  HeapWord* volatile _top;
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    74
  HeapWord* _compaction_top;
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    75
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34617
diff changeset
    76
  G1BlockOffsetTablePart _bot_part;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    77
  Mutex _par_alloc_lock;
8928
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents: 8680
diff changeset
    78
  // When we need to retire an allocation region, while other threads
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents: 8680
diff changeset
    79
  // are also concurrently trying to allocate into it, we typically
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents: 8680
diff changeset
    80
  // allocate a dummy object at the end of the region to ensure that
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents: 8680
diff changeset
    81
  // no more allocations can take place in it. However, sometimes we
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents: 8680
diff changeset
    82
  // want to know where the end of the last "real" object we allocated
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents: 8680
diff changeset
    83
  // into the region was and this is what this keeps track.
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents: 8680
diff changeset
    84
  HeapWord* _pre_dummy_top;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    85
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    86
public:
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    87
  void set_bottom(HeapWord* value) { _bottom = value; }
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    88
  HeapWord* bottom() const         { return _bottom; }
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    89
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    90
  void set_end(HeapWord* value)    { _end = value; }
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    91
  HeapWord* end() const            { return _end;    }
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    92
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    93
  void set_compaction_top(HeapWord* compaction_top) { _compaction_top = compaction_top; }
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    94
  HeapWord* compaction_top() const { return _compaction_top; }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    95
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25479
diff changeset
    96
  void set_top(HeapWord* value) { _top = value; }
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25479
diff changeset
    97
  HeapWord* top() const { return _top; }
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25479
diff changeset
    98
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
    99
  // Returns true iff the given the heap  region contains the
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   100
  // given address as part of an allocated object. This may
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   101
  // be a potentially, so we restrict its use to assertion checks only.
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   102
  bool is_in(const void* p) const {
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   103
    return is_in_reserved(p);
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   104
  }
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   105
  bool is_in(oop obj) const {
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   106
    return is_in((void*)obj);
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   107
  }
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   108
  // Returns true iff the given reserved memory of the space contains the
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   109
  // given address.
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   110
  bool is_in_reserved(const void* p) const { return _bottom <= p && p < _end; }
26157
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 25492
diff changeset
   111
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   112
  size_t capacity()     const { return byte_size(bottom(), end()); }
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   113
  size_t used() const { return byte_size(bottom(), top()); }
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   114
  size_t free() const { return byte_size(top(), end()); }
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   115
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   116
  bool is_empty() const { return used() == 0; }
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   117
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   118
private:
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   119
  void reset_after_compaction() { set_top(compaction_top()); }
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   120
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   121
  // Try to allocate at least min_word_size and up to desired_size from this region.
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   122
  // Returns NULL if not possible, otherwise sets actual_word_size to the amount of
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   123
  // space allocated.
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   124
  // This version assumes that all allocation requests to this HeapRegion are properly
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   125
  // synchronized.
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   126
  inline HeapWord* allocate_impl(size_t min_word_size, size_t desired_word_size, size_t* actual_word_size);
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   127
  // Try to allocate at least min_word_size and up to desired_size from this HeapRegion.
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   128
  // Returns NULL if not possible, otherwise sets actual_word_size to the amount of
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   129
  // space allocated.
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   130
  // This version synchronizes with other calls to par_allocate_impl().
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   131
  inline HeapWord* par_allocate_impl(size_t min_word_size, size_t desired_word_size, size_t* actual_word_size);
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25479
diff changeset
   132
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   133
  void mangle_unused_area() PRODUCT_RETURN;
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25479
diff changeset
   134
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   135
public:
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25479
diff changeset
   136
  void object_iterate(ObjectClosure* blk);
29681
e96b344b2c42 8073463: G1 does not mangle freed heap regions
david
parents: 29470
diff changeset
   137
8928
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents: 8680
diff changeset
   138
  // See the comment above in the declaration of _pre_dummy_top for an
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents: 8680
diff changeset
   139
  // explanation of what it is.
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents: 8680
diff changeset
   140
  void set_pre_dummy_top(HeapWord* pre_dummy_top) {
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents: 8680
diff changeset
   141
    assert(is_in(pre_dummy_top) && pre_dummy_top <= top(), "pre-condition");
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents: 8680
diff changeset
   142
    _pre_dummy_top = pre_dummy_top;
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents: 8680
diff changeset
   143
  }
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   144
8928
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents: 8680
diff changeset
   145
  HeapWord* pre_dummy_top() {
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents: 8680
diff changeset
   146
    return (_pre_dummy_top == NULL) ? top() : _pre_dummy_top;
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents: 8680
diff changeset
   147
  }
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents: 8680
diff changeset
   148
  void reset_pre_dummy_top() { _pre_dummy_top = NULL; }
e5c53268bef5 7023069: G1: Introduce symmetric locking in the slow allocation path
tonyp
parents: 8680
diff changeset
   149
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   150
  void clear(bool mangle_space);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   151
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   152
  HeapWord* block_start(const void* p);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   153
  HeapWord* block_start_const(const void* p) const;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   154
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   155
  // Allocation (return NULL if full).  Assumes the caller has established
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   156
  // mutually exclusive access to the HeapRegion.
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   157
  HeapWord* allocate(size_t min_word_size, size_t desired_word_size, size_t* actual_word_size);
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   158
  // Allocation (return NULL if full).  Enforces mutual exclusion internally.
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   159
  HeapWord* par_allocate(size_t min_word_size, size_t desired_word_size, size_t* actual_word_size);
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   160
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   161
  HeapWord* allocate(size_t word_size);
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   162
  HeapWord* par_allocate(size_t word_size);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   163
27889
7d50f95e0076 8065358: Refactor G1s usage of save_marks and reduce related races
mgerdin
parents: 27624
diff changeset
   164
  HeapWord* saved_mark_word() const { ShouldNotReachHere(); return NULL; }
7d50f95e0076 8065358: Refactor G1s usage of save_marks and reduce related races
mgerdin
parents: 27624
diff changeset
   165
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   166
  // MarkSweep support phase3
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   167
  HeapWord* initialize_threshold();
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   168
  HeapWord* cross_threshold(HeapWord* start, HeapWord* end);
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   169
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   170
  void reset_bot() {
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34617
diff changeset
   171
    _bot_part.reset_bot();
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   172
  }
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   173
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   174
  void print_bot_on(outputStream* out) {
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34617
diff changeset
   175
    _bot_part.print_on(out);
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   176
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   177
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   178
private:
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   179
  // The remembered set for this region.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   180
  HeapRegionRemSet* _rem_set;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   181
36098
e056a98ac7ca 8149650: Create a trace event for G1 heap region type transitions
david
parents: 35507
diff changeset
   182
  void report_region_type_change(G1HeapRegionTraceType::Type to);
e056a98ac7ca 8149650: Create a trace event for G1 heap region type transitions
david
parents: 35507
diff changeset
   183
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 46307
diff changeset
   184
  // Returns whether the given object address refers to a dead object, and either the
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 46307
diff changeset
   185
  // size of the object (if live) or the size of the block (if dead) in size.
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 46307
diff changeset
   186
  // May
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 46307
diff changeset
   187
  // - only called with obj < top()
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 46307
diff changeset
   188
  // - not called on humongous objects or archive regions
46750
bcab0128a16f 8184346: Clean up G1CMBitmap
tschatzl
parents: 46520
diff changeset
   189
  inline bool 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: 46307
diff changeset
   190
9989
305a76435cf1 7045330: G1: Simplify/fix the HeapRegionSeq class
tonyp
parents: 9418
diff changeset
   191
  // The index of this region in the heap region sequence.
26316
93f6b40c038b 8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents: 26157
diff changeset
   192
  uint  _hrm_index;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   193
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents: 26422
diff changeset
   194
  HeapRegionType _type;
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents: 26422
diff changeset
   195
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   196
  // For a humongous region, region in which it starts.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   197
  HeapRegion* _humongous_start_region;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   198
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   199
  // True iff an attempt to evacuate an object in the region failed.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   200
  bool _evacuation_failed;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   201
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   202
  // Fields used by the HeapRegionSetBase class and subclasses.
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   203
  HeapRegion* _next;
23471
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23453
diff changeset
   204
  HeapRegion* _prev;
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   205
#ifdef ASSERT
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   206
  HeapRegionSetBase* _containing_set;
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   207
#endif // ASSERT
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   208
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   209
  // We use concurrent marking to determine the amount of live data
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   210
  // in each heap region.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   211
  size_t _prev_marked_bytes;    // Bytes known to be live via last completed marking.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   212
  size_t _next_marked_bytes;    // Bytes known to be live via in-progress marking.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   213
12382
6aaecb1cbfe1 7145441: G1: collection set chooser-related cleanup
tonyp
parents: 12381
diff changeset
   214
  // The calculated GC efficiency of the region.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   215
  double _gc_efficiency;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   216
54465
c4f16445675a 8218668: Clean up evacuation of optional collection set
tschatzl
parents: 53703
diff changeset
   217
  static const uint InvalidCSetIndex = UINT_MAX;
c4f16445675a 8218668: Clean up evacuation of optional collection set
tschatzl
parents: 53703
diff changeset
   218
52897
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52875
diff changeset
   219
  // The index in the optional regions array, if this region
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52875
diff changeset
   220
  // is considered optional during a mixed collections.
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52875
diff changeset
   221
  uint _index_in_opt_cset;
57802
854e828d6b5b 8227442: Make young_index_in_cset zero-based
tschatzl
parents: 55607
diff changeset
   222
854e828d6b5b 8227442: Make young_index_in_cset zero-based
tschatzl
parents: 55607
diff changeset
   223
  // Data for young region survivor prediction.
854e828d6b5b 8227442: Make young_index_in_cset zero-based
tschatzl
parents: 55607
diff changeset
   224
  uint  _young_index_in_cset;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   225
  SurvRateGroup* _surv_rate_group;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   226
  int  _age_index;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   227
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   228
  // The start of the unmarked area. The unmarked area extends from this
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   229
  // word until the top and/or end of the region, and is the part
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   230
  // of the region for which no marking was done, i.e. objects may
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   231
  // have been allocated in this part since the last mark phase.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   232
  // "prev" is the top at the start of the last completed marking.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   233
  // "next" is the top at the start of the in-progress marking (if any.)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   234
  HeapWord* _prev_top_at_mark_start;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   235
  HeapWord* _next_top_at_mark_start;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   236
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   237
  void init_top_at_mark_start() {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   238
    assert(_prev_marked_bytes == 0 &&
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   239
           _next_marked_bytes == 0,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   240
           "Must be called after zero_marked_bytes.");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   241
    HeapWord* bot = bottom();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   242
    _prev_top_at_mark_start = bot;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   243
    _next_top_at_mark_start = bot;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   244
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   245
5350
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 4024
diff changeset
   246
  // Cached attributes used in the collection set policy information
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 4024
diff changeset
   247
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 4024
diff changeset
   248
  // The RSet length that was added to the total value
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 4024
diff changeset
   249
  // for the collection set.
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 4024
diff changeset
   250
  size_t _recorded_rs_length;
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 4024
diff changeset
   251
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 4024
diff changeset
   252
  // The predicted elapsed time that was added to total value
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 4024
diff changeset
   253
  // for the collection set.
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 4024
diff changeset
   254
  double _predicted_elapsed_time_ms;
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 4024
diff changeset
   255
59060
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 58980
diff changeset
   256
  uint _node_index;
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 58980
diff changeset
   257
55607
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 55510
diff changeset
   258
  // Iterate over the references covered by the given MemRegion in a humongous
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 55510
diff changeset
   259
  // object and apply the given closure to them.
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 46307
diff changeset
   260
  // Humongous objects are allocated directly in the old-gen. So we need special
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 46307
diff changeset
   261
  // handling for concurrent processing encountering an in-progress allocation.
55607
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 55510
diff changeset
   262
  // Returns the address after the last actually scanned or NULL if the area could
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 55510
diff changeset
   263
  // not be scanned (That should only happen when invoked concurrently with the
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 55510
diff changeset
   264
  // mutator).
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 46307
diff changeset
   265
  template <class Closure, bool is_gc_active>
55607
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 55510
diff changeset
   266
  inline HeapWord* do_oops_on_memregion_in_humongous(MemRegion mr,
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 55510
diff changeset
   267
                                                     Closure* cl,
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 55510
diff changeset
   268
                                                     G1CollectedHeap* g1h);
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 46307
diff changeset
   269
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 46307
diff changeset
   270
  // Returns the block size of the given (dead, potentially having its class unloaded) object
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 46307
diff changeset
   271
  // starting at p extending to at most the prev TAMS using the given mark bitmap.
46750
bcab0128a16f 8184346: Clean up G1CMBitmap
tschatzl
parents: 46520
diff changeset
   272
  inline size_t block_size_using_bitmap(const HeapWord* p, const G1CMBitMap* const prev_bitmap) const;
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   273
public:
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   274
  HeapRegion(uint hrm_index, G1BlockOffsetTable* bot, MemRegion mr);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   275
26157
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 25492
diff changeset
   276
  // Initializing the HeapRegion not only resets the data structure, but also
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 25492
diff changeset
   277
  // resets the BOT for that heap region.
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 25492
diff changeset
   278
  // The default values for clear_space means that we will do the clearing if
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 25492
diff changeset
   279
  // there's clearing to be done ourselves. We also always mangle the space.
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   280
  void initialize(MemRegion mr, bool clear_space = false, bool mangle_space = SpaceDecorator::Mangle);
26157
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 25492
diff changeset
   281
10677
370a8da2d63f 7095194: G1: HeapRegion::GrainBytes, GrainWords, and CardsPerRegion should be size_t
johnc
parents: 10671
diff changeset
   282
  static int    LogOfHRGrainBytes;
370a8da2d63f 7095194: G1: HeapRegion::GrainBytes, GrainWords, and CardsPerRegion should be size_t
johnc
parents: 10671
diff changeset
   283
  static int    LogOfHRGrainWords;
55510
3e31a8beaae4 8213108: Improve work distribution during remembered set scan
tschatzl
parents: 54781
diff changeset
   284
  static int    LogCardsPerRegion;
10677
370a8da2d63f 7095194: G1: HeapRegion::GrainBytes, GrainWords, and CardsPerRegion should be size_t
johnc
parents: 10671
diff changeset
   285
370a8da2d63f 7095194: G1: HeapRegion::GrainBytes, GrainWords, and CardsPerRegion should be size_t
johnc
parents: 10671
diff changeset
   286
  static size_t GrainBytes;
370a8da2d63f 7095194: G1: HeapRegion::GrainBytes, GrainWords, and CardsPerRegion should be size_t
johnc
parents: 10671
diff changeset
   287
  static size_t GrainWords;
370a8da2d63f 7095194: G1: HeapRegion::GrainBytes, GrainWords, and CardsPerRegion should be size_t
johnc
parents: 10671
diff changeset
   288
  static size_t CardsPerRegion;
3697
ea9211aa02f5 6819085: G1: use larger and/or user settable region size
tonyp
parents: 3000
diff changeset
   289
10671
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 10670
diff changeset
   290
  static size_t align_up_to_region_byte_size(size_t sz) {
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 10670
diff changeset
   291
    return (sz + (size_t) GrainBytes - 1) &
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 10670
diff changeset
   292
                                      ~((1 << (size_t) LogOfHRGrainBytes) - 1);
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 10670
diff changeset
   293
  }
431ff8629f97 7075646: G1: fix inconsistencies in the monitoring data
tonyp
parents: 10670
diff changeset
   294
34617
943740ea0d17 8144072: G1ParScanThreadState::update_rs does not need to call is_in_reserved
ehelin
parents: 34249
diff changeset
   295
943740ea0d17 8144072: G1ParScanThreadState::update_rs does not need to call is_in_reserved
ehelin
parents: 34249
diff changeset
   296
  // Returns whether a field is in the same region as the obj it points to.
943740ea0d17 8144072: G1ParScanThreadState::update_rs does not need to call is_in_reserved
ehelin
parents: 34249
diff changeset
   297
  template <typename T>
943740ea0d17 8144072: G1ParScanThreadState::update_rs does not need to call is_in_reserved
ehelin
parents: 34249
diff changeset
   298
  static bool is_in_same_region(T* p, oop obj) {
943740ea0d17 8144072: G1ParScanThreadState::update_rs does not need to call is_in_reserved
ehelin
parents: 34249
diff changeset
   299
    assert(p != NULL, "p can't be NULL");
943740ea0d17 8144072: G1ParScanThreadState::update_rs does not need to call is_in_reserved
ehelin
parents: 34249
diff changeset
   300
    assert(obj != NULL, "obj can't be NULL");
943740ea0d17 8144072: G1ParScanThreadState::update_rs does not need to call is_in_reserved
ehelin
parents: 34249
diff changeset
   301
    return (((uintptr_t) p ^ cast_from_oop<uintptr_t>(obj)) >> LogOfHRGrainBytes) == 0;
943740ea0d17 8144072: G1ParScanThreadState::update_rs does not need to call is_in_reserved
ehelin
parents: 34249
diff changeset
   302
  }
943740ea0d17 8144072: G1ParScanThreadState::update_rs does not need to call is_in_reserved
ehelin
parents: 34249
diff changeset
   303
19986
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents: 19728
diff changeset
   304
  static size_t max_region_size();
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   305
  static size_t min_region_size_in_words();
19986
33d188c66ed9 8010722: assert: failed: heap size is too big for compressed oops
tschatzl
parents: 19728
diff changeset
   306
3697
ea9211aa02f5 6819085: G1: use larger and/or user settable region size
tonyp
parents: 3000
diff changeset
   307
  // It sets up the heap region size (GrainBytes / GrainWords), as
ea9211aa02f5 6819085: G1: use larger and/or user settable region size
tonyp
parents: 3000
diff changeset
   308
  // well as other related fields that are based on the heap region
ea9211aa02f5 6819085: G1: use larger and/or user settable region size
tonyp
parents: 3000
diff changeset
   309
  // size (LogOfHRGrainBytes / LogOfHRGrainWords /
ea9211aa02f5 6819085: G1: use larger and/or user settable region size
tonyp
parents: 3000
diff changeset
   310
  // CardsPerRegion). All those fields are considered constant
ea9211aa02f5 6819085: G1: use larger and/or user settable region size
tonyp
parents: 3000
diff changeset
   311
  // throughout the JVM's execution, therefore they should only be set
ea9211aa02f5 6819085: G1: use larger and/or user settable region size
tonyp
parents: 3000
diff changeset
   312
  // up once during initialization time.
19728
9e1556506d2d 8019902: G1: Use the average heap size rather than the minimum heap size to calculate the region size
brutisso
parents: 19339
diff changeset
   313
  static void setup_heap_region_size(size_t initial_heap_size, size_t max_heap_size);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   314
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25479
diff changeset
   315
  // All allocated blocks are occupied by objects in a HeapRegion
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25479
diff changeset
   316
  bool block_is_obj(const HeapWord* p) const;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25479
diff changeset
   317
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 46307
diff changeset
   318
  // Returns whether the given object is dead based on TAMS and bitmap.
46750
bcab0128a16f 8184346: Clean up G1CMBitmap
tschatzl
parents: 46520
diff changeset
   319
  bool 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: 46307
diff changeset
   320
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25479
diff changeset
   321
  // Returns the object size for all valid block starts
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25479
diff changeset
   322
  // and the amount of unallocated words if called on top()
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25479
diff changeset
   323
  size_t block_size(const HeapWord* p) const;
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25479
diff changeset
   324
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   325
  // Scans through the region using the bitmap to determine what
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   326
  // objects to call size_t ApplyToMarkedClosure::apply(oop) for.
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   327
  template<typename ApplyToMarkedClosure>
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   328
  inline void apply_to_marked_objects(G1CMBitMap* bitmap, ApplyToMarkedClosure* closure);
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   329
  // Update heap region to be consistent after compaction.
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   330
  void complete_compaction();
27624
fe43edc5046d 8043243: convert SCAN_AND_FORWARD, SCAN_AND_ADJUST_POINTERS, SCAN_AND_COMPACT macros to methods
mlarsson
parents: 27009
diff changeset
   331
32389
626f27450e12 8067336: Allow that PLAB allocations at the end of regions are flexible
tschatzl
parents: 32185
diff changeset
   332
  inline HeapWord* par_allocate_no_bot_updates(size_t min_word_size, size_t desired_word_size, size_t* word_size);
25481
1427aa24638c 8047818: G1 HeapRegions can no longer be ContiguousSpaces
mgerdin
parents: 25479
diff changeset
   333
  inline HeapWord* 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
   334
  inline HeapWord* allocate_no_bot_updates(size_t min_word_size, size_t desired_word_size, size_t* actual_size);
7905
cc7740616b03 6994297: G1: do first-level slow-path allocations with a CAS
tonyp
parents: 7904
diff changeset
   335
26316
93f6b40c038b 8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents: 26157
diff changeset
   336
  // If this region is a member of a HeapRegionManager, the index in that
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   337
  // sequence, otherwise -1.
26316
93f6b40c038b 8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents: 26157
diff changeset
   338
  uint hrm_index() const { return _hrm_index; }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   339
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   340
  // The number of bytes marked live in the region in the last marking phase.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   341
  size_t marked_bytes()    { return _prev_marked_bytes; }
8930
52368505ee8e 7027766: G1: introduce flag to dump the liveness information per region at the end of marking
tonyp
parents: 8928
diff changeset
   342
  size_t live_bytes() {
52368505ee8e 7027766: G1: introduce flag to dump the liveness information per region at the end of marking
tonyp
parents: 8928
diff changeset
   343
    return (top() - prev_top_at_mark_start()) * HeapWordSize + marked_bytes();
52368505ee8e 7027766: G1: introduce flag to dump the liveness information per region at the end of marking
tonyp
parents: 8928
diff changeset
   344
  }
52368505ee8e 7027766: G1: introduce flag to dump the liveness information per region at the end of marking
tonyp
parents: 8928
diff changeset
   345
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   346
  // The number of bytes counted in the next marking.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   347
  size_t next_marked_bytes() { return _next_marked_bytes; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   348
  // The number of bytes live wrt the next marking.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   349
  size_t next_live_bytes() {
8930
52368505ee8e 7027766: G1: introduce flag to dump the liveness information per region at the end of marking
tonyp
parents: 8928
diff changeset
   350
    return
52368505ee8e 7027766: G1: introduce flag to dump the liveness information per region at the end of marking
tonyp
parents: 8928
diff changeset
   351
      (top() - next_top_at_mark_start()) * HeapWordSize + next_marked_bytes();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   352
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   353
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   354
  // A lower bound on the amount of garbage bytes in the region.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   355
  size_t garbage_bytes() {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   356
    size_t used_at_mark_start_bytes =
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   357
      (prev_top_at_mark_start() - bottom()) * HeapWordSize;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   358
    return used_at_mark_start_bytes - marked_bytes();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   359
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   360
11756
28b6fe22e43d 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 11583
diff changeset
   361
  // Return the amount of bytes we'll reclaim if we collect this
28b6fe22e43d 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 11583
diff changeset
   362
  // region. This includes not only the known garbage bytes in the
28b6fe22e43d 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 11583
diff changeset
   363
  // region but also any unallocated space in it, i.e., [top, end),
28b6fe22e43d 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 11583
diff changeset
   364
  // since it will also be reclaimed if we collect the region.
28b6fe22e43d 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 11583
diff changeset
   365
  size_t reclaimable_bytes() {
28b6fe22e43d 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 11583
diff changeset
   366
    size_t known_live_bytes = live_bytes();
28b6fe22e43d 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 11583
diff changeset
   367
    assert(known_live_bytes <= capacity(), "sanity");
28b6fe22e43d 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 11583
diff changeset
   368
    return capacity() - known_live_bytes;
28b6fe22e43d 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 11583
diff changeset
   369
  }
28b6fe22e43d 7132029: G1: mixed GC phase lasts for longer than it should
tonyp
parents: 11583
diff changeset
   370
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   371
  // An upper bound on the number of live bytes in the region.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   372
  size_t max_live_bytes() { return used() - garbage_bytes(); }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   373
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   374
  void add_to_marked_bytes(size_t incr_bytes) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   375
    _next_marked_bytes = _next_marked_bytes + incr_bytes;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   376
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   377
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   378
  void zero_marked_bytes()      {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   379
    _prev_marked_bytes = _next_marked_bytes = 0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   380
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   381
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents: 26422
diff changeset
   382
  const char* get_type_str() const { return _type.get_str(); }
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents: 26422
diff changeset
   383
  const char* get_short_type_str() const { return _type.get_short_str(); }
36098
e056a98ac7ca 8149650: Create a trace event for G1 heap region type transitions
david
parents: 35507
diff changeset
   384
  G1HeapRegionTraceType::Type get_trace_type() { return _type.get_trace_type(); }
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents: 26422
diff changeset
   385
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents: 26422
diff changeset
   386
  bool is_free() const { return _type.is_free(); }
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents: 26422
diff changeset
   387
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents: 26422
diff changeset
   388
  bool is_young()    const { return _type.is_young();    }
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents: 26422
diff changeset
   389
  bool is_eden()     const { return _type.is_eden();     }
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents: 26422
diff changeset
   390
  bool is_survivor() const { return _type.is_survivor(); }
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents: 26422
diff changeset
   391
26846
7d4376f8560e 8058495: G1: normalize names for isHumongous() and friends
tonyp
parents: 26839
diff changeset
   392
  bool is_humongous() const { return _type.is_humongous(); }
7d4376f8560e 8058495: G1: normalize names for isHumongous() and friends
tonyp
parents: 26839
diff changeset
   393
  bool is_starts_humongous() const { return _type.is_starts_humongous(); }
7d4376f8560e 8058495: G1: normalize names for isHumongous() and friends
tonyp
parents: 26839
diff changeset
   394
  bool is_continues_humongous() const { return _type.is_continues_humongous();   }
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents: 26422
diff changeset
   395
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents: 26422
diff changeset
   396
  bool is_old() const { return _type.is_old(); }
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents: 26422
diff changeset
   397
42589
037b433e8069 8166811: Missing memory fences between memory allocation and refinement
kbarrett
parents: 42588
diff changeset
   398
  bool is_old_or_humongous() const { return _type.is_old_or_humongous(); }
037b433e8069 8166811: Missing memory fences between memory allocation and refinement
kbarrett
parents: 42588
diff changeset
   399
51494
1906adbef2dc 8208498: Put archive regions into a first-class HeapRegionSet
tschatzl
parents: 50441
diff changeset
   400
  bool is_old_or_humongous_or_archive() const { return _type.is_old_or_humongous_or_archive(); }
1906adbef2dc 8208498: Put archive regions into a first-class HeapRegionSet
tschatzl
parents: 50441
diff changeset
   401
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   402
  // A pinned region contains objects which are not moved by garbage collections.
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   403
  // Humongous regions and archive regions are pinned.
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   404
  bool is_pinned() const { return _type.is_pinned(); }
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   405
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   406
  // An archive region is a pinned region, also tagged as old, which
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   407
  // should not be marked during mark/sweep. This allows the address
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   408
  // space to be shared by JVM instances.
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46750
diff changeset
   409
  bool is_archive()        const { return _type.is_archive(); }
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46750
diff changeset
   410
  bool is_open_archive()   const { return _type.is_open_archive(); }
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46750
diff changeset
   411
  bool is_closed_archive() const { return _type.is_closed_archive(); }
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   412
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   413
  // For a humongous region, region in which it starts.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   414
  HeapRegion* humongous_start_region() const {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   415
    return _humongous_start_region;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   416
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   417
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   418
  // Makes the current region be a "starts humongous" region, i.e.,
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   419
  // the first region in a series of one or more contiguous regions
33786
ac8da6513351 8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents: 33205
diff changeset
   420
  // that will contain a single "humongous" object.
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   421
  //
34249
a015a11067a2 8138681: Runtime.getFreeMemory() reports wrong value after humongous allocation.
david
parents: 33786
diff changeset
   422
  // obj_top : points to the top of the humongous object.
a015a11067a2 8138681: Runtime.getFreeMemory() reports wrong value after humongous allocation.
david
parents: 33786
diff changeset
   423
  // fill_size : size of the filler object at the end of the region series.
a015a11067a2 8138681: Runtime.getFreeMemory() reports wrong value after humongous allocation.
david
parents: 33786
diff changeset
   424
  void set_starts_humongous(HeapWord* obj_top, size_t fill_size);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   425
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   426
  // Makes the current region be a "continues humongous'
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   427
  // region. first_hr is the "start humongous" region of the series
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   428
  // which this region will be part of.
26846
7d4376f8560e 8058495: G1: normalize names for isHumongous() and friends
tonyp
parents: 26839
diff changeset
   429
  void set_continues_humongous(HeapRegion* first_hr);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   430
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   431
  // Unsets the humongous-related fields on the region.
26696
623a25e6c686 8057768: Make heap region region type in G1 HeapRegion explicit
tonyp
parents: 26422
diff changeset
   432
  void clear_humongous();
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   433
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   434
  // If the region has a remembered set, return a pointer to it.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   435
  HeapRegionRemSet* rem_set() const {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   436
    return _rem_set;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   437
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   438
32185
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31592
diff changeset
   439
  inline bool in_collection_set() const;
29470
e34bbcd36e53 8030646: track collection set membership in one place
ehelin
parents: 28207
diff changeset
   440
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   441
  // Methods used by the HeapRegionSetBase class and subclasses.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   442
23471
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23453
diff changeset
   443
  // Getter and setter for the next and prev fields used to link regions into
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   444
  // linked lists.
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   445
  HeapRegion* next()              { return _next; }
23471
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23453
diff changeset
   446
  HeapRegion* prev()              { return _prev; }
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   447
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   448
  void set_next(HeapRegion* next) { _next = next; }
23471
ec9427262f0a 8036025: Sort the freelist in order to shrink the heap
jwilhelm
parents: 23453
diff changeset
   449
  void set_prev(HeapRegion* prev) { _prev = prev; }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   450
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   451
  // Every region added to a set is tagged with a reference to that
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   452
  // set. This is used for doing consistency checking to make sure that
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   453
  // the contents of a set are as they should be and it's only
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   454
  // available in non-product builds.
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   455
#ifdef ASSERT
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   456
  void set_containing_set(HeapRegionSetBase* containing_set) {
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   457
    assert((containing_set == NULL && _containing_set != NULL) ||
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   458
           (containing_set != NULL && _containing_set == NULL),
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32389
diff changeset
   459
           "containing_set: " PTR_FORMAT " "
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32389
diff changeset
   460
           "_containing_set: " PTR_FORMAT,
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32389
diff changeset
   461
           p2i(containing_set), p2i(_containing_set));
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   462
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   463
    _containing_set = containing_set;
8680
f1c414e16a4c 7014923: G1: code cleanup
tonyp
parents: 7923
diff changeset
   464
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   465
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   466
  HeapRegionSetBase* containing_set() { return _containing_set; }
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   467
#else // ASSERT
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   468
  void set_containing_set(HeapRegionSetBase* containing_set) { }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   469
8680
f1c414e16a4c 7014923: G1: code cleanup
tonyp
parents: 7923
diff changeset
   470
  // containing_set() is only used in asserts so there's no reason
7923
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   471
  // to provide a dummy version of it.
fc200fcd4e05 6977804: G1: remove the zero-filling thread
tonyp
parents: 7905
diff changeset
   472
#endif // ASSERT
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   473
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   474
39979
b17e445924da 8034842: Parallelize the Free CSet phase in G1
tschatzl
parents: 39698
diff changeset
   475
  // Reset the HeapRegion to default values.
b17e445924da 8034842: Parallelize the Free CSet phase in G1
tschatzl
parents: 39698
diff changeset
   476
  // If skip_remset is true, do not clear the remembered set.
49632
64f9ebc85e67 8197573: Remove concurrent cleanup and secondary free list handling
tschatzl
parents: 49605
diff changeset
   477
  // If clear_space is true, clear the HeapRegion's memory.
64f9ebc85e67 8197573: Remove concurrent cleanup and secondary free list handling
tschatzl
parents: 49605
diff changeset
   478
  // If locked is true, assume we are the only thread doing this operation.
39979
b17e445924da 8034842: Parallelize the Free CSet phase in G1
tschatzl
parents: 39698
diff changeset
   479
  void hr_clear(bool skip_remset, bool clear_space, bool locked = false);
49632
64f9ebc85e67 8197573: Remove concurrent cleanup and secondary free list handling
tschatzl
parents: 49605
diff changeset
   480
  // Clear the card table corresponding to this region.
64f9ebc85e67 8197573: Remove concurrent cleanup and secondary free list handling
tschatzl
parents: 49605
diff changeset
   481
  void clear_cardtable();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   482
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   483
  // Get the start of the unmarked area in this region.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   484
  HeapWord* prev_top_at_mark_start() const { return _prev_top_at_mark_start; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   485
  HeapWord* next_top_at_mark_start() const { return _next_top_at_mark_start; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   486
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   487
  // Note the start or end of marking. This tells the heap region
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   488
  // that the collector is about to start or has finished (concurrently)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   489
  // marking the heap.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   490
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   491
  // Notify the region that concurrent marking is starting. Initialize
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   492
  // all fields related to the next marking info.
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   493
  inline void note_start_of_marking();
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   494
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   495
  // Notify the region that concurrent marking has finished. Copy the
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   496
  // (now finalized) next marking info fields into the prev marking
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   497
  // info fields.
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   498
  inline void note_end_of_marking();
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   499
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   500
  // Notify the region that we are about to start processing
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   501
  // self-forwarded objects during evac failure handling.
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   502
  void note_self_forwarding_removal_start(bool during_initial_mark,
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   503
                                          bool during_conc_mark);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   504
11455
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   505
  // Notify the region that we have finished processing self-forwarded
a6ab3d8b9a4c 6888336: G1: avoid explicitly marking and pushing objects in survivor spaces
tonyp
parents: 11451
diff changeset
   506
  // objects during evac failure handling.
46258
d26ebd7e2f10 8142749: HeapRegion::_predicted_bytes_to_copy is unused and can be removed
fzhinkin
parents: 42589
diff changeset
   507
  void note_self_forwarding_removal_end(size_t marked_bytes);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   508
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   509
  void reset_during_compaction() {
33786
ac8da6513351 8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents: 33205
diff changeset
   510
    assert(is_humongous(),
ac8da6513351 8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents: 33205
diff changeset
   511
           "should only be called for humongous regions");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   512
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   513
    zero_marked_bytes();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   514
    init_top_at_mark_start();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   515
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   516
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   517
  void calc_gc_efficiency(void);
53703
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents: 53244
diff changeset
   518
  double gc_efficiency() const { return _gc_efficiency;}
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   519
54465
c4f16445675a 8218668: Clean up evacuation of optional collection set
tschatzl
parents: 53703
diff changeset
   520
  uint index_in_opt_cset() const {
c4f16445675a 8218668: Clean up evacuation of optional collection set
tschatzl
parents: 53703
diff changeset
   521
    assert(has_index_in_opt_cset(), "Opt cset index not set.");
c4f16445675a 8218668: Clean up evacuation of optional collection set
tschatzl
parents: 53703
diff changeset
   522
    return _index_in_opt_cset;
c4f16445675a 8218668: Clean up evacuation of optional collection set
tschatzl
parents: 53703
diff changeset
   523
  }
c4f16445675a 8218668: Clean up evacuation of optional collection set
tschatzl
parents: 53703
diff changeset
   524
  bool has_index_in_opt_cset() const { return _index_in_opt_cset != InvalidCSetIndex; }
52897
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52875
diff changeset
   525
  void set_index_in_opt_cset(uint index) { _index_in_opt_cset = index; }
54465
c4f16445675a 8218668: Clean up evacuation of optional collection set
tschatzl
parents: 53703
diff changeset
   526
  void clear_index_in_opt_cset() { _index_in_opt_cset = InvalidCSetIndex; }
52897
495c05ee2a9a 8213890: Implementation of JEP 344: Abortable Mixed Collections for G1
sjohanss
parents: 52875
diff changeset
   527
57802
854e828d6b5b 8227442: Make young_index_in_cset zero-based
tschatzl
parents: 55607
diff changeset
   528
  uint  young_index_in_cset() const { return _young_index_in_cset; }
854e828d6b5b 8227442: Make young_index_in_cset zero-based
tschatzl
parents: 55607
diff changeset
   529
  void clear_young_index_in_cset() { _young_index_in_cset = 0; }
854e828d6b5b 8227442: Make young_index_in_cset zero-based
tschatzl
parents: 55607
diff changeset
   530
  void set_young_index_in_cset(uint index) {
854e828d6b5b 8227442: Make young_index_in_cset zero-based
tschatzl
parents: 55607
diff changeset
   531
    assert(index != UINT_MAX, "just checking");
854e828d6b5b 8227442: Make young_index_in_cset zero-based
tschatzl
parents: 55607
diff changeset
   532
    assert(index != 0, "just checking");
854e828d6b5b 8227442: Make young_index_in_cset zero-based
tschatzl
parents: 55607
diff changeset
   533
    assert(is_young(), "pre-condition");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   534
    _young_index_in_cset = index;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   535
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   536
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   537
  int age_in_surv_rate_group() {
57802
854e828d6b5b 8227442: Make young_index_in_cset zero-based
tschatzl
parents: 55607
diff changeset
   538
    assert(_surv_rate_group != NULL, "pre-condition");
854e828d6b5b 8227442: Make young_index_in_cset zero-based
tschatzl
parents: 55607
diff changeset
   539
    assert(_age_index > -1, "pre-condition");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   540
    return _surv_rate_group->age_in_group(_age_index);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   541
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   542
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   543
  void record_surv_words_in_group(size_t words_survived) {
57802
854e828d6b5b 8227442: Make young_index_in_cset zero-based
tschatzl
parents: 55607
diff changeset
   544
    assert(_surv_rate_group != NULL, "pre-condition");
854e828d6b5b 8227442: Make young_index_in_cset zero-based
tschatzl
parents: 55607
diff changeset
   545
    assert(_age_index > -1, "pre-condition");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   546
    int age_in_group = age_in_surv_rate_group();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   547
    _surv_rate_group->record_surviving_words(age_in_group, words_survived);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   548
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   549
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   550
  int age_in_surv_rate_group_cond() {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   551
    if (_surv_rate_group != NULL)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   552
      return age_in_surv_rate_group();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   553
    else
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   554
      return -1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   555
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   556
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   557
  SurvRateGroup* surv_rate_group() {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   558
    return _surv_rate_group;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   559
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   560
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   561
  void install_surv_rate_group(SurvRateGroup* surv_rate_group) {
57802
854e828d6b5b 8227442: Make young_index_in_cset zero-based
tschatzl
parents: 55607
diff changeset
   562
    assert(surv_rate_group != NULL, "pre-condition");
854e828d6b5b 8227442: Make young_index_in_cset zero-based
tschatzl
parents: 55607
diff changeset
   563
    assert(_surv_rate_group == NULL, "pre-condition");
854e828d6b5b 8227442: Make young_index_in_cset zero-based
tschatzl
parents: 55607
diff changeset
   564
    assert(is_young(), "pre-condition");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   565
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   566
    _surv_rate_group = surv_rate_group;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   567
    _age_index = surv_rate_group->next_age_index();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   568
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   569
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   570
  void uninstall_surv_rate_group() {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   571
    if (_surv_rate_group != NULL) {
57802
854e828d6b5b 8227442: Make young_index_in_cset zero-based
tschatzl
parents: 55607
diff changeset
   572
      assert(_age_index > -1, "pre-condition");
854e828d6b5b 8227442: Make young_index_in_cset zero-based
tschatzl
parents: 55607
diff changeset
   573
      assert(is_young(), "pre-condition");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   574
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   575
      _surv_rate_group = NULL;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   576
      _age_index = -1;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   577
    } else {
57802
854e828d6b5b 8227442: Make young_index_in_cset zero-based
tschatzl
parents: 55607
diff changeset
   578
      assert(_age_index == -1, "pre-condition");
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   579
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   580
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   581
36098
e056a98ac7ca 8149650: Create a trace event for G1 heap region type transitions
david
parents: 35507
diff changeset
   582
  void set_free();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   583
36098
e056a98ac7ca 8149650: Create a trace event for G1 heap region type transitions
david
parents: 35507
diff changeset
   584
  void set_eden();
e056a98ac7ca 8149650: Create a trace event for G1 heap region type transitions
david
parents: 35507
diff changeset
   585
  void set_eden_pre_gc();
e056a98ac7ca 8149650: Create a trace event for G1 heap region type transitions
david
parents: 35507
diff changeset
   586
  void set_survivor();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   587
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46750
diff changeset
   588
  void move_to_old();
36098
e056a98ac7ca 8149650: Create a trace event for G1 heap region type transitions
david
parents: 35507
diff changeset
   589
  void set_old();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   590
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46750
diff changeset
   591
  void set_open_archive();
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46750
diff changeset
   592
  void set_closed_archive();
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   593
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   594
  // Determine if an object has been allocated since the last
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   595
  // mark performed by the collector. This returns true iff the object
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   596
  // is within the unmarked area of the region.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   597
  bool obj_allocated_since_prev_marking(oop obj) const {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   598
    return (HeapWord *) obj >= prev_top_at_mark_start();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   599
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   600
  bool obj_allocated_since_next_marking(oop obj) const {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   601
    return (HeapWord *) obj >= next_top_at_mark_start();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   602
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   603
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   604
  // Returns the "evacuation_failed" property of the region.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   605
  bool evacuation_failed() { return _evacuation_failed; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   606
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   607
  // Sets the "evacuation_failed" property of the region.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   608
  void set_evacuation_failed(bool b) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   609
    _evacuation_failed = b;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   610
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   611
    if (b) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   612
      _next_marked_bytes = 0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   613
    }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   614
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   615
55607
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 55510
diff changeset
   616
  // Iterate over the objects overlapping the given memory region, applying cl
42589
037b433e8069 8166811: Missing memory fences between memory allocation and refinement
kbarrett
parents: 42588
diff changeset
   617
  // to all references in the region.  This is a helper for
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 46307
diff changeset
   618
  // G1RemSet::refine_card*, and is tightly coupled with them.
55607
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 55510
diff changeset
   619
  // mr must not be empty. Must be trimmed to the allocated/parseable space in this region.
42589
037b433e8069 8166811: Missing memory fences between memory allocation and refinement
kbarrett
parents: 42588
diff changeset
   620
  // This region must be old or humongous.
55607
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 55510
diff changeset
   621
  // Returns the next unscanned address if the designated objects were successfully
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 55510
diff changeset
   622
  // processed, NULL if an unparseable part of the heap was encountered (That should
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 55510
diff changeset
   623
  // only happen when invoked concurrently with the mutator).
46517
14de3e5151a9 8071280: Specialize HeapRegion::oops_on_card_seq_iterate_careful() for use during concurrent refinement and updating the rset
tschatzl
parents: 46307
diff changeset
   624
  template <bool is_gc_active, class Closure>
55607
5919b273def6 8224741: Optimize the scan area during the Scan Heap Roots phase
tschatzl
parents: 55510
diff changeset
   625
  inline HeapWord* oops_on_memregion_seq_iterate_careful(MemRegion mr, Closure* cl);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   626
5350
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 4024
diff changeset
   627
  size_t recorded_rs_length() const        { return _recorded_rs_length; }
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 4024
diff changeset
   628
  double predicted_elapsed_time_ms() const { return _predicted_elapsed_time_ms; }
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 4024
diff changeset
   629
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 4024
diff changeset
   630
  void set_recorded_rs_length(size_t rs_length) {
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 4024
diff changeset
   631
    _recorded_rs_length = rs_length;
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 4024
diff changeset
   632
  }
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 4024
diff changeset
   633
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 4024
diff changeset
   634
  void set_predicted_elapsed_time_ms(double ms) {
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 4024
diff changeset
   635
    _predicted_elapsed_time_ms = ms;
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 4024
diff changeset
   636
  }
cccf0925702e 6819061: G1: eliminate serial Other times that are proportional to the collection set length
johnc
parents: 4024
diff changeset
   637
19339
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 15482
diff changeset
   638
  // Routines for managing a list of code roots (attached to the
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 15482
diff changeset
   639
  // this region's RSet) that point into this heap region.
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 15482
diff changeset
   640
  void add_strong_code_root(nmethod* nm);
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 26327
diff changeset
   641
  void add_strong_code_root_locked(nmethod* nm);
19339
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 15482
diff changeset
   642
  void remove_strong_code_root(nmethod* nm);
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 15482
diff changeset
   643
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 15482
diff changeset
   644
  // Applies blk->do_code_blob() to each of the entries in
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 15482
diff changeset
   645
  // the strong code roots list for this region
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 15482
diff changeset
   646
  void strong_code_roots_do(CodeBlobClosure* blk) const;
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 15482
diff changeset
   647
59060
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 58980
diff changeset
   648
  uint node_index() const { return _node_index; }
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 58980
diff changeset
   649
  void set_node_index(uint node_index) { _node_index = node_index; }
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 58980
diff changeset
   650
19339
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 15482
diff changeset
   651
  // Verify that the entries on the strong code root list for this
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 15482
diff changeset
   652
  // region are live and include at least one pointer into this region.
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 15482
diff changeset
   653
  void verify_strong_code_roots(VerifyOption vo, bool* failures) const;
d247781beec7 7145569: G1: optimize nmethods scanning
johnc
parents: 15482
diff changeset
   654
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   655
  void print() const;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   656
  void print_on(outputStream* st) const;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   657
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   658
  // vo == UsePrevMarking -> use "prev" marking information,
9995
290620c08233 7004681: G1: Extend marking verification to Full GCs
johnc
parents: 9989
diff changeset
   659
  // vo == UseNextMarking -> use "next" marking information
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   660
  // vo == UseFullMarking -> use "next" marking bitmap but no TAMS
9995
290620c08233 7004681: G1: Extend marking verification to Full GCs
johnc
parents: 9989
diff changeset
   661
  //
3000
bbce6052b595 6850846: G1: extend G1 marking verification
tonyp
parents: 2883
diff changeset
   662
  // NOTE: Only the "prev" marking information is guaranteed to be
bbce6052b595 6850846: G1: extend G1 marking verification
tonyp
parents: 2883
diff changeset
   663
  // consistent most of the time, so most calls to this should use
9995
290620c08233 7004681: G1: Extend marking verification to Full GCs
johnc
parents: 9989
diff changeset
   664
  // vo == UsePrevMarking.
290620c08233 7004681: G1: Extend marking verification to Full GCs
johnc
parents: 9989
diff changeset
   665
  // Currently, there is only one case where this is called with
290620c08233 7004681: G1: Extend marking verification to Full GCs
johnc
parents: 9989
diff changeset
   666
  // vo == UseNextMarking, which is to verify the "next" marking
290620c08233 7004681: G1: Extend marking verification to Full GCs
johnc
parents: 9989
diff changeset
   667
  // information at the end of remark.
290620c08233 7004681: G1: Extend marking verification to Full GCs
johnc
parents: 9989
diff changeset
   668
  // Currently there is only one place where this is called with
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   669
  // vo == UseFullMarking, which is to verify the marking during a
9995
290620c08233 7004681: G1: Extend marking verification to Full GCs
johnc
parents: 9989
diff changeset
   670
  // full GC.
12379
2cf45b79ce3a 4988100: oop_verify_old_oop appears to be dead
brutisso
parents: 12272
diff changeset
   671
  void verify(VerifyOption vo, bool *failures) const;
3000
bbce6052b595 6850846: G1: extend G1 marking verification
tonyp
parents: 2883
diff changeset
   672
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   673
  // Verify using the "prev" marking information
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   674
  void verify() const;
35507
aa2affc60a2f 8145442: Add the facility to verify remembered sets for G1
poonam
parents: 35461
diff changeset
   675
aa2affc60a2f 8145442: Add the facility to verify remembered sets for G1
poonam
parents: 35461
diff changeset
   676
  void verify_rem_set(VerifyOption vo, bool *failures) const;
aa2affc60a2f 8145442: Add the facility to verify remembered sets for G1
poonam
parents: 35461
diff changeset
   677
  void verify_rem_set() const;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   678
};
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   679
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   680
// HeapRegionClosure is used for iterating over regions.
48969
jwilhelm
parents: 48890
diff changeset
   681
// Terminates the iteration when the "do_heap_region" method returns "true".
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   682
class HeapRegionClosure : public StackObj {
26316
93f6b40c038b 8054819: Rename HeapRegionSeq to HeapRegionManager
tschatzl
parents: 26157
diff changeset
   683
  friend class HeapRegionManager;
39698
4016de4e596b 8159978: Use an array to store the collection set regions instead of linking through regions
tschatzl
parents: 38183
diff changeset
   684
  friend class G1CollectionSet;
53703
24341625d8f2 8217330: Split G1CollectionSetChooser into collection set candidate container and the chooser algorithm
tschatzl
parents: 53244
diff changeset
   685
  friend class G1CollectionSetCandidates;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   686
48969
jwilhelm
parents: 48890
diff changeset
   687
  bool _is_complete;
jwilhelm
parents: 48890
diff changeset
   688
  void set_incomplete() { _is_complete = false; }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   689
58980
47c20fc6a517 8189737: Make HeapRegion not derive from Space
tschatzl
parents: 57802
diff changeset
   690
public:
48969
jwilhelm
parents: 48890
diff changeset
   691
  HeapRegionClosure(): _is_complete(true) {}
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   692
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   693
  // Typically called on each region until it returns true.
48969
jwilhelm
parents: 48890
diff changeset
   694
  virtual bool do_heap_region(HeapRegion* r) = 0;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   695
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   696
  // True after iteration if the closure was applied to all heap regions
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   697
  // and returned "false" in all cases.
48969
jwilhelm
parents: 48890
diff changeset
   698
  bool is_complete() { return _is_complete; }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   699
};
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   700
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52897
diff changeset
   701
#endif // SHARE_GC_G1_HEAPREGION_HPP