1 /*
2 * Copyright Amazon.com Inc. 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 *
23 */
24
25 #include "gc/shared/fullGCForwarding.hpp"
26 #include "memory/memRegion.hpp"
27 #include "runtime/globals_extension.hpp"
28
29 HeapWord* FullGCForwarding::_heap_base = nullptr;
30 int FullGCForwarding::_num_low_bits = 0;
31
32 void FullGCForwarding::initialize_flags(size_t max_heap_size) {
33 #ifdef _LP64
34 size_t max_narrow_heap_size = right_n_bits(NumLowBitsNarrow - Shift);
35 if (UseCompactObjectHeaders && max_heap_size > max_narrow_heap_size * HeapWordSize) {
36 warning("Compact object headers require a java heap size smaller than %zu"
37 "%s (given: %zu%s). Disabling compact object headers.",
38 byte_size_in_proper_unit(max_narrow_heap_size * HeapWordSize),
39 proper_unit_for_byte_size(max_narrow_heap_size * HeapWordSize),
40 byte_size_in_proper_unit(max_heap_size),
41 proper_unit_for_byte_size(max_heap_size));
42 FLAG_SET_ERGO(UseCompactObjectHeaders, false);
43 }
44 #endif
45 }
46
47 void FullGCForwarding::initialize(MemRegion heap) {
48 #ifdef _LP64
49 _heap_base = heap.start();
50 if (UseCompactObjectHeaders) {
51 _num_low_bits = NumLowBitsNarrow;
52 } else {
53 _num_low_bits = NumLowBitsWide;
54 }
55 #endif
56 }