194 if (do_resolve) {
195 method_entry->set_bytecode1(invoke_code);
196 }
197 } else if (byte_no == 2) {
198 if (change_to_virtual) {
199 assert(invoke_code == Bytecodes::_invokeinterface, "");
200 // NOTE: THIS IS A HACK - BE VERY CAREFUL!!!
201 //
202 // Workaround for the case where we encounter an invokeinterface, but we
203 // should really have an _invokevirtual since the resolved method is a
204 // virtual method in java.lang.Object. This is a corner case in the spec
205 // but is presumably legal. javac does not generate this code.
206 //
207 // We do not set bytecode_1() to _invokeinterface, because that is the
208 // bytecode # used by the interpreter to see if it is resolved. In this
209 // case, the method gets reresolved with caller for each interface call
210 // because the actual selected method may not be public.
211 //
212 // We set bytecode_2() to _invokevirtual.
213 // See also interpreterRuntime.cpp. (8/25/2000)
214 } else {
215 assert(invoke_code == Bytecodes::_invokevirtual ||
216 (invoke_code == Bytecodes::_invokeinterface &&
217 ((method->is_private() ||
218 (method->is_final() && method->method_holder() == vmClasses::Object_klass())))),
219 "unexpected invocation mode");
220 if (invoke_code == Bytecodes::_invokeinterface &&
221 (method->is_private() || method->is_final())) {
222 // We set bytecode_1() to _invokeinterface, because that is the
223 // bytecode # used by the interpreter to see if it is resolved.
224 // We set bytecode_2() to _invokevirtual.
225 method_entry->set_bytecode1(invoke_code);
226 }
227 }
228 // set up for invokevirtual, even if linking for invokeinterface also:
229 method_entry->set_bytecode2(Bytecodes::_invokevirtual);
230 } else {
231 ShouldNotReachHere();
232 }
233 }
234
235 void ConstantPoolCache::set_direct_call(Bytecodes::Code invoke_code, int method_index, const methodHandle& method,
236 bool sender_is_interface) {
237 int index = Method::nonvirtual_vtable_index;
238 // index < 0; FIXME: inline and customize set_direct_or_vtable_call
239 set_direct_or_vtable_call(invoke_code, method_index, method, index, sender_is_interface);
240 }
241
242 void ConstantPoolCache::set_vtable_call(Bytecodes::Code invoke_code, int method_index, const methodHandle& method, int index) {
243 // either the method is a miranda or its holder should accept the given index
244 assert(method->method_holder()->is_interface() || method->method_holder()->verify_vtable_index(index), "");
245 // index >= 0; FIXME: inline and customize set_direct_or_vtable_call
246 set_direct_or_vtable_call(invoke_code, method_index, method, index, false);
247 }
248
249 void ConstantPoolCache::set_itable_call(Bytecodes::Code invoke_code,
|
194 if (do_resolve) {
195 method_entry->set_bytecode1(invoke_code);
196 }
197 } else if (byte_no == 2) {
198 if (change_to_virtual) {
199 assert(invoke_code == Bytecodes::_invokeinterface, "");
200 // NOTE: THIS IS A HACK - BE VERY CAREFUL!!!
201 //
202 // Workaround for the case where we encounter an invokeinterface, but we
203 // should really have an _invokevirtual since the resolved method is a
204 // virtual method in java.lang.Object. This is a corner case in the spec
205 // but is presumably legal. javac does not generate this code.
206 //
207 // We do not set bytecode_1() to _invokeinterface, because that is the
208 // bytecode # used by the interpreter to see if it is resolved. In this
209 // case, the method gets reresolved with caller for each interface call
210 // because the actual selected method may not be public.
211 //
212 // We set bytecode_2() to _invokevirtual.
213 // See also interpreterRuntime.cpp. (8/25/2000)
214 invoke_code = Bytecodes::_invokevirtual;
215 } else {
216 assert(invoke_code == Bytecodes::_invokevirtual ||
217 (invoke_code == Bytecodes::_invokeinterface &&
218 ((method->is_private() ||
219 (method->is_final() && method->method_holder() == vmClasses::Object_klass())))),
220 "unexpected invocation mode");
221 if (invoke_code == Bytecodes::_invokeinterface &&
222 (method->is_private() || method->is_final())) {
223 // We set bytecode_1() to _invokeinterface, because that is the
224 // bytecode # used by the interpreter to see if it is resolved.
225 // We set bytecode_2() to _invokevirtual.
226 method_entry->set_bytecode1(invoke_code);
227 }
228 }
229 // set up for invokevirtual, even if linking for invokeinterface also:
230 method_entry->set_bytecode2(invoke_code);
231 } else {
232 ShouldNotReachHere();
233 }
234 }
235
236 void ConstantPoolCache::set_direct_call(Bytecodes::Code invoke_code, int method_index, const methodHandle& method,
237 bool sender_is_interface) {
238 int index = Method::nonvirtual_vtable_index;
239 // index < 0; FIXME: inline and customize set_direct_or_vtable_call
240 set_direct_or_vtable_call(invoke_code, method_index, method, index, sender_is_interface);
241 }
242
243 void ConstantPoolCache::set_vtable_call(Bytecodes::Code invoke_code, int method_index, const methodHandle& method, int index) {
244 // either the method is a miranda or its holder should accept the given index
245 assert(method->method_holder()->is_interface() || method->method_holder()->verify_vtable_index(index), "");
246 // index >= 0; FIXME: inline and customize set_direct_or_vtable_call
247 set_direct_or_vtable_call(invoke_code, method_index, method, index, false);
248 }
249
250 void ConstantPoolCache::set_itable_call(Bytecodes::Code invoke_code,
|