annotate agent/src/share/classes/sun/jvm/hotspot/code/CodeBlob.java @ 1644:2a47bd84841f

6965184: possible races in make_not_entrant_or_zombie Reviewed-by: kvn
author never
date Thu, 08 Jul 2010 14:29:44 -0700
parents e9ff18c4ace7
children 3e8fbc61cee8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 2000, 2005, 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: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
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: 0
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
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.asm.x86.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.compiler.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.runtime.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 import sun.jvm.hotspot.types.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 import sun.jvm.hotspot.utilities.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 public class CodeBlob extends VMObject {
a61af66fc99e Initial load
duke
parents:
diff changeset
38 private static AddressField nameField;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 private static CIntegerField sizeField;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 private static CIntegerField headerSizeField;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 private static CIntegerField relocationSizeField;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 private static CIntegerField instructionsOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 private static CIntegerField frameCompleteOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 private static CIntegerField dataOffsetField;
a61af66fc99e Initial load
duke
parents:
diff changeset
45 private static CIntegerField frameSizeField;
a61af66fc99e Initial load
duke
parents:
diff changeset
46 private static AddressField oopMapsField;
a61af66fc99e Initial load
duke
parents:
diff changeset
47
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // Only used by server compiler on x86; computed over in SA rather
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // than relying on computation in target VM
a61af66fc99e Initial load
duke
parents:
diff changeset
50 private static final int NOT_YET_COMPUTED = -2;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 private static final int UNDEFINED = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 private int linkOffset = NOT_YET_COMPUTED;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 private static int matcherInterpreterFramePointerReg;
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55 static {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 VM.registerVMInitializedObserver(new Observer() {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 public void update(Observable o, Object data) {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 initialize(VM.getVM().getTypeDataBase());
a61af66fc99e Initial load
duke
parents:
diff changeset
59 }
a61af66fc99e Initial load
duke
parents:
diff changeset
60 });
a61af66fc99e Initial load
duke
parents:
diff changeset
61 }
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 private static void initialize(TypeDataBase db) {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 Type type = db.lookupType("CodeBlob");
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 nameField = type.getAddressField("_name");
a61af66fc99e Initial load
duke
parents:
diff changeset
67 sizeField = type.getCIntegerField("_size");
a61af66fc99e Initial load
duke
parents:
diff changeset
68 headerSizeField = type.getCIntegerField("_header_size");
a61af66fc99e Initial load
duke
parents:
diff changeset
69 relocationSizeField = type.getCIntegerField("_relocation_size");
a61af66fc99e Initial load
duke
parents:
diff changeset
70 frameCompleteOffsetField = type.getCIntegerField("_frame_complete_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
71 instructionsOffsetField = type.getCIntegerField("_instructions_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
72 dataOffsetField = type.getCIntegerField("_data_offset");
a61af66fc99e Initial load
duke
parents:
diff changeset
73 frameSizeField = type.getCIntegerField("_frame_size");
a61af66fc99e Initial load
duke
parents:
diff changeset
74 oopMapsField = type.getAddressField("_oop_maps");
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 if (VM.getVM().isServerCompiler()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 matcherInterpreterFramePointerReg =
a61af66fc99e Initial load
duke
parents:
diff changeset
78 db.lookupIntConstant("Matcher::interpreter_frame_pointer_reg").intValue();
a61af66fc99e Initial load
duke
parents:
diff changeset
79 }
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 public CodeBlob(Address addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 super(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
84 }
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // Typing
a61af66fc99e Initial load
duke
parents:
diff changeset
87 public boolean isBufferBlob() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
88 public boolean isNMethod() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
89 public boolean isRuntimeStub() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
90 public boolean isDeoptimizationStub() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
91 public boolean isUncommonTrapStub() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
92 public boolean isExceptionStub() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
93 public boolean isSafepointStub() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // Fine grain nmethod support: isNmethod() == isJavaMethod() || isNativeMethod() || isOSRMethod()
a61af66fc99e Initial load
duke
parents:
diff changeset
96 public boolean isJavaMethod() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
97 public boolean isNativeMethod() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 /** On-Stack Replacement method */
a61af66fc99e Initial load
duke
parents:
diff changeset
99 public boolean isOSRMethod() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // Boundaries
a61af66fc99e Initial load
duke
parents:
diff changeset
102 public Address headerBegin() {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 return addr;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 public Address headerEnd() {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 return addr.addOffsetTo(headerSizeField.getValue(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // FIXME: add RelocInfo
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // public RelocInfo relocationBegin();
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // public RelocInfo relocationEnd();
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 public Address instructionsBegin() {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 return headerBegin().addOffsetTo(instructionsOffsetField.getValue(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 public Address instructionsEnd() {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 return headerBegin().addOffsetTo(dataOffsetField.getValue(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 public Address dataBegin() {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 return headerBegin().addOffsetTo(dataOffsetField.getValue(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 public Address dataEnd() {
a61af66fc99e Initial load
duke
parents:
diff changeset
127 return headerBegin().addOffsetTo(sizeField.getValue(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // Offsets
a61af66fc99e Initial load
duke
parents:
diff changeset
131 public int getRelocationOffset() { return (int) headerSizeField.getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
132 public int getInstructionsOffset() { return (int) instructionsOffsetField.getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 public int getDataOffset() { return (int) dataOffsetField.getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 // Sizes
a61af66fc99e Initial load
duke
parents:
diff changeset
136 public int getSize() { return (int) sizeField.getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
137 public int getHeaderSize() { return (int) headerSizeField.getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // FIXME: add getRelocationSize()
a61af66fc99e Initial load
duke
parents:
diff changeset
139 public int getInstructionsSize() { return (int) instructionsEnd().minus(instructionsBegin()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
140 public int getDataSize() { return (int) dataEnd().minus(dataBegin()); }
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 // Containment
a61af66fc99e Initial load
duke
parents:
diff changeset
143 public boolean blobContains(Address addr) { return headerBegin().lessThanOrEqual(addr) && dataEnd().greaterThan(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // FIXME: add relocationContains
a61af66fc99e Initial load
duke
parents:
diff changeset
145 public boolean instructionsContains(Address addr) { return instructionsBegin().lessThanOrEqual(addr) && instructionsEnd().greaterThan(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
146 public boolean dataContains(Address addr) { return dataBegin().lessThanOrEqual(addr) && dataEnd().greaterThan(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
147 public boolean contains(Address addr) { return instructionsContains(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
148 public boolean isFrameCompleteAt(Address a) { return instructionsContains(a) && a.minus(instructionsBegin()) >= frameCompleteOffsetField.getValue(addr); }
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150 // Reclamation support (really only used by the nmethods, but in order to get asserts to work
a61af66fc99e Initial load
duke
parents:
diff changeset
151 // in the CodeCache they are defined virtual here)
a61af66fc99e Initial load
duke
parents:
diff changeset
152 public boolean isZombie() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
153 public boolean isLockedByVM() { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
154
a61af66fc99e Initial load
duke
parents:
diff changeset
155 /** OopMap for frame; can return null if none available */
a61af66fc99e Initial load
duke
parents:
diff changeset
156 public OopMapSet getOopMaps() {
a61af66fc99e Initial load
duke
parents:
diff changeset
157 Address oopMapsAddr = oopMapsField.getValue(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
158 if (oopMapsAddr == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
a61af66fc99e Initial load
duke
parents:
diff changeset
161 return new OopMapSet(oopMapsAddr);
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // FIXME: not yet implementable
a61af66fc99e Initial load
duke
parents:
diff changeset
164 // void set_oop_maps(OopMapSet* p);
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166 public OopMap getOopMapForReturnAddress(Address returnAddress, boolean debugging) {
a61af66fc99e Initial load
duke
parents:
diff changeset
167 Address pc = returnAddress;
a61af66fc99e Initial load
duke
parents:
diff changeset
168 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
169 Assert.that(getOopMaps() != null, "nope");
a61af66fc99e Initial load
duke
parents:
diff changeset
170 }
a61af66fc99e Initial load
duke
parents:
diff changeset
171 return getOopMaps().findMapAtOffset(pc.minus(instructionsBegin()), debugging);
a61af66fc99e Initial load
duke
parents:
diff changeset
172 }
a61af66fc99e Initial load
duke
parents:
diff changeset
173
a61af66fc99e Initial load
duke
parents:
diff changeset
174 // virtual void preserve_callee_argument_oops(frame fr, const RegisterMap* reg_map, void f(oop*)) { ShouldNotReachHere(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // FIXME;
a61af66fc99e Initial load
duke
parents:
diff changeset
176
a61af66fc99e Initial load
duke
parents:
diff changeset
177 /** NOTE: this returns a size in BYTES in this system! */
a61af66fc99e Initial load
duke
parents:
diff changeset
178 public long getFrameSize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 return VM.getVM().getAddressSize() * frameSizeField.getValue(addr);
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181
a61af66fc99e Initial load
duke
parents:
diff changeset
182 // Returns true, if the next frame is responsible for GC'ing oops passed as arguments
a61af66fc99e Initial load
duke
parents:
diff changeset
183 public boolean callerMustGCArguments(JavaThread thread) { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
184
a61af66fc99e Initial load
duke
parents:
diff changeset
185 public String getName() {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 return CStringUtilities.getString(nameField.getValue(addr));
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 // FIXME: NOT FINISHED
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 // FIXME: add more accessors
a61af66fc99e Initial load
duke
parents:
diff changeset
192
a61af66fc99e Initial load
duke
parents:
diff changeset
193 public void print() {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 printOn(System.out);
a61af66fc99e Initial load
duke
parents:
diff changeset
195 }
a61af66fc99e Initial load
duke
parents:
diff changeset
196
a61af66fc99e Initial load
duke
parents:
diff changeset
197 public void printOn(PrintStream tty) {
a61af66fc99e Initial load
duke
parents:
diff changeset
198 tty.print(getName());
a61af66fc99e Initial load
duke
parents:
diff changeset
199 printComponentsOn(tty);
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201
a61af66fc99e Initial load
duke
parents:
diff changeset
202 protected void printComponentsOn(PrintStream tty) {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 tty.println(" instructions: [" + instructionsBegin() + ", " + instructionsEnd() + "), " +
a61af66fc99e Initial load
duke
parents:
diff changeset
204 " data: [" + dataBegin() + ", " + dataEnd() + "), " +
a61af66fc99e Initial load
duke
parents:
diff changeset
205 " frame size: " + getFrameSize());
a61af66fc99e Initial load
duke
parents:
diff changeset
206 }
a61af66fc99e Initial load
duke
parents:
diff changeset
207 }