11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 #include "precompiled.hpp"
25 #include "gc/shared/gcHeapSummary.hpp"
26 #include "gc/shared/suspendibleThreadSet.hpp"
27 #include "gc/z/zCollectedHeap.hpp"
28 #include "gc/z/zGlobals.hpp"
29 #include "gc/z/zHeap.inline.hpp"
30 #include "gc/z/zNMethod.hpp"
31 #include "gc/z/zServiceability.hpp"
32 #include "gc/z/zStat.hpp"
33 #include "gc/z/zUtils.inline.hpp"
34 #include "memory/universe.hpp"
35 #include "runtime/mutexLocker.hpp"
36
37 ZCollectedHeap* ZCollectedHeap::heap() {
38 CollectedHeap* heap = Universe::heap();
39 assert(heap != NULL, "Uninitialized access to ZCollectedHeap::heap()");
40 assert(heap->kind() == CollectedHeap::Z, "Invalid name");
41 return (ZCollectedHeap*)heap;
42 }
43
44 ZCollectedHeap::ZCollectedHeap() :
45 _soft_ref_policy(),
46 _barrier_set(),
47 _initialize(&_barrier_set),
48 _heap(),
49 _director(new ZDirector()),
50 _driver(new ZDriver()),
108 return false;
109 }
110
111 bool ZCollectedHeap::is_in(const void* p) const {
112 return _heap.is_in((uintptr_t)p);
113 }
114
115 uint32_t ZCollectedHeap::hash_oop(oop obj) const {
116 return _heap.hash_oop(obj);
117 }
118
119 HeapWord* ZCollectedHeap::allocate_new_tlab(size_t min_size, size_t requested_size, size_t* actual_size) {
120 const size_t size_in_bytes = ZUtils::words_to_bytes(align_object_size(requested_size));
121 const uintptr_t addr = _heap.alloc_tlab(size_in_bytes);
122
123 if (addr != 0) {
124 *actual_size = requested_size;
125 }
126
127 return (HeapWord*)addr;
128 }
129
130 HeapWord* ZCollectedHeap::mem_allocate(size_t size, bool* gc_overhead_limit_was_exceeded) {
131 const size_t size_in_bytes = ZUtils::words_to_bytes(align_object_size(size));
132 return (HeapWord*)_heap.alloc_object(size_in_bytes);
133 }
134
135 MetaWord* ZCollectedHeap::satisfy_failed_metadata_allocation(ClassLoaderData* loader_data,
136 size_t size,
137 Metaspace::MetadataType mdtype) {
138 MetaWord* result;
139
140 // Start asynchronous GC
141 collect(GCCause::_metadata_GC_threshold);
142
143 // Expand and retry allocation
144 result = loader_data->metaspace_non_null()->expand_and_allocate(size, mdtype);
145 if (result != NULL) {
146 return result;
147 }
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 #include "precompiled.hpp"
25 #include "gc/shared/gcHeapSummary.hpp"
26 #include "gc/shared/suspendibleThreadSet.hpp"
27 #include "gc/z/zCollectedHeap.hpp"
28 #include "gc/z/zGlobals.hpp"
29 #include "gc/z/zHeap.inline.hpp"
30 #include "gc/z/zNMethod.hpp"
31 #include "gc/z/zObjArrayAllocator.hpp"
32 #include "gc/z/zServiceability.hpp"
33 #include "gc/z/zStat.hpp"
34 #include "gc/z/zUtils.inline.hpp"
35 #include "memory/universe.hpp"
36 #include "runtime/mutexLocker.hpp"
37
38 ZCollectedHeap* ZCollectedHeap::heap() {
39 CollectedHeap* heap = Universe::heap();
40 assert(heap != NULL, "Uninitialized access to ZCollectedHeap::heap()");
41 assert(heap->kind() == CollectedHeap::Z, "Invalid name");
42 return (ZCollectedHeap*)heap;
43 }
44
45 ZCollectedHeap::ZCollectedHeap() :
46 _soft_ref_policy(),
47 _barrier_set(),
48 _initialize(&_barrier_set),
49 _heap(),
50 _director(new ZDirector()),
51 _driver(new ZDriver()),
109 return false;
110 }
111
112 bool ZCollectedHeap::is_in(const void* p) const {
113 return _heap.is_in((uintptr_t)p);
114 }
115
116 uint32_t ZCollectedHeap::hash_oop(oop obj) const {
117 return _heap.hash_oop(obj);
118 }
119
120 HeapWord* ZCollectedHeap::allocate_new_tlab(size_t min_size, size_t requested_size, size_t* actual_size) {
121 const size_t size_in_bytes = ZUtils::words_to_bytes(align_object_size(requested_size));
122 const uintptr_t addr = _heap.alloc_tlab(size_in_bytes);
123
124 if (addr != 0) {
125 *actual_size = requested_size;
126 }
127
128 return (HeapWord*)addr;
129 }
130
131 oop ZCollectedHeap::array_allocate(Klass* klass, int size, int length, bool do_zero, TRAPS) {
132 if (!do_zero) {
133 return CollectedHeap::array_allocate(klass, size, length, false /* do_zero */, THREAD);
134 }
135
136 ZObjArrayAllocator allocator(klass, size, length, THREAD);
137 return allocator.allocate();
138 }
139
140 HeapWord* ZCollectedHeap::mem_allocate(size_t size, bool* gc_overhead_limit_was_exceeded) {
141 const size_t size_in_bytes = ZUtils::words_to_bytes(align_object_size(size));
142 return (HeapWord*)_heap.alloc_object(size_in_bytes);
143 }
144
145 MetaWord* ZCollectedHeap::satisfy_failed_metadata_allocation(ClassLoaderData* loader_data,
146 size_t size,
147 Metaspace::MetadataType mdtype) {
148 MetaWord* result;
149
150 // Start asynchronous GC
151 collect(GCCause::_metadata_GC_threshold);
152
153 // Expand and retry allocation
154 result = loader_data->metaspace_non_null()->expand_and_allocate(size, mdtype);
155 if (result != NULL) {
156 return result;
157 }
|