src/hotspot/share/gc/g1/g1Allocator.hpp
author sangheki
Wed, 13 Nov 2019 10:49:32 -0800
changeset 59061 df6f2350edfa
parent 59060 fce1fa1bdc91
permissions -rw-r--r--
8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3) Reviewed-by: kbarrett, sjohanss, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52674
diff changeset
     2
 * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
     4
 *
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
     7
 * published by the Free Software Foundation.
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
     8
 *
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    13
 * accompanied this code).
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    14
 *
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    18
 *
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    21
 * questions.
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    22
 *
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    23
 */
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52674
diff changeset
    25
#ifndef SHARE_GC_G1_G1ALLOCATOR_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52674
diff changeset
    26
#define SHARE_GC_G1_G1ALLOCATOR_HPP
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30586
diff changeset
    28
#include "gc/g1/g1AllocRegion.hpp"
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 53846
diff changeset
    29
#include "gc/g1/g1HeapRegionAttr.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30586
diff changeset
    30
#include "gc/shared/collectedHeap.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30586
diff changeset
    31
#include "gc/shared/plab.hpp"
30175
543725014c9d 8076457: Fix includes of inline.hpp in GC code
stefank
parents: 29327
diff changeset
    32
53411
aa87f38fcba2 8217374: Rename G1 EvacuationInfo class to G1EvacuationInfo
tschatzl
parents: 53244
diff changeset
    33
class G1EvacuationInfo;
59060
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 54843
diff changeset
    34
class G1NUMA;
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    35
32185
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31975
diff changeset
    36
// Interface to keep track of which regions G1 is currently allocating into. Provides
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31975
diff changeset
    37
// some accessors (e.g. allocating into them, or getting their occupancy).
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31975
diff changeset
    38
// Also keeps track of retained regions across GCs.
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    39
class G1Allocator : public CHeapObj<mtGC> {
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    40
  friend class VMStructs;
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    41
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    42
private:
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    43
  G1CollectedHeap* _g1h;
59060
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 54843
diff changeset
    44
  G1NUMA* _numa;
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    45
34146
42523f0da397 8141280: G1ResManAllocator doesn't work with _survivor_is_full/_old_is_full
sjohanss
parents: 33105
diff changeset
    46
  bool _survivor_is_full;
42523f0da397 8141280: G1ResManAllocator doesn't work with _survivor_is_full/_old_is_full
sjohanss
parents: 33105
diff changeset
    47
  bool _old_is_full;
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    48
59060
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 54843
diff changeset
    49
  // The number of MutatorAllocRegions used, one per memory node.
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 54843
diff changeset
    50
  size_t _num_alloc_regions;
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 54843
diff changeset
    51
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    52
  // Alloc region used to satisfy mutator allocation requests.
59060
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 54843
diff changeset
    53
  MutatorAllocRegion* _mutator_alloc_regions;
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    54
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    55
  // Alloc region used to satisfy allocation requests by the GC for
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    56
  // survivor objects.
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    57
  SurvivorGCAllocRegion* _survivor_gc_alloc_regions;
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    58
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    59
  // Alloc region used to satisfy allocation requests by the GC for
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    60
  // old objects.
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    61
  OldGCAllocRegion _old_gc_alloc_region;
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    62
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    63
  HeapRegion* _retained_old_gc_alloc_region;
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    64
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    65
  bool survivor_is_full() const;
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    66
  bool old_is_full() const;
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    67
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    68
  void set_survivor_full();
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    69
  void set_old_full();
34146
42523f0da397 8141280: G1ResManAllocator doesn't work with _survivor_is_full/_old_is_full
sjohanss
parents: 33105
diff changeset
    70
53411
aa87f38fcba2 8217374: Rename G1 EvacuationInfo class to G1EvacuationInfo
tschatzl
parents: 53244
diff changeset
    71
  void reuse_retained_old_region(G1EvacuationInfo& evacuation_info,
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    72
                                 OldGCAllocRegion* old,
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    73
                                 HeapRegion** retained);
34146
42523f0da397 8141280: G1ResManAllocator doesn't work with _survivor_is_full/_old_is_full
sjohanss
parents: 33105
diff changeset
    74
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    75
  // Accessors to the allocation regions.
59060
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 54843
diff changeset
    76
  inline MutatorAllocRegion* mutator_alloc_region(uint node_index);
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    77
  inline SurvivorGCAllocRegion* survivor_gc_alloc_region(uint node_index);
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    78
  inline OldGCAllocRegion* old_gc_alloc_region();
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    79
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    80
  // Allocation attempt during GC for a survivor object / PLAB.
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    81
  HeapWord* survivor_attempt_allocation(size_t min_word_size,
59060
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 54843
diff changeset
    82
                                        size_t desired_word_size,
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    83
                                        size_t* actual_word_size,
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    84
                                        uint node_index);
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    85
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    86
  // Allocation attempt during GC for an old object / PLAB.
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    87
  HeapWord* old_attempt_allocation(size_t min_word_size,
59060
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 54843
diff changeset
    88
                                   size_t desired_word_size,
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 54843
diff changeset
    89
                                   size_t* actual_word_size);
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 54843
diff changeset
    90
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 54843
diff changeset
    91
  // Node index of current thread.
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 54843
diff changeset
    92
  inline uint current_node_index() const;
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 54843
diff changeset
    93
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    94
public:
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    95
  G1Allocator(G1CollectedHeap* heap);
59060
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 54843
diff changeset
    96
  ~G1Allocator();
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
    97
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    98
  uint num_nodes() { return (uint)_num_alloc_regions; }
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    99
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   100
#ifdef ASSERT
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   101
  // Do we currently have an active mutator region to allocate into?
59060
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 54843
diff changeset
   102
  bool has_mutator_alloc_region();
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   103
#endif
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
   104
59060
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 54843
diff changeset
   105
  void init_mutator_alloc_regions();
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 54843
diff changeset
   106
  void release_mutator_alloc_regions();
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
   107
53411
aa87f38fcba2 8217374: Rename G1 EvacuationInfo class to G1EvacuationInfo
tschatzl
parents: 53244
diff changeset
   108
  void init_gc_alloc_regions(G1EvacuationInfo& evacuation_info);
aa87f38fcba2 8217374: Rename G1 EvacuationInfo class to G1EvacuationInfo
tschatzl
parents: 53244
diff changeset
   109
  void release_gc_alloc_regions(G1EvacuationInfo& evacuation_info);
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   110
  void abandon_gc_alloc_regions();
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   111
  bool is_retained_old_region(HeapRegion* hr);
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   112
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   113
  // Allocate blocks of memory during mutator time.
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
   114
49945
9425445633cf 8191471: Elastic TLABs for G1
sjohanss
parents: 49713
diff changeset
   115
  inline HeapWord* attempt_allocation(size_t min_word_size,
9425445633cf 8191471: Elastic TLABs for G1
sjohanss
parents: 49713
diff changeset
   116
                                      size_t desired_word_size,
9425445633cf 8191471: Elastic TLABs for G1
sjohanss
parents: 49713
diff changeset
   117
                                      size_t* actual_word_size);
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   118
  inline HeapWord* attempt_allocation_locked(size_t word_size);
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   119
  inline HeapWord* attempt_allocation_force(size_t word_size);
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   120
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   121
  size_t unsafe_max_tlab_alloc();
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   122
  size_t used_in_alloc_regions();
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
   123
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   124
  // Allocate blocks of memory during garbage collection. Will ensure an
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   125
  // allocation region, either by picking one or expanding the
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   126
  // heap, and then allocate a block of the given size. The block
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   127
  // may not be a humongous - it must fit into a single heap region.
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 53846
diff changeset
   128
  HeapWord* par_allocate_during_gc(G1HeapRegionAttr dest,
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   129
                                   size_t word_size,
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   130
                                   uint node_index);
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   131
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 53846
diff changeset
   132
  HeapWord* par_allocate_during_gc(G1HeapRegionAttr dest,
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   133
                                   size_t min_word_size,
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   134
                                   size_t desired_word_size,
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   135
                                   size_t* actual_word_size,
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   136
                                   uint node_index);
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
   137
};
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
   138
32185
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31975
diff changeset
   139
// Manages the PLABs used during garbage collection. Interface for allocation from PLABs.
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31975
diff changeset
   140
// Needs to handle multiple contexts, extra alignment in any "survivor" area and some
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31975
diff changeset
   141
// statistics.
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31975
diff changeset
   142
class G1PLABAllocator : public CHeapObj<mtGC> {
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
   143
  friend class G1ParScanThreadState;
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   144
private:
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   145
  typedef G1HeapRegionAttr::region_type_t region_type_t;
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   146
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
   147
  G1CollectedHeap* _g1h;
32185
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31975
diff changeset
   148
  G1Allocator* _allocator;
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
   149
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   150
  PLAB** _alloc_buffers[G1HeapRegionAttr::Num];
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   151
28213
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 26839
diff changeset
   152
  // The survivor alignment in effect in bytes.
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 26839
diff changeset
   153
  // == 0 : don't align survivors
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 26839
diff changeset
   154
  // != 0 : align survivors to that alignment
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 26839
diff changeset
   155
  // These values were chosen to favor the non-alignment case since some
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 26839
diff changeset
   156
  // architectures have a special compare against zero instructions.
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 26839
diff changeset
   157
  const uint _survivor_alignment_bytes;
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 26839
diff changeset
   158
32379
aa14adafaf0f 8073013: Add detailed information about PLAB memory usage
tschatzl
parents: 32378
diff changeset
   159
  // Number of words allocated directly (not counting PLAB allocation).
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 53846
diff changeset
   160
  size_t _direct_allocated[G1HeapRegionAttr::Num];
32379
aa14adafaf0f 8073013: Add detailed information about PLAB memory usage
tschatzl
parents: 32378
diff changeset
   161
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   162
  void flush_and_retire_stats();
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   163
  inline PLAB* alloc_buffer(G1HeapRegionAttr dest, uint node_index) const;
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   164
  inline PLAB* alloc_buffer(region_type_t dest, uint node_index) const;
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   165
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   166
  // Returns the number of allocation buffers for the given dest.
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   167
  // There is only 1 buffer for Old while Young may have multiple buffers depending on
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   168
  // active NUMA nodes.
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   169
  inline uint alloc_buffers_length(region_type_t dest) const;
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
   170
28213
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 26839
diff changeset
   171
  // Calculate the survivor space object alignment in bytes. Returns that or 0 if
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 26839
diff changeset
   172
  // there are no restrictions on survivor alignment.
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   173
  static uint calc_survivor_alignment_bytes();
32377
5ee15c417d02 8003237: G1: Reduce unnecessary (and failing) allocation attempts when handling an evacuation failure
tschatzl
parents: 32185
diff changeset
   174
32383
bc9971c6bf2b 8067339: PLAB reallocation might result in failure to allocate object in that recently allocated PLAB
tschatzl
parents: 32379
diff changeset
   175
  bool may_throw_away_buffer(size_t const allocation_word_sz, size_t const buffer_size) const;
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
   176
public:
32185
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents: 31975
diff changeset
   177
  G1PLABAllocator(G1Allocator* allocator);
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   178
  ~G1PLABAllocator();
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
   179
53846
fe95464806a7 8219096: Merge print_termination_stats code with current logging
tschatzl
parents: 53411
diff changeset
   180
  size_t waste() const;
fe95464806a7 8219096: Merge print_termination_stats code with current logging
tschatzl
parents: 53411
diff changeset
   181
  size_t undo_waste() const;
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
   182
28213
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 26839
diff changeset
   183
  // Allocate word_sz words in dest, either directly into the regions or by
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 26839
diff changeset
   184
  // allocating a new PLAB. Returns the address of the allocated memory, NULL if
32377
5ee15c417d02 8003237: G1: Reduce unnecessary (and failing) allocation attempts when handling an evacuation failure
tschatzl
parents: 32185
diff changeset
   185
  // not successful. Plab_refill_failed indicates whether an attempt to refill the
5ee15c417d02 8003237: G1: Reduce unnecessary (and failing) allocation attempts when handling an evacuation failure
tschatzl
parents: 32185
diff changeset
   186
  // PLAB failed or not.
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 53846
diff changeset
   187
  HeapWord* allocate_direct_or_new_plab(G1HeapRegionAttr dest,
28213
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 26839
diff changeset
   188
                                        size_t word_sz,
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   189
                                        bool* plab_refill_failed,
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   190
                                        uint node_index);
28213
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 26839
diff changeset
   191
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 26839
diff changeset
   192
  // Allocate word_sz words in the PLAB of dest.  Returns the address of the
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 26839
diff changeset
   193
  // allocated memory, NULL if not successful.
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 53846
diff changeset
   194
  inline HeapWord* plab_allocate(G1HeapRegionAttr dest,
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   195
                                 size_t word_sz,
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   196
                                 uint node_index);
28213
b0bf57cd1e9d 8060025: Object copy time regressions after JDK-8031323 and JDK-8057536
tschatzl
parents: 26839
diff changeset
   197
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 53846
diff changeset
   198
  inline HeapWord* allocate(G1HeapRegionAttr dest,
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   199
                            size_t word_sz,
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   200
                            bool* refill_failed,
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   201
                            uint node_index);
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
   202
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   203
  void undo_allocation(G1HeapRegionAttr dest, HeapWord* obj, size_t word_sz, uint node_index);
26837
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
   204
};
72a43d3841e7 8057536: Refactor G1 to allow context specific allocations
sjohanss
parents:
diff changeset
   205
46285
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 34146
diff changeset
   206
// G1ArchiveRegionMap is a boolean array used to mark G1 regions as
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 34146
diff changeset
   207
// archive regions.  This allows a quick check for whether an object
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 34146
diff changeset
   208
// should not be marked because it is in an archive region.
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 34146
diff changeset
   209
class G1ArchiveRegionMap : public G1BiasedMappedArray<bool> {
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 34146
diff changeset
   210
protected:
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 34146
diff changeset
   211
  bool default_value() const { return false; }
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 34146
diff changeset
   212
};
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 34146
diff changeset
   213
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   214
// G1ArchiveAllocator is used to allocate memory in archive
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   215
// regions. Such regions are not scavenged nor compacted by GC.
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   216
// There are two types of archive regions, which are
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   217
// differ in the kind of references allowed for the contained objects:
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   218
//
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   219
// - 'Closed' archive region contain no references outside of other
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   220
//   closed archive regions. The region is immutable by GC. GC does
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   221
//   not mark object header in 'closed' archive region.
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   222
// - An 'open' archive region allow references to any other regions,
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   223
//   including closed archive, open archive and other java heap regions.
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   224
//   GC can adjust pointers and mark object header in 'open' archive region.
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   225
class G1ArchiveAllocator : public CHeapObj<mtGC> {
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   226
protected:
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   227
  bool _open; // Indicate if the region is 'open' archive.
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   228
  G1CollectedHeap* _g1h;
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   229
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   230
  // The current allocation region
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   231
  HeapRegion* _allocation_region;
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   232
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   233
  // Regions allocated for the current archive range.
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   234
  GrowableArray<HeapRegion*> _allocated_regions;
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   235
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   236
  // The number of bytes used in the current range.
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   237
  size_t _summary_bytes_used;
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   238
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   239
  // Current allocation window within the current region.
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   240
  HeapWord* _bottom;
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   241
  HeapWord* _top;
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   242
  HeapWord* _max;
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   243
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   244
  // Allocate a new region for this archive allocator.
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   245
  // Allocation is from the top of the reserved heap downward.
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   246
  bool alloc_new_region();
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   247
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   248
public:
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   249
  G1ArchiveAllocator(G1CollectedHeap* g1h, bool open) :
51332
c25572739e7c 8208669: GC changes to allow enabling -Wreorder
tschatzl
parents: 49945
diff changeset
   250
    _open(open),
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   251
    _g1h(g1h),
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   252
    _allocation_region(NULL),
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   253
    _allocated_regions((ResourceObj::set_allocation_type((address) &_allocated_regions,
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   254
                                                         ResourceObj::C_HEAP),
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   255
                        2), true /* C_Heap */),
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   256
    _summary_bytes_used(0),
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   257
    _bottom(NULL),
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   258
    _top(NULL),
51332
c25572739e7c 8208669: GC changes to allow enabling -Wreorder
tschatzl
parents: 49945
diff changeset
   259
    _max(NULL) { }
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   260
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   261
  virtual ~G1ArchiveAllocator() {
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   262
    assert(_allocation_region == NULL, "_allocation_region not NULL");
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   263
  }
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   264
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   265
  static G1ArchiveAllocator* create_allocator(G1CollectedHeap* g1h, bool open);
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   266
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   267
  // Allocate memory for an individual object.
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   268
  HeapWord* archive_mem_allocate(size_t word_size);
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   269
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   270
  // Return the memory ranges used in the current archive, after
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   271
  // aligning to the requested alignment.
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   272
  void complete_archive(GrowableArray<MemRegion>* ranges,
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   273
                        size_t end_alignment_in_bytes);
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   274
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   275
  // The number of bytes allocated by this allocator.
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   276
  size_t used() {
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   277
    return _summary_bytes_used;
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   278
  }
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   279
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   280
  // Clear the count of bytes allocated in prior G1 regions. This
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   281
  // must be done when recalculate_use is used to reset the counter
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   282
  // for the generic allocator, since it counts bytes in all G1
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   283
  // regions, including those still associated with this allocator.
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   284
  void clear_used() {
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   285
    _summary_bytes_used = 0;
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   286
  }
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   287
46285
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 34146
diff changeset
   288
  // Create the _archive_region_map which is used to identify archive objects.
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 34146
diff changeset
   289
  static inline void enable_archive_object_check();
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 34146
diff changeset
   290
52674
c9325aa887da 8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents: 52062
diff changeset
   291
  // Mark regions containing the specified address range as archive/non-archive.
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   292
  static inline void set_range_archive(MemRegion range, bool open);
52674
c9325aa887da 8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents: 52062
diff changeset
   293
  static inline void clear_range_archive(MemRegion range, bool open);
46285
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 34146
diff changeset
   294
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   295
  // Check if the object is in closed archive
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   296
  static inline bool is_closed_archive_object(oop object);
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   297
  // Check if the object is in open archive
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   298
  static inline bool is_open_archive_object(oop object);
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   299
  // Check if the object is either in closed archive or open archive
52062
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 51332
diff changeset
   300
  static inline bool is_archived_object(oop object);
46285
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 34146
diff changeset
   301
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 34146
diff changeset
   302
private:
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 34146
diff changeset
   303
  static bool _archive_check_enabled;
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   304
  static G1ArchiveRegionMap  _closed_archive_region_map;
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   305
  static G1ArchiveRegionMap  _open_archive_region_map;
46285
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 34146
diff changeset
   306
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   307
  // Check if an object is in a closed archive region using the _closed_archive_region_map.
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   308
  static inline bool in_closed_archive_range(oop object);
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   309
  // Check if an object is in open archive region using the _open_archive_region_map.
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   310
  static inline bool in_open_archive_range(oop object);
46285
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 34146
diff changeset
   311
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   312
  // Check if archive object checking is enabled, to avoid calling in_open/closed_archive_range
46285
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 34146
diff changeset
   313
  // unnecessarily.
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 34146
diff changeset
   314
  static inline bool archive_check_enabled();
31346
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   315
};
a70d45c06136 8042668: GC Support for shared heap ranges in CDS
jiangli
parents: 30764
diff changeset
   316
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 52674
diff changeset
   317
#endif // SHARE_GC_G1_G1ALLOCATOR_HPP