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