Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ConstantPoolCacheEntry.java
41161 views
1
/*
2
* Copyright (c) 2001, 2020, 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.oops;
26
27
import java.util.*;
28
import sun.jvm.hotspot.debugger.*;
29
import sun.jvm.hotspot.runtime.*;
30
import sun.jvm.hotspot.types.*;
31
import sun.jvm.hotspot.utilities.*;
32
import sun.jvm.hotspot.utilities.Observable;
33
import sun.jvm.hotspot.utilities.Observer;
34
35
public class ConstantPoolCacheEntry {
36
private static long size;
37
private static long baseOffset;
38
private static CIntegerField indices;
39
private static AddressField f1;
40
private static CIntegerField f2;
41
private static CIntegerField flags;
42
43
private ConstantPoolCache cp;
44
private long offset;
45
46
static {
47
VM.registerVMInitializedObserver(new Observer() {
48
public void update(Observable o, Object data) {
49
initialize(VM.getVM().getTypeDataBase());
50
}
51
});
52
}
53
54
private static synchronized void initialize(TypeDataBase db) throws WrongTypeException {
55
Type type = db.lookupType("ConstantPoolCacheEntry");
56
size = type.getSize();
57
58
indices = type.getCIntegerField("_indices");
59
f1 = type.getAddressField ("_f1");
60
f2 = type.getCIntegerField("_f2");
61
flags = type.getCIntegerField("_flags");
62
63
type = db.lookupType("ConstantPoolCache");
64
baseOffset = type.getSize();
65
}
66
67
ConstantPoolCacheEntry(ConstantPoolCache cp, int index) {
68
this.cp = cp;
69
offset = baseOffset + index * size;
70
}
71
72
public int getConstantPoolIndex() {
73
if (Assert.ASSERTS_ENABLED) {
74
Assert.that((getIndices() & 0xFFFF) != 0, "must be main entry");
75
}
76
return (int) (getIndices() & 0xFFFF);
77
}
78
79
private long getIndices() {
80
return cp.getAddress().getCIntegerAt(indices.getOffset() + offset, indices.getSize(), indices.isUnsigned());
81
}
82
83
public Metadata getF1() {
84
return Metadata.instantiateWrapperFor(cp.getAddress().getAddressAt(f1.getOffset() + offset));
85
}
86
87
public int getF2() {
88
return cp.getAddress().getJIntAt(f1.getOffset() + offset);
89
}
90
91
public int getFlags() {
92
return cp.getAddress().getJIntAt(flags.getOffset() + offset);
93
}
94
95
static NamedFieldIdentifier f1FieldName = new NamedFieldIdentifier("_f1");
96
static NamedFieldIdentifier f2FieldName = new NamedFieldIdentifier("_f2");
97
static NamedFieldIdentifier flagsFieldName = new NamedFieldIdentifier("_flags");
98
99
public void iterateFields(MetadataVisitor visitor) {
100
visitor.doOop(new OopField(f1FieldName, f1.getOffset() + offset, true), true);
101
visitor.doInt(new IntField(f2FieldName, f2.getOffset() + offset, true), true);
102
visitor.doInt(new IntField(flagsFieldName, flags.getOffset() + offset, true), true);
103
}
104
}
105
106