1 /*
2 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
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 */
63 _workers(),
64 _object_allocator(_workers.nworkers()),
65 _page_allocator(heap_min_size(), heap_max_size(), heap_max_reserve_size()),
66 _pagetable(),
67 _mark(&_workers, &_pagetable),
68 _reference_processor(&_workers),
69 _weak_roots_processor(&_workers),
70 _relocate(&_workers),
71 _relocation_set(),
72 _unload(&_workers),
73 _serviceability(heap_min_size(), heap_max_size()) {
74 // Install global heap instance
75 assert(_heap == NULL, "Already initialized");
76 _heap = this;
77
78 // Update statistics
79 ZStatHeap::set_at_initialize(heap_max_size(), heap_max_reserve_size());
80 }
81
82 size_t ZHeap::heap_min_size() const {
83 const size_t aligned_min_size = align_up(InitialHeapSize, ZPageSizeMin);
84 return MIN2(aligned_min_size, heap_max_size());
85 }
86
87 size_t ZHeap::heap_max_size() const {
88 const size_t aligned_max_size = align_up(MaxHeapSize, ZPageSizeMin);
89 return MIN2(aligned_max_size, ZAddressOffsetMax);
90 }
91
92 size_t ZHeap::heap_max_reserve_size() const {
93 // Reserve one small page per worker plus one shared medium page. This is still just
94 // an estimate and doesn't guarantee that we can't run out of memory during relocation.
95 const size_t max_reserve_size = (_workers.nworkers() * ZPageSizeSmall) + ZPageSizeMedium;
96 return MIN2(max_reserve_size, heap_max_size());
97 }
98
99 bool ZHeap::is_initialized() const {
100 return _page_allocator.is_initialized() && _mark.is_initialized();
101 }
102
103 size_t ZHeap::min_capacity() const {
104 return heap_min_size();
105 }
106
107 size_t ZHeap::max_capacity() const {
108 return _page_allocator.max_capacity();
|
1 /*
2 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
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 */
63 _workers(),
64 _object_allocator(_workers.nworkers()),
65 _page_allocator(heap_min_size(), heap_max_size(), heap_max_reserve_size()),
66 _pagetable(),
67 _mark(&_workers, &_pagetable),
68 _reference_processor(&_workers),
69 _weak_roots_processor(&_workers),
70 _relocate(&_workers),
71 _relocation_set(),
72 _unload(&_workers),
73 _serviceability(heap_min_size(), heap_max_size()) {
74 // Install global heap instance
75 assert(_heap == NULL, "Already initialized");
76 _heap = this;
77
78 // Update statistics
79 ZStatHeap::set_at_initialize(heap_max_size(), heap_max_reserve_size());
80 }
81
82 size_t ZHeap::heap_min_size() const {
83 const size_t aligned_min_size = align_up(InitialHeapSize, ZGranuleSize);
84 return MIN2(aligned_min_size, heap_max_size());
85 }
86
87 size_t ZHeap::heap_max_size() const {
88 const size_t aligned_max_size = align_up(MaxHeapSize, ZGranuleSize);
89 return MIN2(aligned_max_size, ZAddressOffsetMax);
90 }
91
92 size_t ZHeap::heap_max_reserve_size() const {
93 // Reserve one small page per worker plus one shared medium page. This is still just
94 // an estimate and doesn't guarantee that we can't run out of memory during relocation.
95 const size_t max_reserve_size = (_workers.nworkers() * ZPageSizeSmall) + ZPageSizeMedium;
96 return MIN2(max_reserve_size, heap_max_size());
97 }
98
99 bool ZHeap::is_initialized() const {
100 return _page_allocator.is_initialized() && _mark.is_initialized();
101 }
102
103 size_t ZHeap::min_capacity() const {
104 return heap_min_size();
105 }
106
107 size_t ZHeap::max_capacity() const {
108 return _page_allocator.max_capacity();
|