annotate src/share/vm/oops/cpCacheOop.cpp @ 1552:c18cbe5936b8

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