author | tschatzl |
Wed, 18 Apr 2018 11:36:48 +0200 | |
changeset 49806 | 2d62570a615c |
parent 49713 | 456e51e56ea2 |
child 49945 | 9425445633cf |
permissions | -rw-r--r-- |
32185
49a57ff2c3cb
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff
changeset
|
1 |
/* |
49713 | 2 |
* Copyright (c) 2015, 2018, 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 |
|
49a57ff2c3cb
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff
changeset
|
25 |
#ifndef SHARE_VM_GC_G1_G1ALLOCATOR_INLINE_HPP |
49a57ff2c3cb
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff
changeset
|
26 |
#define SHARE_VM_GC_G1_G1ALLOCATOR_INLINE_HPP |
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" |
32185
49a57ff2c3cb
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff
changeset
|
31 |
|
49713 | 32 |
inline MutatorAllocRegion* G1Allocator::mutator_alloc_region() { |
33 |
return &_mutator_alloc_region; |
|
34 |
} |
|
35 |
||
36 |
inline SurvivorGCAllocRegion* G1Allocator::survivor_gc_alloc_region() { |
|
37 |
return &_survivor_gc_alloc_region; |
|
38 |
} |
|
39 |
||
40 |
inline OldGCAllocRegion* G1Allocator::old_gc_alloc_region() { |
|
41 |
return &_old_gc_alloc_region; |
|
42 |
} |
|
43 |
||
44 |
inline HeapWord* G1Allocator::attempt_allocation(size_t word_size) { |
|
49323 | 45 |
return mutator_alloc_region()->attempt_allocation(word_size); |
32185
49a57ff2c3cb
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff
changeset
|
46 |
} |
49a57ff2c3cb
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff
changeset
|
47 |
|
49713 | 48 |
inline HeapWord* G1Allocator::attempt_allocation_locked(size_t word_size) { |
49323 | 49 |
HeapWord* result = mutator_alloc_region()->attempt_allocation_locked(word_size); |
50 |
assert(result != NULL || mutator_alloc_region()->get() == NULL, |
|
51 |
"Must not have a mutator alloc region if there is no memory, but is " PTR_FORMAT, p2i(mutator_alloc_region()->get())); |
|
32185
49a57ff2c3cb
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff
changeset
|
52 |
return result; |
49a57ff2c3cb
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff
changeset
|
53 |
} |
49a57ff2c3cb
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff
changeset
|
54 |
|
49713 | 55 |
inline HeapWord* G1Allocator::attempt_allocation_force(size_t word_size) { |
49323 | 56 |
return mutator_alloc_region()->attempt_allocation_force(word_size); |
32185
49a57ff2c3cb
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff
changeset
|
57 |
} |
49a57ff2c3cb
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff
changeset
|
58 |
|
49713 | 59 |
inline PLAB* G1PLABAllocator::alloc_buffer(InCSetState dest) { |
60 |
assert(dest.is_valid(), |
|
61 |
"Allocation buffer index out-of-bounds: " CSETSTATE_FORMAT, dest.value()); |
|
62 |
assert(_alloc_buffers[dest.value()] != NULL, |
|
63 |
"Allocation buffer is NULL: " CSETSTATE_FORMAT, dest.value()); |
|
64 |
return _alloc_buffers[dest.value()]; |
|
65 |
} |
|
66 |
||
32378
8dd0e7359751
8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents:
32185
diff
changeset
|
67 |
inline HeapWord* G1PLABAllocator::plab_allocate(InCSetState dest, |
49323 | 68 |
size_t word_sz) { |
69 |
PLAB* buffer = alloc_buffer(dest); |
|
32378
8dd0e7359751
8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents:
32185
diff
changeset
|
70 |
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
|
71 |
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
|
72 |
} else { |
8dd0e7359751
8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents:
32185
diff
changeset
|
73 |
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
|
74 |
} |
8dd0e7359751
8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents:
32185
diff
changeset
|
75 |
} |
8dd0e7359751
8133470: Uses of Atomic methods in plab.hpp should be moved to .inline.hpp file
tschatzl
parents:
32185
diff
changeset
|
76 |
|
49713 | 77 |
inline HeapWord* G1PLABAllocator::allocate(InCSetState dest, |
78 |
size_t word_sz, |
|
79 |
bool* refill_failed) { |
|
80 |
HeapWord* const obj = plab_allocate(dest, word_sz); |
|
81 |
if (obj != NULL) { |
|
82 |
return obj; |
|
83 |
} |
|
84 |
return allocate_direct_or_new_plab(dest, word_sz, refill_failed); |
|
85 |
} |
|
86 |
||
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
87 |
// 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
|
88 |
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
|
89 |
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
|
90 |
return; |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
91 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
92 |
|
46285
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
33105
diff
changeset
|
93 |
_archive_check_enabled = true; |
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
33105
diff
changeset
|
94 |
size_t length = Universe::heap()->max_capacity(); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
95 |
_closed_archive_region_map.initialize((HeapWord*)Universe::heap()->base(), |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
96 |
(HeapWord*)Universe::heap()->base() + length, |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
97 |
HeapRegion::GrainBytes); |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
98 |
_open_archive_region_map.initialize((HeapWord*)Universe::heap()->base(), |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
99 |
(HeapWord*)Universe::heap()->base() + length, |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
100 |
HeapRegion::GrainBytes); |
46285
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
33105
diff
changeset
|
101 |
} |
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
33105
diff
changeset
|
102 |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
103 |
// 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
|
104 |
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
|
105 |
assert(_archive_check_enabled, "archive range check not enabled"); |
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
106 |
if (open) { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
107 |
_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
|
108 |
} else { |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
109 |
_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
|
110 |
} |
46285
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
33105
diff
changeset
|
111 |
} |
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
33105
diff
changeset
|
112 |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
113 |
// 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
|
114 |
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
|
115 |
// 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
|
116 |
// 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
|
117 |
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
|
118 |
} |
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
33105
diff
changeset
|
119 |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
120 |
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
|
121 |
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
|
122 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
123 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
124 |
// 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
|
125 |
// unnecessarily. |
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
33105
diff
changeset
|
126 |
inline bool G1ArchiveAllocator::archive_check_enabled() { |
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
33105
diff
changeset
|
127 |
return _archive_check_enabled; |
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
33105
diff
changeset
|
128 |
} |
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
33105
diff
changeset
|
129 |
|
46810
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
130 |
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
|
131 |
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
|
132 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
133 |
|
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
134 |
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
|
135 |
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
|
136 |
} |
7dad333205cd
8179302: Pre-resolve constant pool string entries and cache resolved_reference arrays in CDS archive.
jiangli
parents:
46285
diff
changeset
|
137 |
|
46285
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
33105
diff
changeset
|
138 |
inline bool G1ArchiveAllocator::is_archive_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
|
139 |
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
|
140 |
in_open_archive_range(object))); |
46285
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
33105
diff
changeset
|
141 |
} |
5b673a9fa682
8171235: Move archive object code from G1MarkSweep into G1ArchiveAllocator
sjohanss
parents:
33105
diff
changeset
|
142 |
|
32185
49a57ff2c3cb
8073052: Rename and clean up the allocation manager hierarchy in g1Allocator.?pp
tschatzl
parents:
diff
changeset
|
143 |
#endif // SHARE_VM_GC_G1_G1ALLOCATOR_HPP |