annotate agent/src/share/classes/sun/jvm/hotspot/code/PCDesc.java @ 3908:7588156f5cf9

7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244) Reviewed-by: kvn
author never
date Mon, 05 Sep 2011 17:09:05 -0700
parents 3e8fbc61cee8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1748
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1552
diff changeset
2 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1040
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1040
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1040
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.code;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.types.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 /** PcDescs map a physical PC (given as offset from start of nmethod)
a61af66fc99e Initial load
duke
parents:
diff changeset
34 to the corresponding source scope and byte code index. */
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 public class PCDesc extends VMObject {
a61af66fc99e Initial load
duke
parents:
diff changeset
37 private static CIntegerField pcOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 private static CIntegerField scopeDecodeOffsetField;
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 931
diff changeset
39 private static CIntegerField objDecodeOffsetField;
931
72088be4b386 6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents: 900
diff changeset
40 private static CIntegerField pcFlagsField;
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
41 private static int reexecuteMask;
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
42 private static int isMethodHandleInvokeMask;
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
43 private static int returnOopMask;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
47 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
48 initialize(VM.getVM().getTypeDataBase());
a61af66fc99e Initial load
duke
parents:
diff changeset
49 }
a61af66fc99e Initial load
duke
parents:
diff changeset
50 });
a61af66fc99e Initial load
duke
parents:
diff changeset
51 }
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 private static void initialize(TypeDataBase db) {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 Type type = db.lookupType("PcDesc");
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 pcOffsetField = type.getCIntegerField("_pc_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
57 scopeDecodeOffsetField = type.getCIntegerField("_scope_decode_offset");
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 931
diff changeset
58 objDecodeOffsetField = type.getCIntegerField("_obj_decode_offset");
931
72088be4b386 6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents: 900
diff changeset
59 pcFlagsField = type.getCIntegerField("_flags");
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
60
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
61 reexecuteMask = db.lookupIntConstant("PcDesc::PCDESC_reexecute");
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
62 isMethodHandleInvokeMask = db.lookupIntConstant("PcDesc::PCDESC_is_method_handle_invoke");
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
63 returnOopMask = db.lookupIntConstant("PcDesc::PCDESC_return_oop");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 public PCDesc(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 super(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
68 }
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // FIXME: add additional constructor probably needed for ScopeDesc::sender()
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 public int getPCOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
73 return (int) pcOffsetField.getValue(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
74 }
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 public int getScopeDecodeOffset() {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 return ((int) scopeDecodeOffsetField.getValue(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
78 }
a61af66fc99e Initial load
duke
parents:
diff changeset
79
1040
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 931
diff changeset
80 public int getObjDecodeOffset() {
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 931
diff changeset
81 return ((int) objDecodeOffsetField.getValue(addr));
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 931
diff changeset
82 }
873ec3787992 6892186: SA does not dump debug info for scalar replaced objects
kvn
parents: 931
diff changeset
83
0
a61af66fc99e Initial load
duke
parents:
diff changeset
84 public Address getRealPC(NMethod code) {
1748
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1552
diff changeset
85 return code.codeBegin().addOffsetTo(getPCOffset());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
86 }
a61af66fc99e Initial load
duke
parents:
diff changeset
87
931
72088be4b386 6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents: 900
diff changeset
88
72088be4b386 6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents: 900
diff changeset
89 public boolean getReexecute() {
72088be4b386 6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents: 900
diff changeset
90 int flags = (int)pcFlagsField.getValue(addr);
3908
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
91 return (flags & reexecuteMask) != 0;
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
92 }
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
93
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
94 public boolean isMethodHandleInvoke() {
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
95 int flags = (int)pcFlagsField.getValue(addr);
7588156f5cf9 7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents: 1748
diff changeset
96 return (flags & isMethodHandleInvokeMask) != 0;
931
72088be4b386 6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents: 900
diff changeset
97 }
72088be4b386 6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents: 900
diff changeset
98
0
a61af66fc99e Initial load
duke
parents:
diff changeset
99 public void print(NMethod code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
100 printOn(System.out, code);
a61af66fc99e Initial load
duke
parents:
diff changeset
101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 public void printOn(PrintStream tty, NMethod code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 tty.println("PCDesc(" + getRealPC(code) + "):");
a61af66fc99e Initial load
duke
parents:
diff changeset
105 for (ScopeDesc sd = code.getScopeDescAt(getRealPC(code));
a61af66fc99e Initial load
duke
parents:
diff changeset
106 sd != null;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 sd = sd.sender()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
108 tty.print(" ");
a61af66fc99e Initial load
duke
parents:
diff changeset
109 sd.getMethod().printValueOn(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
110 tty.print(" @" + sd.getBCI());
900
9987d9d5eb0e 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 0
diff changeset
111 tty.print(" reexecute=" + sd.getReexecute());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
112 tty.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
113 }
a61af66fc99e Initial load
duke
parents:
diff changeset
114 }
a61af66fc99e Initial load
duke
parents:
diff changeset
115 }