< prev index next >

src/hotspot/share/oops/cpCache.cpp

Print this page

193     if (do_resolve) {
194       method_entry->set_bytecode1(invoke_code);
195     }
196   } else if (byte_no == 2)  {
197     if (change_to_virtual) {
198       assert(invoke_code == Bytecodes::_invokeinterface, "");
199       // NOTE: THIS IS A HACK - BE VERY CAREFUL!!!
200       //
201       // Workaround for the case where we encounter an invokeinterface, but we
202       // should really have an _invokevirtual since the resolved method is a
203       // virtual method in java.lang.Object. This is a corner case in the spec
204       // but is presumably legal. javac does not generate this code.
205       //
206       // We do not set bytecode_1() to _invokeinterface, because that is the
207       // bytecode # used by the interpreter to see if it is resolved.  In this
208       // case, the method gets reresolved with caller for each interface call
209       // because the actual selected method may not be public.
210       //
211       // We set bytecode_2() to _invokevirtual.
212       // See also interpreterRuntime.cpp. (8/25/2000)

213     } else {
214       assert(invoke_code == Bytecodes::_invokevirtual ||
215              (invoke_code == Bytecodes::_invokeinterface &&
216               ((method->is_private() ||
217                 (method->is_final() && method->method_holder() == vmClasses::Object_klass())))),
218              "unexpected invocation mode");
219       if (invoke_code == Bytecodes::_invokeinterface &&
220           (method->is_private() || method->is_final())) {
221         // We set bytecode_1() to _invokeinterface, because that is the
222         // bytecode # used by the interpreter to see if it is resolved.
223         // We set bytecode_2() to _invokevirtual.
224         method_entry->set_bytecode1(invoke_code);
225       }
226     }
227     // set up for invokevirtual, even if linking for invokeinterface also:
228     method_entry->set_bytecode2(Bytecodes::_invokevirtual);
229   } else {
230     ShouldNotReachHere();
231   }
232 }
233 
234 void ConstantPoolCache::set_direct_call(Bytecodes::Code invoke_code, int method_index, const methodHandle& method,
235                                         bool sender_is_interface) {
236   int index = Method::nonvirtual_vtable_index;
237   // index < 0; FIXME: inline and customize set_direct_or_vtable_call
238   set_direct_or_vtable_call(invoke_code, method_index, method, index, sender_is_interface);
239 }
240 
241 void ConstantPoolCache::set_vtable_call(Bytecodes::Code invoke_code, int method_index, const methodHandle& method, int index) {
242   // either the method is a miranda or its holder should accept the given index
243   assert(method->method_holder()->is_interface() || method->method_holder()->verify_vtable_index(index), "");
244   // index >= 0; FIXME: inline and customize set_direct_or_vtable_call
245   set_direct_or_vtable_call(invoke_code, method_index, method, index, false);
246 }
247 
248 void ConstantPoolCache::set_itable_call(Bytecodes::Code invoke_code,

193     if (do_resolve) {
194       method_entry->set_bytecode1(invoke_code);
195     }
196   } else if (byte_no == 2)  {
197     if (change_to_virtual) {
198       assert(invoke_code == Bytecodes::_invokeinterface, "");
199       // NOTE: THIS IS A HACK - BE VERY CAREFUL!!!
200       //
201       // Workaround for the case where we encounter an invokeinterface, but we
202       // should really have an _invokevirtual since the resolved method is a
203       // virtual method in java.lang.Object. This is a corner case in the spec
204       // but is presumably legal. javac does not generate this code.
205       //
206       // We do not set bytecode_1() to _invokeinterface, because that is the
207       // bytecode # used by the interpreter to see if it is resolved.  In this
208       // case, the method gets reresolved with caller for each interface call
209       // because the actual selected method may not be public.
210       //
211       // We set bytecode_2() to _invokevirtual.
212       // See also interpreterRuntime.cpp. (8/25/2000)
213       invoke_code = Bytecodes::_invokevirtual;
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(invoke_code);
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,
< prev index next >