Mercurial > hg > graal-jvmci-8
annotate src/share/vm/oops/cpCacheOop.cpp @ 1507:cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
Summary: split MethodHandle.invoke into invokeExact and invokeGeneric; also clean up JVM-to-Java interfaces
Reviewed-by: twisti
author | jrose |
---|---|
date | Sat, 01 May 2010 02:42:18 -0700 |
parents | 389049f3f393 |
children | c18cbe5936b8 |
rev | line source |
---|---|
0 | 1 /* |
844 | 2 * Copyright 1998-2009 Sun Microsystems, Inc. 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 * | |
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 #include "incls/_precompiled.incl" | |
26 #include "incls/_cpCacheOop.cpp.incl" | |
27 | |
28 | |
29 // Implememtation of ConstantPoolCacheEntry | |
30 | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
844
diff
changeset
|
31 void ConstantPoolCacheEntry::initialize_entry(int index) { |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
196
diff
changeset
|
32 assert(0 < index && index < 0x10000, "sanity check"); |
0 | 33 _indices = index; |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
196
diff
changeset
|
34 assert(constant_pool_index() == index, ""); |
0 | 35 } |
36 | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
844
diff
changeset
|
37 void ConstantPoolCacheEntry::initialize_secondary_entry(int main_index) { |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
844
diff
changeset
|
38 assert(0 <= main_index && main_index < 0x10000, "sanity check"); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
844
diff
changeset
|
39 _indices = (main_index << 16); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
844
diff
changeset
|
40 assert(main_entry_index() == main_index, ""); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
844
diff
changeset
|
41 } |
0 | 42 |
43 int ConstantPoolCacheEntry::as_flags(TosState state, bool is_final, | |
44 bool is_vfinal, bool is_volatile, | |
45 bool is_method_interface, bool is_method) { | |
46 int f = state; | |
47 | |
48 assert( state < number_of_states, "Invalid state in as_flags"); | |
49 | |
50 f <<= 1; | |
51 if (is_final) f |= 1; | |
52 f <<= 1; | |
53 if (is_vfinal) f |= 1; | |
54 f <<= 1; | |
55 if (is_volatile) f |= 1; | |
56 f <<= 1; | |
57 if (is_method_interface) f |= 1; | |
58 f <<= 1; | |
59 if (is_method) f |= 1; | |
60 f <<= ConstantPoolCacheEntry::hotSwapBit; | |
61 // Preserve existing flag bit values | |
62 #ifdef ASSERT | |
63 int old_state = ((_flags >> tosBits) & 0x0F); | |
64 assert(old_state == 0 || old_state == state, | |
65 "inconsistent cpCache flags state"); | |
66 #endif | |
67 return (_flags | f) ; | |
68 } | |
69 | |
70 void ConstantPoolCacheEntry::set_bytecode_1(Bytecodes::Code code) { | |
71 #ifdef ASSERT | |
72 // Read once. | |
73 volatile Bytecodes::Code c = bytecode_1(); | |
74 assert(c == 0 || c == code || code == 0, "update must be consistent"); | |
75 #endif | |
76 // Need to flush pending stores here before bytecode is written. | |
77 OrderAccess::release_store_ptr(&_indices, _indices | ((u_char)code << 16)); | |
78 } | |
79 | |
80 void ConstantPoolCacheEntry::set_bytecode_2(Bytecodes::Code code) { | |
81 #ifdef ASSERT | |
82 // Read once. | |
83 volatile Bytecodes::Code c = bytecode_2(); | |
84 assert(c == 0 || c == code || code == 0, "update must be consistent"); | |
85 #endif | |
86 // Need to flush pending stores here before bytecode is written. | |
87 OrderAccess::release_store_ptr(&_indices, _indices | ((u_char)code << 24)); | |
88 } | |
89 | |
90 #ifdef ASSERT | |
91 // It is possible to have two different dummy methodOops created | |
92 // when the resolve code for invoke interface executes concurrently | |
93 // Hence the assertion below is weakened a bit for the invokeinterface | |
94 // case. | |
95 bool ConstantPoolCacheEntry::same_methodOop(oop cur_f1, oop f1) { | |
96 return (cur_f1 == f1 || ((methodOop)cur_f1)->name() == | |
97 ((methodOop)f1)->name() || ((methodOop)cur_f1)->signature() == | |
98 ((methodOop)f1)->signature()); | |
99 } | |
100 #endif | |
101 | |
102 // Note that concurrent update of both bytecodes can leave one of them | |
103 // reset to zero. This is harmless; the interpreter will simply re-resolve | |
104 // the damaged entry. More seriously, the memory synchronization is needed | |
105 // to flush other fields (f1, f2) completely to memory before the bytecodes | |
106 // are updated, lest other processors see a non-zero bytecode but zero f1/f2. | |
107 void ConstantPoolCacheEntry::set_field(Bytecodes::Code get_code, | |
108 Bytecodes::Code put_code, | |
109 KlassHandle field_holder, | |
110 int orig_field_index, | |
111 int field_offset, | |
112 TosState field_type, | |
113 bool is_final, | |
114 bool is_volatile) { | |
115 set_f1(field_holder()); | |
116 set_f2(field_offset); | |
117 // The field index is used by jvm/ti and is the index into fields() array | |
118 // in holder instanceKlass. This is scaled by instanceKlass::next_offset. | |
119 assert((orig_field_index % instanceKlass::next_offset) == 0, "wierd index"); | |
120 const int field_index = orig_field_index / instanceKlass::next_offset; | |
121 assert(field_index <= field_index_mask, | |
122 "field index does not fit in low flag bits"); | |
123 set_flags(as_flags(field_type, is_final, false, is_volatile, false, false) | | |
124 (field_index & field_index_mask)); | |
125 set_bytecode_1(get_code); | |
126 set_bytecode_2(put_code); | |
127 NOT_PRODUCT(verify(tty)); | |
128 } | |
129 | |
130 int ConstantPoolCacheEntry::field_index() const { | |
131 return (_flags & field_index_mask) * instanceKlass::next_offset; | |
132 } | |
133 | |
134 void ConstantPoolCacheEntry::set_method(Bytecodes::Code invoke_code, | |
135 methodHandle method, | |
136 int vtable_index) { | |
137 | |
138 assert(method->interpreter_entry() != NULL, "should have been set at this point"); | |
139 assert(!method->is_obsolete(), "attempt to write obsolete method to cpCache"); | |
140 bool change_to_virtual = (invoke_code == Bytecodes::_invokeinterface); | |
141 | |
142 int byte_no = -1; | |
143 bool needs_vfinal_flag = false; | |
144 switch (invoke_code) { | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
196
diff
changeset
|
145 case Bytecodes::_invokedynamic: |
0 | 146 case Bytecodes::_invokevirtual: |
147 case Bytecodes::_invokeinterface: { | |
148 if (method->can_be_statically_bound()) { | |
149 set_f2((intptr_t)method()); | |
150 needs_vfinal_flag = true; | |
151 } else { | |
152 assert(vtable_index >= 0, "valid index"); | |
153 set_f2(vtable_index); | |
154 } | |
155 byte_no = 2; | |
156 break; | |
157 } | |
158 case Bytecodes::_invokespecial: | |
159 // Preserve the value of the vfinal flag on invokevirtual bytecode | |
160 // which may be shared with this constant pool cache entry. | |
161 needs_vfinal_flag = is_resolved(Bytecodes::_invokevirtual) && is_vfinal(); | |
162 // fall through | |
163 case Bytecodes::_invokestatic: | |
164 set_f1(method()); | |
165 byte_no = 1; | |
166 break; | |
167 default: | |
168 ShouldNotReachHere(); | |
169 break; | |
170 } | |
171 | |
172 set_flags(as_flags(as_TosState(method->result_type()), | |
173 method->is_final_method(), | |
174 needs_vfinal_flag, | |
175 false, | |
176 change_to_virtual, | |
177 true)| | |
178 method()->size_of_parameters()); | |
179 | |
180 // Note: byte_no also appears in TemplateTable::resolve. | |
181 if (byte_no == 1) { | |
182 set_bytecode_1(invoke_code); | |
183 } else if (byte_no == 2) { | |
184 if (change_to_virtual) { | |
185 // NOTE: THIS IS A HACK - BE VERY CAREFUL!!! | |
186 // | |
187 // Workaround for the case where we encounter an invokeinterface, but we | |
188 // should really have an _invokevirtual since the resolved method is a | |
189 // virtual method in java.lang.Object. This is a corner case in the spec | |
190 // but is presumably legal. javac does not generate this code. | |
191 // | |
192 // We set bytecode_1() to _invokeinterface, because that is the | |
193 // bytecode # used by the interpreter to see if it is resolved. | |
194 // We set bytecode_2() to _invokevirtual. | |
195 // See also interpreterRuntime.cpp. (8/25/2000) | |
196 // Only set resolved for the invokeinterface case if method is public. | |
197 // Otherwise, the method needs to be reresolved with caller for each | |
198 // interface call. | |
199 if (method->is_public()) set_bytecode_1(invoke_code); | |
200 set_bytecode_2(Bytecodes::_invokevirtual); | |
201 } else { | |
202 set_bytecode_2(invoke_code); | |
203 } | |
204 } else { | |
205 ShouldNotReachHere(); | |
206 } | |
207 NOT_PRODUCT(verify(tty)); | |
208 } | |
209 | |
210 | |
211 void ConstantPoolCacheEntry::set_interface_call(methodHandle method, int index) { | |
212 klassOop interf = method->method_holder(); | |
213 assert(instanceKlass::cast(interf)->is_interface(), "must be an interface"); | |
214 set_f1(interf); | |
215 set_f2(index); | |
216 set_flags(as_flags(as_TosState(method->result_type()), method->is_final_method(), false, false, false, true) | method()->size_of_parameters()); | |
217 set_bytecode_1(Bytecodes::_invokeinterface); | |
218 } | |
219 | |
220 | |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1059
diff
changeset
|
221 void ConstantPoolCacheEntry::set_dynamic_call(Handle call_site, |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1059
diff
changeset
|
222 methodHandle signature_invoker) { |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1059
diff
changeset
|
223 int param_size = signature_invoker->size_of_parameters(); |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
844
diff
changeset
|
224 assert(param_size >= 1, "method argument size must include MH.this"); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
196
diff
changeset
|
225 param_size -= 1; // do not count MH.this; it is not stacked for invokedynamic |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
196
diff
changeset
|
226 if (Atomic::cmpxchg_ptr(call_site(), &_f1, NULL) == NULL) { |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
196
diff
changeset
|
227 // racing threads might be trying to install their own favorites |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
196
diff
changeset
|
228 set_f1(call_site()); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
196
diff
changeset
|
229 } |
1507
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1059
diff
changeset
|
230 //set_f2(0); |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1059
diff
changeset
|
231 bool is_final = true; |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1059
diff
changeset
|
232 assert(signature_invoker->is_final_method(), "is_final"); |
cd5dbf694d45
6939134: JSR 292 adjustments to method handle invocation
jrose
parents:
1059
diff
changeset
|
233 set_flags(as_flags(as_TosState(signature_invoker->result_type()), is_final, false, false, false, true) | param_size); |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
196
diff
changeset
|
234 // do not do set_bytecode on a secondary CP cache entry |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
196
diff
changeset
|
235 //set_bytecode_1(Bytecodes::_invokedynamic); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
196
diff
changeset
|
236 } |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
196
diff
changeset
|
237 |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
196
diff
changeset
|
238 |
0 | 239 class LocalOopClosure: public OopClosure { |
240 private: | |
241 void (*_f)(oop*); | |
242 | |
243 public: | |
244 LocalOopClosure(void f(oop*)) { _f = f; } | |
245 virtual void do_oop(oop* o) { _f(o); } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
246 virtual void do_oop(narrowOop *o) { ShouldNotReachHere(); } |
0 | 247 }; |
248 | |
249 | |
250 void ConstantPoolCacheEntry::oops_do(void f(oop*)) { | |
251 LocalOopClosure blk(f); | |
252 oop_iterate(&blk); | |
253 } | |
254 | |
255 | |
256 void ConstantPoolCacheEntry::oop_iterate(OopClosure* blk) { | |
257 assert(in_words(size()) == 4, "check code below - may need adjustment"); | |
258 // field[1] is always oop or NULL | |
259 blk->do_oop((oop*)&_f1); | |
260 if (is_vfinal()) { | |
261 blk->do_oop((oop*)&_f2); | |
262 } | |
263 } | |
264 | |
265 | |
266 void ConstantPoolCacheEntry::oop_iterate_m(OopClosure* blk, MemRegion mr) { | |
267 assert(in_words(size()) == 4, "check code below - may need adjustment"); | |
268 // field[1] is always oop or NULL | |
269 if (mr.contains((oop *)&_f1)) blk->do_oop((oop*)&_f1); | |
270 if (is_vfinal()) { | |
271 if (mr.contains((oop *)&_f2)) blk->do_oop((oop*)&_f2); | |
272 } | |
273 } | |
274 | |
275 | |
276 void ConstantPoolCacheEntry::follow_contents() { | |
277 assert(in_words(size()) == 4, "check code below - may need adjustment"); | |
278 // field[1] is always oop or NULL | |
279 MarkSweep::mark_and_push((oop*)&_f1); | |
280 if (is_vfinal()) { | |
281 MarkSweep::mark_and_push((oop*)&_f2); | |
282 } | |
283 } | |
284 | |
285 #ifndef SERIALGC | |
286 void ConstantPoolCacheEntry::follow_contents(ParCompactionManager* cm) { | |
287 assert(in_words(size()) == 4, "check code below - may need adjustment"); | |
288 // field[1] is always oop or NULL | |
289 PSParallelCompact::mark_and_push(cm, (oop*)&_f1); | |
290 if (is_vfinal()) { | |
291 PSParallelCompact::mark_and_push(cm, (oop*)&_f2); | |
292 } | |
293 } | |
294 #endif // SERIALGC | |
295 | |
296 void ConstantPoolCacheEntry::adjust_pointers() { | |
297 assert(in_words(size()) == 4, "check code below - may need adjustment"); | |
298 // field[1] is always oop or NULL | |
299 MarkSweep::adjust_pointer((oop*)&_f1); | |
300 if (is_vfinal()) { | |
301 MarkSweep::adjust_pointer((oop*)&_f2); | |
302 } | |
303 } | |
304 | |
305 #ifndef SERIALGC | |
306 void ConstantPoolCacheEntry::update_pointers() { | |
307 assert(in_words(size()) == 4, "check code below - may need adjustment"); | |
308 // field[1] is always oop or NULL | |
309 PSParallelCompact::adjust_pointer((oop*)&_f1); | |
310 if (is_vfinal()) { | |
311 PSParallelCompact::adjust_pointer((oop*)&_f2); | |
312 } | |
313 } | |
314 | |
315 void ConstantPoolCacheEntry::update_pointers(HeapWord* beg_addr, | |
316 HeapWord* end_addr) { | |
317 assert(in_words(size()) == 4, "check code below - may need adjustment"); | |
318 // field[1] is always oop or NULL | |
319 PSParallelCompact::adjust_pointer((oop*)&_f1, beg_addr, end_addr); | |
320 if (is_vfinal()) { | |
321 PSParallelCompact::adjust_pointer((oop*)&_f2, beg_addr, end_addr); | |
322 } | |
323 } | |
324 #endif // SERIALGC | |
325 | |
326 // RedefineClasses() API support: | |
327 // If this constantPoolCacheEntry refers to old_method then update it | |
328 // to refer to new_method. | |
329 bool ConstantPoolCacheEntry::adjust_method_entry(methodOop old_method, | |
330 methodOop new_method, bool * trace_name_printed) { | |
331 | |
332 if (is_vfinal()) { | |
333 // virtual and final so f2() contains method ptr instead of vtable index | |
334 if (f2() == (intptr_t)old_method) { | |
335 // match old_method so need an update | |
336 _f2 = (intptr_t)new_method; | |
337 if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) { | |
338 if (!(*trace_name_printed)) { | |
339 // RC_TRACE_MESG macro has an embedded ResourceMark | |
340 RC_TRACE_MESG(("adjust: name=%s", | |
341 Klass::cast(old_method->method_holder())->external_name())); | |
342 *trace_name_printed = true; | |
343 } | |
344 // RC_TRACE macro has an embedded ResourceMark | |
345 RC_TRACE(0x00400000, ("cpc vf-entry update: %s(%s)", | |
346 new_method->name()->as_C_string(), | |
347 new_method->signature()->as_C_string())); | |
348 } | |
349 | |
350 return true; | |
351 } | |
352 | |
353 // f1() is not used with virtual entries so bail out | |
354 return false; | |
355 } | |
356 | |
357 if ((oop)_f1 == NULL) { | |
358 // NULL f1() means this is a virtual entry so bail out | |
359 // We are assuming that the vtable index does not need change. | |
360 return false; | |
361 } | |
362 | |
363 if ((oop)_f1 == old_method) { | |
364 _f1 = new_method; | |
365 if (RC_TRACE_IN_RANGE(0x00100000, 0x00400000)) { | |
366 if (!(*trace_name_printed)) { | |
367 // RC_TRACE_MESG macro has an embedded ResourceMark | |
368 RC_TRACE_MESG(("adjust: name=%s", | |
369 Klass::cast(old_method->method_holder())->external_name())); | |
370 *trace_name_printed = true; | |
371 } | |
372 // RC_TRACE macro has an embedded ResourceMark | |
373 RC_TRACE(0x00400000, ("cpc entry update: %s(%s)", | |
374 new_method->name()->as_C_string(), | |
375 new_method->signature()->as_C_string())); | |
376 } | |
377 | |
378 return true; | |
379 } | |
380 | |
381 return false; | |
382 } | |
383 | |
384 bool ConstantPoolCacheEntry::is_interesting_method_entry(klassOop k) { | |
385 if (!is_method_entry()) { | |
386 // not a method entry so not interesting by default | |
387 return false; | |
388 } | |
389 | |
390 methodOop m = NULL; | |
391 if (is_vfinal()) { | |
392 // virtual and final so _f2 contains method ptr instead of vtable index | |
393 m = (methodOop)_f2; | |
394 } else if ((oop)_f1 == NULL) { | |
395 // NULL _f1 means this is a virtual entry so also not interesting | |
396 return false; | |
397 } else { | |
398 if (!((oop)_f1)->is_method()) { | |
399 // _f1 can also contain a klassOop for an interface | |
400 return false; | |
401 } | |
402 m = (methodOop)_f1; | |
403 } | |
404 | |
405 assert(m != NULL && m->is_method(), "sanity check"); | |
406 if (m == NULL || !m->is_method() || m->method_holder() != k) { | |
407 // robustness for above sanity checks or method is not in | |
408 // the interesting class | |
409 return false; | |
410 } | |
411 | |
412 // the method is in the interesting class so the entry is interesting | |
413 return true; | |
414 } | |
415 | |
416 void ConstantPoolCacheEntry::print(outputStream* st, int index) const { | |
417 // print separator | |
418 if (index == 0) tty->print_cr(" -------------"); | |
419 // print entry | |
726
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
196
diff
changeset
|
420 tty->print_cr("%3d (%08x) ", index, this); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
196
diff
changeset
|
421 if (is_secondary_entry()) |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
196
diff
changeset
|
422 tty->print_cr("[%5d|secondary]", main_entry_index()); |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
196
diff
changeset
|
423 else |
be93aad57795
6655646: dynamic languages need dynamically linked call sites
jrose
parents:
196
diff
changeset
|
424 tty->print_cr("[%02x|%02x|%5d]", bytecode_2(), bytecode_1(), constant_pool_index()); |
0 | 425 tty->print_cr(" [ %08x]", (address)(oop)_f1); |
426 tty->print_cr(" [ %08x]", _f2); | |
427 tty->print_cr(" [ %08x]", _flags); | |
428 tty->print_cr(" -------------"); | |
429 } | |
430 | |
431 void ConstantPoolCacheEntry::verify(outputStream* st) const { | |
432 // not implemented yet | |
433 } | |
434 | |
435 // Implementation of ConstantPoolCache | |
436 | |
437 void constantPoolCacheOopDesc::initialize(intArray& inverse_index_map) { | |
438 assert(inverse_index_map.length() == length(), "inverse index map must have same length as cache"); | |
1059
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
844
diff
changeset
|
439 for (int i = 0; i < length(); i++) { |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
844
diff
changeset
|
440 ConstantPoolCacheEntry* e = entry_at(i); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
844
diff
changeset
|
441 int original_index = inverse_index_map[i]; |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
844
diff
changeset
|
442 if ((original_index & Rewriter::_secondary_entry_tag) != 0) { |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
844
diff
changeset
|
443 int main_index = (original_index - Rewriter::_secondary_entry_tag); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
844
diff
changeset
|
444 assert(!entry_at(main_index)->is_secondary_entry(), "valid main index"); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
844
diff
changeset
|
445 e->initialize_secondary_entry(main_index); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
844
diff
changeset
|
446 } else { |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
844
diff
changeset
|
447 e->initialize_entry(original_index); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
844
diff
changeset
|
448 } |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
844
diff
changeset
|
449 assert(entry_at(i) == e, "sanity"); |
389049f3f393
6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents:
844
diff
changeset
|
450 } |
0 | 451 } |
452 | |
453 // RedefineClasses() API support: | |
454 // If any entry of this constantPoolCache points to any of | |
455 // old_methods, replace it with the corresponding new_method. | |
456 void constantPoolCacheOopDesc::adjust_method_entries(methodOop* old_methods, methodOop* new_methods, | |
457 int methods_length, bool * trace_name_printed) { | |
458 | |
459 if (methods_length == 0) { | |
460 // nothing to do if there are no methods | |
461 return; | |
462 } | |
463 | |
464 // get shorthand for the interesting class | |
465 klassOop old_holder = old_methods[0]->method_holder(); | |
466 | |
467 for (int i = 0; i < length(); i++) { | |
468 if (!entry_at(i)->is_interesting_method_entry(old_holder)) { | |
469 // skip uninteresting methods | |
470 continue; | |
471 } | |
472 | |
473 // The constantPoolCache contains entries for several different | |
474 // things, but we only care about methods. In fact, we only care | |
475 // about methods in the same class as the one that contains the | |
476 // old_methods. At this point, we have an interesting entry. | |
477 | |
478 for (int j = 0; j < methods_length; j++) { | |
479 methodOop old_method = old_methods[j]; | |
480 methodOop new_method = new_methods[j]; | |
481 | |
482 if (entry_at(i)->adjust_method_entry(old_method, new_method, | |
483 trace_name_printed)) { | |
484 // current old_method matched this entry and we updated it so | |
485 // break out and get to the next interesting entry if there one | |
486 break; | |
487 } | |
488 } | |
489 } | |
490 } |