1 /*
2  * Copyright (c) 2018, 2021, 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  *
23  */
24 
25 package sun.jvm.hotspot.gc.z;
26 
27 import sun.jvm.hotspot.debugger.Address;
28 import sun.jvm.hotspot.runtime.VM;
29 import sun.jvm.hotspot.runtime.VMObject;
30 import sun.jvm.hotspot.types.AddressField;
31 import sun.jvm.hotspot.types.Type;
32 import sun.jvm.hotspot.types.TypeDataBase;
33 
34 class ZGlobalsForVMStructs extends VMObject {
35     private static AddressField ZGlobalPhaseField;
36     private static AddressField ZGlobalSeqNumField;
37     private static AddressField ZAddressOffsetMaskField;
38     private static AddressField ZAddressMetadataMaskField;
39     private static AddressField ZAddressMetadataFinalizableField;
40     private static AddressField ZAddressGoodMaskField;
41     private static AddressField ZAddressBadMaskField;
42     private static AddressField ZAddressWeakBadMaskField;
43     private static AddressField ZObjectAlignmentSmallShiftField;
44     private static AddressField ZObjectAlignmentSmallField;
45 
46     static {
VM.registerVMInitializedObserver(o, d) -> initialize(VM.getVM().getTypeDataBase())47         VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase()));
48     }
49 
initialize(TypeDataBase db)50     static private synchronized void initialize(TypeDataBase db) {
51         Type type = db.lookupType("ZGlobalsForVMStructs");
52 
53         ZGlobalPhaseField = type.getAddressField("_ZGlobalPhase");
54         ZGlobalSeqNumField = type.getAddressField("_ZGlobalSeqNum");
55         ZAddressOffsetMaskField = type.getAddressField("_ZAddressOffsetMask");
56         ZAddressMetadataMaskField = type.getAddressField("_ZAddressMetadataMask");
57         ZAddressMetadataFinalizableField = type.getAddressField("_ZAddressMetadataFinalizable");
58         ZAddressGoodMaskField = type.getAddressField("_ZAddressGoodMask");
59         ZAddressBadMaskField = type.getAddressField("_ZAddressBadMask");
60         ZAddressWeakBadMaskField = type.getAddressField("_ZAddressWeakBadMask");
61         ZObjectAlignmentSmallShiftField = type.getAddressField("_ZObjectAlignmentSmallShift");
62         ZObjectAlignmentSmallField = type.getAddressField("_ZObjectAlignmentSmall");
63     }
64 
ZGlobalsForVMStructs(Address addr)65     ZGlobalsForVMStructs(Address addr) {
66         super(addr);
67     }
68 
ZGlobalPhase()69     int ZGlobalPhase() {
70         return ZGlobalPhaseField.getValue(addr).getJIntAt(0);
71     }
72 
ZGlobalSeqNum()73     int ZGlobalSeqNum() {
74         return ZGlobalSeqNumField.getValue(addr).getJIntAt(0);
75     }
76 
ZAddressOffsetMask()77     long ZAddressOffsetMask() {
78         return ZAddressOffsetMaskField.getValue(addr).getJLongAt(0);
79     }
80 
ZAddressMetadataMask()81     long ZAddressMetadataMask() {
82         return ZAddressMetadataMaskField.getValue(addr).getJLongAt(0);
83     }
84 
ZAddressMetadataFinalizable()85     long ZAddressMetadataFinalizable() {
86         return ZAddressMetadataFinalizableField.getValue(addr).getJLongAt(0);
87     }
88 
ZAddressGoodMask()89     long ZAddressGoodMask() {
90         return ZAddressGoodMaskField.getValue(addr).getJLongAt(0);
91     }
92 
ZAddressBadMask()93     long ZAddressBadMask() {
94         return ZAddressBadMaskField.getValue(addr).getJLongAt(0);
95     }
96 
ZAddressWeakBadMask()97     long ZAddressWeakBadMask() {
98         return ZAddressWeakBadMaskField.getValue(addr).getJLongAt(0);
99     }
100 
ZObjectAlignmentSmallShift()101     int ZObjectAlignmentSmallShift() {
102         return ZObjectAlignmentSmallShiftField.getValue(addr).getJIntAt(0);
103     }
104 
ZObjectAlignmentSmall()105     int ZObjectAlignmentSmall() {
106         return ZObjectAlignmentSmallField.getValue(addr).getJIntAt(0);
107     }
108 }
109