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/code/PCDesc.java
41171 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.code;
26
27
import java.io.*;
28
import java.util.*;
29
import sun.jvm.hotspot.debugger.*;
30
import sun.jvm.hotspot.runtime.*;
31
import sun.jvm.hotspot.types.*;
32
import sun.jvm.hotspot.utilities.Observable;
33
import sun.jvm.hotspot.utilities.Observer;
34
35
/** PcDescs map a physical PC (given as offset from start of nmethod)
36
to the corresponding source scope and byte code index. */
37
38
public class PCDesc extends VMObject {
39
private static CIntegerField pcOffsetField;
40
private static CIntegerField scopeDecodeOffsetField;
41
private static CIntegerField objDecodeOffsetField;
42
private static CIntegerField pcFlagsField;
43
private static int reexecuteMask;
44
private static int isMethodHandleInvokeMask;
45
private static int returnOopMask;
46
47
static {
48
VM.registerVMInitializedObserver(new Observer() {
49
public void update(Observable o, Object data) {
50
initialize(VM.getVM().getTypeDataBase());
51
}
52
});
53
}
54
55
private static void initialize(TypeDataBase db) {
56
Type type = db.lookupType("PcDesc");
57
58
pcOffsetField = type.getCIntegerField("_pc_offset");
59
scopeDecodeOffsetField = type.getCIntegerField("_scope_decode_offset");
60
objDecodeOffsetField = type.getCIntegerField("_obj_decode_offset");
61
pcFlagsField = type.getCIntegerField("_flags");
62
63
reexecuteMask = db.lookupIntConstant("PcDesc::PCDESC_reexecute");
64
isMethodHandleInvokeMask = db.lookupIntConstant("PcDesc::PCDESC_is_method_handle_invoke");
65
returnOopMask = db.lookupIntConstant("PcDesc::PCDESC_return_oop");
66
}
67
68
public PCDesc(Address addr) {
69
super(addr);
70
}
71
72
// FIXME: add additional constructor probably needed for ScopeDesc::sender()
73
74
public int getPCOffset() {
75
return (int) pcOffsetField.getValue(addr);
76
}
77
78
public int getScopeDecodeOffset() {
79
return ((int) scopeDecodeOffsetField.getValue(addr));
80
}
81
82
public int getObjDecodeOffset() {
83
return ((int) objDecodeOffsetField.getValue(addr));
84
}
85
86
public Address getRealPC(NMethod code) {
87
return code.codeBegin().addOffsetTo(getPCOffset());
88
}
89
90
91
public boolean getReexecute() {
92
int flags = (int)pcFlagsField.getValue(addr);
93
return (flags & reexecuteMask) != 0;
94
}
95
96
public boolean isMethodHandleInvoke() {
97
int flags = (int)pcFlagsField.getValue(addr);
98
return (flags & isMethodHandleInvokeMask) != 0;
99
}
100
101
public void print(NMethod code) {
102
printOn(System.out, code);
103
}
104
105
public void printOn(PrintStream tty, NMethod code) {
106
tty.println("PCDesc(" + getRealPC(code) + "):");
107
for (ScopeDesc sd = code.getScopeDescAt(getRealPC(code));
108
sd != null;
109
sd = sd.sender()) {
110
tty.print(" ");
111
sd.getMethod().printValueOn(tty);
112
tty.print(" @" + sd.getBCI());
113
tty.print(" reexecute=" + sd.getReexecute());
114
tty.println();
115
}
116
}
117
}
118
119