Mercurial > hg > graal-compiler
comparison agent/src/share/classes/sun/jvm/hotspot/code/ScopeDesc.java @ 0:a61af66fc99e jdk7-b24
Initial load
author | duke |
---|---|
date | Sat, 01 Dec 2007 00:00:00 +0000 |
parents | |
children | b109e761e927 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a61af66fc99e |
---|---|
1 /* | |
2 * Copyright 2000-2005 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 package sun.jvm.hotspot.code; | |
26 | |
27 import java.io.*; | |
28 import java.util.*; | |
29 | |
30 import sun.jvm.hotspot.oops.*; | |
31 import sun.jvm.hotspot.runtime.*; | |
32 | |
33 /** ScopeDescs contain the information that makes source-level | |
34 debugging of nmethods possible; each scopeDesc describes a method | |
35 activation */ | |
36 | |
37 public class ScopeDesc { | |
38 /** NMethod information */ | |
39 private NMethod code; | |
40 private Method method; | |
41 private int bci; | |
42 /** Decoding offsets */ | |
43 private int decodeOffset; | |
44 private int senderDecodeOffset; | |
45 private int localsDecodeOffset; | |
46 private int expressionsDecodeOffset; | |
47 private int monitorsDecodeOffset; | |
48 | |
49 public ScopeDesc(NMethod code, int decodeOffset) { | |
50 this.code = code; | |
51 this.decodeOffset = decodeOffset; | |
52 | |
53 // Decode header | |
54 DebugInfoReadStream stream = streamAt(decodeOffset); | |
55 | |
56 senderDecodeOffset = stream.readInt(); | |
57 method = (Method) VM.getVM().getObjectHeap().newOop(stream.readOopHandle()); | |
58 bci = stream.readBCI(); | |
59 // Decode offsets for body and sender | |
60 localsDecodeOffset = stream.readInt(); | |
61 expressionsDecodeOffset = stream.readInt(); | |
62 monitorsDecodeOffset = stream.readInt(); | |
63 } | |
64 | |
65 public NMethod getNMethod() { return code; } | |
66 public Method getMethod() { return method; } | |
67 public int getBCI() { return bci; } | |
68 | |
69 /** Returns a List<ScopeValue> */ | |
70 public List getLocals() { | |
71 return decodeScopeValues(localsDecodeOffset); | |
72 } | |
73 | |
74 /** Returns a List<ScopeValue> */ | |
75 public List getExpressions() { | |
76 return decodeScopeValues(expressionsDecodeOffset); | |
77 } | |
78 | |
79 /** Returns a List<MonitorValue> */ | |
80 public List getMonitors() { | |
81 return decodeMonitorValues(monitorsDecodeOffset); | |
82 } | |
83 | |
84 /** Stack walking. Returns null if this is the outermost scope. */ | |
85 public ScopeDesc sender() { | |
86 if (isTop()) { | |
87 return null; | |
88 } | |
89 | |
90 return new ScopeDesc(code, senderDecodeOffset); | |
91 } | |
92 | |
93 /** Returns where the scope was decoded */ | |
94 public int getDecodeOffset() { | |
95 return decodeOffset; | |
96 } | |
97 | |
98 /** Tells whether sender() returns null */ | |
99 public boolean isTop() { | |
100 return (senderDecodeOffset == DebugInformationRecorder.SERIALIZED_NULL); | |
101 } | |
102 | |
103 public boolean equals(Object arg) { | |
104 if (arg == null) { | |
105 return false; | |
106 } | |
107 | |
108 if (!(arg instanceof ScopeDesc)) { | |
109 return false; | |
110 } | |
111 | |
112 ScopeDesc sd = (ScopeDesc) arg; | |
113 | |
114 return (sd.method.equals(method) && (sd.bci == bci)); | |
115 } | |
116 | |
117 public void printValue() { | |
118 printValueOn(System.out); | |
119 } | |
120 | |
121 public void printValueOn(PrintStream tty) { | |
122 tty.print("ScopeDesc for "); | |
123 method.printValueOn(tty); | |
124 tty.println(" @bci " + bci); | |
125 } | |
126 | |
127 // FIXME: add more accessors | |
128 | |
129 //-------------------------------------------------------------------------------- | |
130 // Internals only below this point | |
131 // | |
132 | |
133 private DebugInfoReadStream streamAt(int decodeOffset) { | |
134 return new DebugInfoReadStream(code, decodeOffset); | |
135 } | |
136 | |
137 /** Returns a List<ScopeValue> or null if no values were present */ | |
138 private List decodeScopeValues(int decodeOffset) { | |
139 if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) { | |
140 return null; | |
141 } | |
142 DebugInfoReadStream stream = streamAt(decodeOffset); | |
143 int length = stream.readInt(); | |
144 List res = new ArrayList(length); | |
145 for (int i = 0; i < length; i++) { | |
146 res.add(ScopeValue.readFrom(stream)); | |
147 } | |
148 return res; | |
149 } | |
150 | |
151 /** Returns a List<MonitorValue> or null if no values were present */ | |
152 private List decodeMonitorValues(int decodeOffset) { | |
153 if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) { | |
154 return null; | |
155 } | |
156 DebugInfoReadStream stream = streamAt(decodeOffset); | |
157 int length = stream.readInt(); | |
158 List res = new ArrayList(length); | |
159 for (int i = 0; i < length; i++) { | |
160 res.add(new MonitorValue(stream)); | |
161 } | |
162 return res; | |
163 } | |
164 } |