1 /*
 2  * Copyright (c) 2021 SAP SE. All rights reserved.
 3  * Copyright (c) 2021, Red Hat Inc. All rights reserved.
 4  * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
 5  *
 6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 7  *
 8  * This code is free software; you can redistribute it and/or modify it
 9  * under the terms of the GNU General Public License version 2 only, as
10  * published by the Free Software Foundation.
11  *
12  * This code is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15  * version 2 for more details (a copy is included in the LICENSE file that
16  * accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License version
19  * 2 along with this work; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21  *
22  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23  * or visit www.oracle.com if you need additional information or have any
24  * questions.
25  *
26  */
27 
28 #include "precompiled.hpp"
29 
30 #include "macroAssembler_x86.hpp"
31 #include "oops/compressedKlass.hpp"
32 #include "utilities/ostream.hpp"
33 #include "utilities/debug.hpp"
34 #include "runtime/globals.hpp"
35 
36 #ifdef _LP64
37 
38 // Given an address p, return true if p can be used as an encoding base.
39 //  (Some platforms have restrictions of what constitutes a valid base address).
40 bool CompressedKlassPointers::is_valid_base(address p) {
41   return MacroAssembler::klass_decode_mode_for_base(p) != MacroAssembler::KlassDecodeNone;
42 }
43 
44 void CompressedKlassPointers::print_mode(outputStream* st) {
45   st->print_cr("Narrow klass base: " PTR_FORMAT ", Narrow klass shift: %d, "
46                "Narrow klass range: " UINT64_FORMAT_X
47                ", Encoding mode %s",
48                p2i(base()), shift(), KlassEncodingMetaspaceMax,
49                MacroAssembler::describe_klass_decode_mode(MacroAssembler::klass_decode_mode()));
50 }
51 
52 #endif // _LP64