Mercurial > hg > graal-compiler
annotate src/share/vm/code/compiledIC.hpp @ 3992:d1bdeef3e3e2
7098282: G1: assert(interval >= 0) failed: Sanity check, referencePolicy.cpp: 76
Summary: There is a race between one thread successfully forwarding and copying the klass mirror for the SoftReference class (including the static master clock) and another thread attempting to use the master clock while attempting to discover a soft reference object. Maintain a shadow copy of the soft reference master clock and use the shadow during reference discovery and reference processing.
Reviewed-by: tonyp, brutisso, ysr
author | johnc |
---|---|
date | Wed, 12 Oct 2011 10:25:51 -0700 |
parents | 1d1603768966 |
children | da91efe96a93 |
rev | line source |
---|---|
0 | 1 /* |
2426
1d1603768966
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents:
2192
diff
changeset
|
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
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 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_CODE_COMPILEDIC_HPP |
26 #define SHARE_VM_CODE_COMPILEDIC_HPP | |
27 | |
28 #include "interpreter/linkResolver.hpp" | |
29 #include "oops/compiledICHolderKlass.hpp" | |
30 #include "oops/compiledICHolderOop.hpp" | |
31 #include "oops/klassOop.hpp" | |
32 #ifdef TARGET_ARCH_x86 | |
33 # include "nativeInst_x86.hpp" | |
34 #endif | |
35 #ifdef TARGET_ARCH_sparc | |
36 # include "nativeInst_sparc.hpp" | |
37 #endif | |
38 #ifdef TARGET_ARCH_zero | |
39 # include "nativeInst_zero.hpp" | |
40 #endif | |
2192
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
41 #ifdef TARGET_ARCH_arm |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
42 # include "nativeInst_arm.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
43 #endif |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
44 #ifdef TARGET_ARCH_ppc |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
45 # include "nativeInst_ppc.hpp" |
b92c45f2bc75
7016023: Enable building ARM and PPC from src/closed repository
bobv
parents:
1972
diff
changeset
|
46 #endif |
1972 | 47 |
0 | 48 //----------------------------------------------------------------------------- |
49 // The CompiledIC represents a compiled inline cache. | |
50 // | |
51 // In order to make patching of the inline cache MT-safe, we only allow the following | |
52 // transitions (when not at a safepoint): | |
53 // | |
54 // | |
55 // [1] --<-- Clean -->--- [1] | |
56 // / (null) \ | |
57 // / \ /-<-\ | |
58 // / [2] \ / \ | |
59 // Interpreted ---------> Monomorphic | [3] | |
60 // (compiledICHolderOop) (klassOop) | | |
61 // \ / \ / | |
62 // [4] \ / [4] \->-/ | |
63 // \->- Megamorphic -<-/ | |
64 // (methodOop) | |
65 // | |
66 // The text in paranteses () refere to the value of the inline cache receiver (mov instruction) | |
67 // | |
68 // The numbers in square brackets refere to the kind of transition: | |
69 // [1]: Initial fixup. Receiver it found from debug information | |
70 // [2]: Compilation of a method | |
71 // [3]: Recompilation of a method (note: only entry is changed. The klassOop must stay the same) | |
72 // [4]: Inline cache miss. We go directly to megamorphic call. | |
73 // | |
74 // The class automatically inserts transition stubs (using the InlineCacheBuffer) when an MT-unsafe | |
75 // transition is made to a stub. | |
76 // | |
77 class CompiledIC; | |
78 | |
79 class CompiledICInfo { | |
80 friend class CompiledIC; | |
81 private: | |
82 address _entry; // entry point for call | |
83 Handle _cached_oop; // Value of cached_oop (either in stub or inline cache) | |
84 bool _is_optimized; // it is an optimized virtual call (i.e., can be statically bound) | |
85 bool _to_interpreter; // Call it to interpreter | |
86 public: | |
87 address entry() const { return _entry; } | |
88 Handle cached_oop() const { return _cached_oop; } | |
89 bool is_optimized() const { return _is_optimized; } | |
90 }; | |
91 | |
92 class CompiledIC: public ResourceObj { | |
93 friend class InlineCacheBuffer; | |
94 friend class ICStub; | |
95 | |
96 | |
97 private: | |
98 NativeCall* _ic_call; // the call instruction | |
99 oop* _oop_addr; // patchable oop cell for this IC | |
100 RelocIterator _oops; // iteration over any and all set-oop instructions | |
101 bool _is_optimized; // an optimized virtual call (i.e., no compiled IC) | |
102 | |
103 CompiledIC(NativeCall* ic_call); | |
104 CompiledIC(Relocation* ic_reloc); // Must be of virtual_call_type/opt_virtual_call_type | |
105 | |
106 // low-level inline-cache manipulation. Cannot be accessed directly, since it might not be MT-safe | |
107 // to change an inline-cache. These changes the underlying inline-cache directly. They *newer* make | |
108 // changes to a transition stub. | |
109 void set_ic_destination(address entry_point); | |
110 void set_cached_oop(oop cache); | |
111 | |
112 // Reads the location of the transition stub. This will fail with an assertion, if no transition stub is | |
113 // associated with the inline cache. | |
114 address stub_address() const; | |
115 bool is_in_transition_state() const; // Use InlineCacheBuffer | |
116 | |
117 public: | |
118 // conversion (machine PC to CompiledIC*) | |
119 friend CompiledIC* CompiledIC_before(address return_addr); | |
120 friend CompiledIC* CompiledIC_at(address call_site); | |
121 friend CompiledIC* CompiledIC_at(Relocation* call_site); | |
122 | |
123 // Return the cached_oop/destination associated with this inline cache. If the cache currently points | |
124 // to a transition stub, it will read the values from the transition stub. | |
125 oop cached_oop() const; | |
126 address ic_destination() const; | |
127 | |
128 bool is_optimized() const { return _is_optimized; } | |
129 | |
130 // State | |
131 bool is_clean() const; | |
132 bool is_megamorphic() const; | |
133 bool is_call_to_compiled() const; | |
134 bool is_call_to_interpreted() const; | |
135 | |
136 address end_of_call() { return _ic_call->return_address(); } | |
137 | |
138 // MT-safe patching of inline caches. Note: Only safe to call is_xxx when holding the CompiledIC_ock | |
139 // so you are guaranteed that no patching takes place. The same goes for verify. | |
140 // | |
141 // Note: We do not provide any direct access to the stub code, to prevent parts of the code | |
142 // to manipulate the inline cache in MT-unsafe ways. | |
143 // | |
144 // They all takes a TRAP argument, since they can cause a GC if the inline-cache buffer is full. | |
145 // | |
146 void set_to_clean(); // Can only be called during a safepoint operation | |
147 void set_to_monomorphic(const CompiledICInfo& info); | |
148 void set_to_megamorphic(CallInfo* call_info, Bytecodes::Code bytecode, TRAPS); | |
149 | |
150 static void compute_monomorphic_entry(methodHandle method, KlassHandle receiver_klass, | |
151 bool is_optimized, bool static_bound, CompiledICInfo& info, TRAPS); | |
152 | |
153 // Location | |
154 address instruction_address() const { return _ic_call->instruction_address(); } | |
155 | |
156 // Misc | |
157 void print() PRODUCT_RETURN; | |
158 void print_compiled_ic() PRODUCT_RETURN; | |
159 void verify() PRODUCT_RETURN; | |
160 }; | |
161 | |
162 inline CompiledIC* CompiledIC_before(address return_addr) { | |
163 CompiledIC* c_ic = new CompiledIC(nativeCall_before(return_addr)); | |
164 c_ic->verify(); | |
165 return c_ic; | |
166 } | |
167 | |
168 inline CompiledIC* CompiledIC_at(address call_site) { | |
169 CompiledIC* c_ic = new CompiledIC(nativeCall_at(call_site)); | |
170 c_ic->verify(); | |
171 return c_ic; | |
172 } | |
173 | |
174 inline CompiledIC* CompiledIC_at(Relocation* call_site) { | |
175 CompiledIC* c_ic = new CompiledIC(call_site); | |
176 c_ic->verify(); | |
177 return c_ic; | |
178 } | |
179 | |
180 | |
181 //----------------------------------------------------------------------------- | |
182 // The CompiledStaticCall represents a call to a static method in the compiled | |
183 // | |
184 // Transition diagram of a static call site is somewhat simpler than for an inlined cache: | |
185 // | |
186 // | |
187 // -----<----- Clean ----->----- | |
188 // / \ | |
189 // / \ | |
190 // compilled code <------------> interpreted code | |
191 // | |
192 // Clean: Calls directly to runtime method for fixup | |
193 // Compiled code: Calls directly to compiled code | |
194 // Interpreted code: Calls to stub that set methodOop reference | |
195 // | |
196 // | |
197 class CompiledStaticCall; | |
198 | |
199 class StaticCallInfo { | |
200 private: | |
201 address _entry; // Entrypoint | |
202 methodHandle _callee; // Callee (used when calling interpreter) | |
203 bool _to_interpreter; // call to interpreted method (otherwise compiled) | |
204 | |
205 friend class CompiledStaticCall; | |
206 public: | |
207 address entry() const { return _entry; } | |
208 methodHandle callee() const { return _callee; } | |
209 }; | |
210 | |
211 | |
212 class CompiledStaticCall: public NativeCall { | |
213 friend class CompiledIC; | |
214 | |
215 // Also used by CompiledIC | |
216 void set_to_interpreted(methodHandle callee, address entry); | |
217 bool is_optimized_virtual(); | |
218 | |
219 public: | |
220 friend CompiledStaticCall* compiledStaticCall_before(address return_addr); | |
221 friend CompiledStaticCall* compiledStaticCall_at(address native_call); | |
222 friend CompiledStaticCall* compiledStaticCall_at(Relocation* call_site); | |
223 | |
224 // State | |
225 bool is_clean() const; | |
226 bool is_call_to_compiled() const; | |
227 bool is_call_to_interpreted() const; | |
228 | |
229 // Clean static call (will force resolving on next use) | |
230 void set_to_clean(); | |
231 | |
232 // Set state. The entry must be the same, as computed by compute_entry. | |
233 // Computation and setting is split up, since the actions are separate during | |
234 // a OptoRuntime::resolve_xxx. | |
235 void set(const StaticCallInfo& info); | |
236 | |
237 // Compute entry point given a method | |
238 static void compute_entry(methodHandle m, StaticCallInfo& info); | |
239 | |
240 // Stub support | |
241 address find_stub(); | |
242 static void set_stub_to_clean(static_stub_Relocation* static_stub); | |
243 | |
244 // Misc. | |
245 void print() PRODUCT_RETURN; | |
246 void verify() PRODUCT_RETURN; | |
247 }; | |
248 | |
249 | |
250 inline CompiledStaticCall* compiledStaticCall_before(address return_addr) { | |
251 CompiledStaticCall* st = (CompiledStaticCall*)nativeCall_before(return_addr); | |
252 st->verify(); | |
253 return st; | |
254 } | |
255 | |
256 inline CompiledStaticCall* compiledStaticCall_at(address native_call) { | |
257 CompiledStaticCall* st = (CompiledStaticCall*)native_call; | |
258 st->verify(); | |
259 return st; | |
260 } | |
261 | |
262 inline CompiledStaticCall* compiledStaticCall_at(Relocation* call_site) { | |
263 return compiledStaticCall_at(call_site->addr()); | |
264 } | |
1972 | 265 |
266 #endif // SHARE_VM_CODE_COMPILEDIC_HPP |