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