@@ -3583,14 +3583,46 @@ void TemplateTable::invokeinterface(int byte_no) {
35833583
35843584 prepare_invoke (byte_no, Rinterface_klass, Rret_addr, Rmethod, Rreceiver, Rflags, Rscratch1);
35853585
3586- // Get receiver klass.
3586+ // First check for Object case, then private interface method,
3587+ // then regular interface method.
3588+
3589+ // Get receiver klass - this is also a null check
35873590 __ null_check_throw (Rreceiver, oopDesc::klass_offset_in_bytes (), Rscratch2);
35883591 __ load_klass (Rrecv_klass, Rreceiver);
35893592
35903593 // Check corner case object method.
3591- Label LobjectMethod, L_no_such_interface, Lthrow_ame;
3594+ // Special case of invokeinterface called for virtual method of
3595+ // java.lang.Object. See ConstantPoolCacheEntry::set_method() for details:
3596+ // The invokeinterface was rewritten to a invokevirtual, hence we have
3597+ // to handle this corner case.
3598+
3599+ Label LnotObjectMethod, Lthrow_ame;
35923600 __ testbitdi (CCR0 , R0 , Rflags, ConstantPoolCacheEntry::is_forced_virtual_shift);
3593- __ btrue (CCR0 , LobjectMethod);
3601+ __ bfalse (CCR0 , LnotObjectMethod);
3602+ invokeinterface_object_method (Rrecv_klass, Rret_addr, Rflags, Rmethod, Rscratch1, Rscratch2);
3603+ __ bind (LnotObjectMethod);
3604+
3605+ // Check for private method invocation - indicated by vfinal
3606+ Label LnotVFinal, L_no_such_interface, L_subtype;
3607+
3608+ __ testbitdi (CCR0 , R0 , Rflags, ConstantPoolCacheEntry::is_vfinal_shift);
3609+ __ bfalse (CCR0 , LnotVFinal);
3610+
3611+ __ check_klass_subtype (Rrecv_klass, Rinterface_klass, Rscratch1, Rscratch2, L_subtype);
3612+ // If we get here the typecheck failed
3613+ __ b (L_no_such_interface);
3614+ __ bind (L_subtype);
3615+
3616+ // do the call
3617+
3618+ Register Rscratch = Rflags; // Rflags is dead now.
3619+
3620+ __ profile_final_call (Rscratch1, Rscratch);
3621+ __ profile_arguments_type (Rindex, Rscratch, Rrecv_klass /* scratch */ , true );
3622+
3623+ __ call_from_interpreter (Rindex, Rret_addr, Rscratch, Rrecv_klass /* scratch */ );
3624+
3625+ __ bind (LnotVFinal);
35943626
35953627 __ lookup_interface_method (Rrecv_klass, Rinterface_klass, noreg, noreg, Rscratch1, Rscratch2,
35963628 L_no_such_interface, /* return_method=*/ false );
@@ -3631,14 +3663,6 @@ void TemplateTable::invokeinterface(int byte_no) {
36313663 call_VM (noreg, CAST_FROM_FN_PTR (address, InterpreterRuntime::throw_IncompatibleClassChangeErrorVerbose),
36323664 Rrecv_klass, Rinterface_klass);
36333665 DEBUG_ONLY ( __ should_not_reach_here (); )
3634-
3635- // Special case of invokeinterface called for virtual method of
3636- // java.lang.Object. See ConstantPoolCacheEntry::set_method() for details:
3637- // The invokeinterface was rewritten to a invokevirtual, hence we have
3638- // to handle this corner case. This code isn't produced by javac, but could
3639- // be produced by another compliant java compiler.
3640- __ bind (LobjectMethod);
3641- invokeinterface_object_method (Rrecv_klass, Rret_addr, Rflags, Rmethod, Rscratch1, Rscratch2);
36423666}
36433667
36443668void TemplateTable::invokedynamic (int byte_no) {
0 commit comments