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/interpreter/InterpreterCodelet.java
41161 views
1
/*
2
* Copyright (c) 2000, 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.interpreter;
26
27
import java.io.*;
28
import java.util.*;
29
30
import sun.jvm.hotspot.code.*;
31
import sun.jvm.hotspot.debugger.*;
32
import sun.jvm.hotspot.runtime.*;
33
import sun.jvm.hotspot.types.*;
34
import sun.jvm.hotspot.utilities.*;
35
import sun.jvm.hotspot.utilities.Observable;
36
import sun.jvm.hotspot.utilities.Observer;
37
38
/** An InterpreterCodelet is a piece of interpreter code. All
39
interpreter code is generated into little codelets which contain
40
extra information for debugging and printing purposes. */
41
42
public class InterpreterCodelet extends Stub {
43
private static long instanceSize;
44
private static CIntegerField sizeField; // the size in bytes
45
private static AddressField descriptionField; // a description of the codelet, for debugging & printing
46
private static CIntegerField bytecodeField; // associated bytecode if any
47
48
static {
49
VM.registerVMInitializedObserver(new Observer() {
50
public void update(Observable o, Object data) {
51
initialize(VM.getVM().getTypeDataBase());
52
}
53
});
54
}
55
56
private static synchronized void initialize(TypeDataBase db) {
57
Type type = db.lookupType("InterpreterCodelet");
58
59
sizeField = type.getCIntegerField("_size");
60
descriptionField = type.getAddressField("_description");
61
bytecodeField = type.getCIntegerField("_bytecode");
62
63
instanceSize = type.getSize();
64
}
65
66
public InterpreterCodelet(Address addr) {
67
super(addr);
68
}
69
70
public long getSize() {
71
return sizeField.getValue(addr);
72
}
73
74
public Address codeBegin() {
75
return addr.addOffsetTo(instanceSize);
76
}
77
78
public Address codeEnd() {
79
return addr.addOffsetTo(getSize());
80
}
81
82
public long codeSize() {
83
return codeEnd().minus(codeBegin());
84
}
85
86
public String getDescription() {
87
return CStringUtilities.getString(descriptionField.getValue(addr));
88
}
89
90
public void verify() {
91
}
92
93
public void printOn(PrintStream tty) {
94
String desc = getDescription();
95
if (desc != null) {
96
tty.print(desc);
97
}
98
// FIXME: add printing of bytecode
99
tty.println(" [" + codeBegin() + ", " + codeEnd() + ") " +
100
codeSize() + " bytes ");
101
// FIXME: add disassembly
102
}
103
}
104
105