src/hotspot/share/gc/g1/g1Allocator.inline.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:
32185
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53116
diff changeset
     2
 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
32185
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
     4
 *
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
     8
 *
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    14
 *
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    18
 *
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    21
 * questions.
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    22
 *
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    23
 */
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53116
diff changeset
    25
#ifndef SHARE_GC_G1_G1ALLOCATOR_INLINE_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53116
diff changeset
    26
#define SHARE_GC_G1_G1ALLOCATOR_INLINE_HPP
32185
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    27
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    28
#include "gc/g1/g1Allocator.hpp"
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    29
#include "gc/g1/g1AllocRegion.inline.hpp"
32378
8dd0e7359751 8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents: 32185
diff changeset
    30
#include "gc/shared/plab.inline.hpp"
54786
ebf733a324d4 8223624: Cleanup includes of universe.hpp
stefank
parents: 53244
diff changeset
    31
#include "memory/universe.hpp"
32185
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    32
59060
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 58015
diff changeset
    33
inline uint G1Allocator::current_node_index() const {
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 58015
diff changeset
    34
  return _numa->index_of_current_thread();
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 58015
diff changeset
    35
}
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 58015
diff changeset
    36
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 58015
diff changeset
    37
inline MutatorAllocRegion* G1Allocator::mutator_alloc_region(uint node_index) {
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 58015
diff changeset
    38
  assert(node_index < _num_alloc_regions, "Invalid index: %u", node_index);
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 58015
diff changeset
    39
  return &_mutator_alloc_regions[node_index];
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    40
}
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    41
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    42
inline SurvivorGCAllocRegion* G1Allocator::survivor_gc_alloc_region(uint node_index) {
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    43
  assert(node_index < _num_alloc_regions, "Invalid index: %u", node_index);
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    44
  return &_survivor_gc_alloc_regions[node_index];
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    45
}
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    46
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    47
inline OldGCAllocRegion* G1Allocator::old_gc_alloc_region() {
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    48
  return &_old_gc_alloc_region;
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    49
}
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    50
49945
9425445633cf 8191471: Elastic TLABs for G1
sjohanss
parents: 49713
diff changeset
    51
inline HeapWord* G1Allocator::attempt_allocation(size_t min_word_size,
9425445633cf 8191471: Elastic TLABs for G1
sjohanss
parents: 49713
diff changeset
    52
                                                 size_t desired_word_size,
9425445633cf 8191471: Elastic TLABs for G1
sjohanss
parents: 49713
diff changeset
    53
                                                 size_t* actual_word_size) {
59060
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 58015
diff changeset
    54
  uint node_index = current_node_index();
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 58015
diff changeset
    55
  HeapWord* result = mutator_alloc_region(node_index)->attempt_retained_allocation(min_word_size, desired_word_size, actual_word_size);
49945
9425445633cf 8191471: Elastic TLABs for G1
sjohanss
parents: 49713
diff changeset
    56
  if (result != NULL) {
9425445633cf 8191471: Elastic TLABs for G1
sjohanss
parents: 49713
diff changeset
    57
    return result;
9425445633cf 8191471: Elastic TLABs for G1
sjohanss
parents: 49713
diff changeset
    58
  }
59060
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 58015
diff changeset
    59
  return mutator_alloc_region(node_index)->attempt_allocation(min_word_size, desired_word_size, actual_word_size);
32185
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    60
}
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    61
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    62
inline HeapWord* G1Allocator::attempt_allocation_locked(size_t word_size) {
59060
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 58015
diff changeset
    63
  uint node_index = current_node_index();
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 58015
diff changeset
    64
  HeapWord* result = mutator_alloc_region(node_index)->attempt_allocation_locked(word_size);
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 58015
diff changeset
    65
  assert(result != NULL || mutator_alloc_region(node_index)->get() == NULL,
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 58015
diff changeset
    66
         "Must not have a mutator alloc region if there is no memory, but is " PTR_FORMAT, p2i(mutator_alloc_region(node_index)->get()));
32185
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    67
  return result;
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    68
}
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    69
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    70
inline HeapWord* G1Allocator::attempt_allocation_force(size_t word_size) {
59060
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 58015
diff changeset
    71
  uint node_index = current_node_index();
fce1fa1bdc91 8220310: Implementation: NUMA-Aware Memory Allocation for G1, Mutator (1/3)
sangheki
parents: 58015
diff changeset
    72
  return mutator_alloc_region(node_index)->attempt_allocation_force(word_size);
32185
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    73
}
49a57ff2c3cb 8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff changeset
    74
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    75
inline PLAB* G1PLABAllocator::alloc_buffer(G1HeapRegionAttr dest, uint node_index) const {
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
    76
  assert(dest.is_valid(),
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54786
diff changeset
    77
         "Allocation buffer index out of bounds: %s", dest.get_type_str());
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54786
diff changeset
    78
  assert(_alloc_buffers[dest.type()] != NULL,
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54786
diff changeset
    79
         "Allocation buffer is NULL: %s", dest.get_type_str());
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    80
  return alloc_buffer(dest.type(), node_index);
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    81
}
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    82
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    83
inline PLAB* G1PLABAllocator::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
    84
  assert(dest < G1HeapRegionAttr::Num,
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    85
         "Allocation buffer index out of bounds: %u", dest);
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    86
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    87
  if (dest == G1HeapRegionAttr::Young) {
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    88
    assert(node_index < alloc_buffers_length(dest),
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    89
           "Allocation buffer index out of bounds: %u, %u", dest, node_index);
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    90
    return _alloc_buffers[dest][node_index];
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    91
  } else {
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    92
    return _alloc_buffers[dest][0];
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    93
  }
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    94
}
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    95
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    96
inline uint G1PLABAllocator::alloc_buffers_length(region_type_t dest) const {
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    97
  if (dest == G1HeapRegionAttr::Young) {
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    98
    return _allocator->num_nodes();
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
    99
  } else {
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   100
    return 1;
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   101
  }
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   102
}
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   103
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54786
diff changeset
   104
inline HeapWord* G1PLABAllocator::plab_allocate(G1HeapRegionAttr dest,
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   105
                                                size_t word_sz,
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   106
                                                uint node_index) {
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   107
  PLAB* buffer = alloc_buffer(dest, node_index);
32378
8dd0e7359751 8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents: 32185
diff changeset
   108
  if (_survivor_alignment_bytes == 0 || !dest.is_young()) {
8dd0e7359751 8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents: 32185
diff changeset
   109
    return buffer->allocate(word_sz);
8dd0e7359751 8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents: 32185
diff changeset
   110
  } else {
8dd0e7359751 8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents: 32185
diff changeset
   111
    return buffer->allocate_aligned(word_sz, _survivor_alignment_bytes);
8dd0e7359751 8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents: 32185
diff changeset
   112
  }
8dd0e7359751 8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents: 32185
diff changeset
   113
}
8dd0e7359751 8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents: 32185
diff changeset
   114
54843
25c329958c70 8200545: Improve filter for enqueued deferred cards
tschatzl
parents: 54786
diff changeset
   115
inline HeapWord* G1PLABAllocator::allocate(G1HeapRegionAttr dest,
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   116
                                           size_t word_sz,
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   117
                                           bool* refill_failed,
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   118
                                           uint node_index) {
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   119
  HeapWord* const obj = plab_allocate(dest, word_sz, node_index);
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   120
  if (obj != NULL) {
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   121
    return obj;
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   122
  }
59061
df6f2350edfa 8220311: Implementation: NUMA-Aware Memory Allocation for G1, Survivor (2/3)
sangheki
parents: 59060
diff changeset
   123
  return allocate_direct_or_new_plab(dest, word_sz, refill_failed, node_index);
49713
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   124
}
456e51e56ea2 8200169: Flatten G1Allocator class hierarchy
sjohanss
parents: 49323
diff changeset
   125
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   126
// Create the maps which is used to identify archive objects.
46285
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 33105
diff changeset
   127
inline void G1ArchiveAllocator::enable_archive_object_check() {
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   128
  if (_archive_check_enabled) {
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   129
    return;
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   130
  }
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   131
46285
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 33105
diff changeset
   132
  _archive_check_enabled = true;
53116
bb03098c4dde 8211425: Allocation of old generation of java heap on alternate memory devices - G1 GC
sangheki
parents: 52674
diff changeset
   133
  size_t length = G1CollectedHeap::heap()->max_reserved_capacity();
58015
dd84de796f2c 8224815: Remove non-GC uses of CollectedHeap::is_in_reserved()
eosterlund
parents: 54843
diff changeset
   134
  _closed_archive_region_map.initialize(G1CollectedHeap::heap()->base(),
dd84de796f2c 8224815: Remove non-GC uses of CollectedHeap::is_in_reserved()
eosterlund
parents: 54843
diff changeset
   135
                                        G1CollectedHeap::heap()->base() + length,
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   136
                                        HeapRegion::GrainBytes);
58015
dd84de796f2c 8224815: Remove non-GC uses of CollectedHeap::is_in_reserved()
eosterlund
parents: 54843
diff changeset
   137
  _open_archive_region_map.initialize(G1CollectedHeap::heap()->base(),
dd84de796f2c 8224815: Remove non-GC uses of CollectedHeap::is_in_reserved()
eosterlund
parents: 54843
diff changeset
   138
                                      G1CollectedHeap::heap()->base() + length,
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   139
                                      HeapRegion::GrainBytes);
46285
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 33105
diff changeset
   140
}
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 33105
diff changeset
   141
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   142
// Set the regions containing the specified address range as archive.
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   143
inline void G1ArchiveAllocator::set_range_archive(MemRegion range, bool open) {
46285
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 33105
diff changeset
   144
  assert(_archive_check_enabled, "archive range check not enabled");
52674
c9325aa887da 8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents: 52062
diff changeset
   145
  log_info(gc, cds)("Mark %s archive regions in map: [" PTR_FORMAT ", " PTR_FORMAT "]",
c9325aa887da 8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents: 52062
diff changeset
   146
                     open ? "open" : "closed",
c9325aa887da 8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents: 52062
diff changeset
   147
                     p2i(range.start()),
c9325aa887da 8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents: 52062
diff changeset
   148
                     p2i(range.last()));
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   149
  if (open) {
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   150
    _open_archive_region_map.set_by_address(range, true);
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   151
  } else {
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   152
    _closed_archive_region_map.set_by_address(range, true);
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   153
  }
46285
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 33105
diff changeset
   154
}
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 33105
diff changeset
   155
52674
c9325aa887da 8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents: 52062
diff changeset
   156
// Clear the archive regions map containing the specified address range.
c9325aa887da 8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents: 52062
diff changeset
   157
inline void G1ArchiveAllocator::clear_range_archive(MemRegion range, bool open) {
c9325aa887da 8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents: 52062
diff changeset
   158
  assert(_archive_check_enabled, "archive range check not enabled");
c9325aa887da 8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents: 52062
diff changeset
   159
  log_info(gc, cds)("Clear %s archive regions in map: [" PTR_FORMAT ", " PTR_FORMAT "]",
c9325aa887da 8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents: 52062
diff changeset
   160
                    open ? "open" : "closed",
c9325aa887da 8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents: 52062
diff changeset
   161
                    p2i(range.start()),
c9325aa887da 8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents: 52062
diff changeset
   162
                    p2i(range.last()));
c9325aa887da 8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents: 52062
diff changeset
   163
  if (open) {
c9325aa887da 8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents: 52062
diff changeset
   164
    _open_archive_region_map.set_by_address(range, false);
c9325aa887da 8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents: 52062
diff changeset
   165
  } else {
c9325aa887da 8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents: 52062
diff changeset
   166
    _closed_archive_region_map.set_by_address(range, false);
c9325aa887da 8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents: 52062
diff changeset
   167
  }
c9325aa887da 8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents: 52062
diff changeset
   168
}
c9325aa887da 8214118: HeapRegions marked as archive even if CDS mapping fails
sjohanss
parents: 52062
diff changeset
   169
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   170
// Check if an object is in a closed archive region using the _archive_region_map.
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   171
inline bool G1ArchiveAllocator::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
   172
  // This is the out-of-line part of is_closed_archive_object test, done separately
46285
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 33105
diff changeset
   173
  // to avoid additional performance impact when the check is not enabled.
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   174
  return _closed_archive_region_map.get_by_address((HeapWord*)object);
46285
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 33105
diff changeset
   175
}
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 33105
diff changeset
   176
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   177
inline bool G1ArchiveAllocator::in_open_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
   178
  return _open_archive_region_map.get_by_address((HeapWord*)object);
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   179
}
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   180
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   181
// 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: 33105
diff changeset
   182
// unnecessarily.
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 33105
diff changeset
   183
inline bool G1ArchiveAllocator::archive_check_enabled() {
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 33105
diff changeset
   184
  return _archive_check_enabled;
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 33105
diff changeset
   185
}
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 33105
diff changeset
   186
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   187
inline bool G1ArchiveAllocator::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
   188
  return (archive_check_enabled() && in_closed_archive_range(object));
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   189
}
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   190
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   191
inline bool G1ArchiveAllocator::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
   192
  return (archive_check_enabled() && in_open_archive_range(object));
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   193
}
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   194
52062
8dbf1a13af49 8206009: Move CDS java heap object archiving code to heapShared.hpp and heapShared.cpp
jiangli
parents: 50095
diff changeset
   195
inline bool G1ArchiveAllocator::is_archived_object(oop object) {
46810
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   196
  return (archive_check_enabled() && (in_closed_archive_range(object) ||
7dad333205cd 8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents: 46285
diff changeset
   197
                                      in_open_archive_range(object)));
46285
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 33105
diff changeset
   198
}
5b673a9fa682 8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents: 33105
diff changeset
   199
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 53116
diff changeset
   200
#endif // SHARE_GC_G1_G1ALLOCATOR_INLINE_HPP