@@ -754,18 +754,21 @@ private static int determineITableStartingIndex(DynamicHub thisHub, int interfac
754754 public static Object dispatchInvocation (InterpreterResolvedJavaMethod seedMethod , Object [] calleeArgs , boolean isVirtual0 , boolean forceStayInInterpreter , boolean preferStayInInterpreter ,
755755 boolean isInvokeInterface , boolean quiet )
756756 throws SemanticJavaException {
757- boolean goThroughPLT ;
757+ // True if we need to go through the platform ABI, e.g. calling an entry point of a
758+ // compilation unit.
759+ boolean callCompiledTarget ;
760+
758761 boolean isVirtual = isVirtual0 ;
759762
760763 if (forceStayInInterpreter ) {
761764 // Force execution in the interpreter, transitively, for all callees in the call
762765 // subtree.
763- goThroughPLT = false ;
766+ callCompiledTarget = false ;
764767 } else {
765768 // Not forced to transitively "stay in interpreter"; but still; it may be "preferred" to
766769 // execute this callee (and only this one) in the interpreter, if possible e.g. Step
767770 // Into.
768- goThroughPLT = !preferStayInInterpreter ;
771+ callCompiledTarget = !preferStayInInterpreter ;
769772 }
770773
771774 InterpreterResolvedObjectType seedDeclaringClass = seedMethod .getDeclaringClass ();
@@ -776,7 +779,7 @@ public static Object dispatchInvocation(InterpreterResolvedJavaMethod seedMethod
776779
777780 CFunctionPointer calleeFtnPtr = Word .nullPointer ();
778781
779- if (goThroughPLT ) {
782+ if (callCompiledTarget ) {
780783 if (seedMethod .hasNativeEntryPoint ()) {
781784 calleeFtnPtr = seedMethod .getNativeEntryPoint ();
782785 if (!quiet ) {
@@ -789,16 +792,16 @@ public static Object dispatchInvocation(InterpreterResolvedJavaMethod seedMethod
789792 */
790793 // InterpreterUtil.guarantee(!isVirtual, "leaveInterpreter is virtual %s",
791794 // seedMethod);
792- goThroughPLT = false ;
795+ callCompiledTarget = false ;
793796
794797 /* arguments to Log methods might have side-effects */
795798 if (InterpreterTraceSupport .getValue () && !quiet ) {
796799 traceInterpreter ("fall back to interp for compile entry " ).string (seedMethod .toString ()).string (" because it has not been compiled." ).newline ();
797800 }
798801 } else if (seedMethod .getVTableIndex () == VTBL_ONE_IMPL ) {
799- goThroughPLT = seedMethod .getOneImplementation ().hasNativeEntryPoint ();
802+ callCompiledTarget = seedMethod .getOneImplementation ().hasNativeEntryPoint ();
800803 } else if (!isVirtual && seedMethod .hasVTableIndex ()) {
801- goThroughPLT = false ;
804+ callCompiledTarget = false ;
802805 /* arguments to Log methods might have side-effects */
803806 if (InterpreterTraceSupport .getValue () && !quiet ) {
804807 traceInterpreter ("invokespecial: " ).string (seedMethod .toString ()).newline ();
@@ -827,14 +830,14 @@ public static Object dispatchInvocation(InterpreterResolvedJavaMethod seedMethod
827830 Class <?> seedClazz = seedDeclaringClass .getJavaClass ();
828831 int vtableIndex = seedMethod .getVTableIndex ();
829832
830- if (goThroughPLT ) {
833+ if (callCompiledTarget ) {
831834 // determine virtual call target via SVM vtable dispatch
832835 calleeFtnPtr = peekAtSVMVTable (seedClazz , thisClazz , vtableIndex , isInvokeInterface );
833836
834837 if (calleeFtnPtr .equal (InterpreterMethodPointerHolder .getMethodNotCompiledHandler ())) {
835838 // can happen e.g. due to devirtualization, need to stay in interpreter in
836839 // this scenario
837- goThroughPLT = false ;
840+ callCompiledTarget = false ;
838841
839842 /* arguments to Log methods might have side-effects */
840843 if (InterpreterTraceSupport .getValue () && !quiet ) {
@@ -850,7 +853,7 @@ public static Object dispatchInvocation(InterpreterResolvedJavaMethod seedMethod
850853 /* arguments to Log methods might have side-effects */
851854 if (InterpreterTraceSupport .getValue () && !quiet ) {
852855 traceInterpreter ("found oneImpl: " ).string (targetMethod .toString ());
853- if (goThroughPLT ) {
856+ if (callCompiledTarget ) {
854857 calleeFtnPtr = targetMethod .getNativeEntryPoint ();
855858 traceInterpreter (" ... with compiled entry=" ).hex (calleeFtnPtr );
856859 }
@@ -859,27 +862,27 @@ public static Object dispatchInvocation(InterpreterResolvedJavaMethod seedMethod
859862 VMError .guarantee (targetMethod != null , "VTBL_ONE_IMPL implies that oneImplementation is available in seedMethod" );
860863 }
861864
862- if (!targetMethod .hasBytecodes () && !goThroughPLT && calleeFtnPtr .isNonNull ()) {
863- goThroughPLT = true ;
865+ if (!targetMethod .hasBytecodes () && !callCompiledTarget && calleeFtnPtr .isNonNull ()) {
866+ callCompiledTarget = true ;
864867 /* arguments to Log methods might have side-effects */
865868 if (InterpreterTraceSupport .getValue () && !quiet ) {
866869 traceInterpreter ("cannot interpret " ).string (targetMethod .toString ()).string (" falling back to compiled version " ).hex (calleeFtnPtr ).newline ();
867870 }
868871 }
869872
870- if (!goThroughPLT && (targetMethod .isNative () && targetMethod .getSignaturePolymorphicIntrinsic () == null )) {
873+ if (!callCompiledTarget && (targetMethod .isNative () && targetMethod .getSignaturePolymorphicIntrinsic () == null )) {
871874 /* no way to execute target in interpreter, fall back to compiled code */
872875 VMError .guarantee (targetMethod .hasNativeEntryPoint ());
873876 calleeFtnPtr = targetMethod .getNativeEntryPoint ();
874877 VMError .guarantee (calleeFtnPtr .isNonNull ());
875- goThroughPLT = true ;
878+ callCompiledTarget = true ;
876879 }
877880
878881 /* arguments to Log methods might have side-effects */
879882 if (InterpreterOptions .InterpreterTraceSupport .getValue () && !quiet ) {
880883 traceInterpreter (" " .repeat (Interpreter .logIndent .get ()))
881884 .string (" -> calling (" )
882- .string (goThroughPLT ? "plt " : "interp" ).string (") " )
885+ .string (callCompiledTarget ? "compiled " : "interp" ).string (") " )
883886 .string (targetMethod .hasNativeEntryPoint () ? "(compiled entry available) " : "" );
884887 if (targetMethod .hasNativeEntryPoint ()) {
885888 traceInterpreter ("(addr: " ).hex (calleeFtnPtr ).string (" ) " );
@@ -891,10 +894,16 @@ public static Object dispatchInvocation(InterpreterResolvedJavaMethod seedMethod
891894 }
892895
893896 Object retObj = null ;
894- if (goThroughPLT ) {
897+ if (callCompiledTarget ) {
895898 VMError .guarantee (!forceStayInInterpreter );
896899 VMError .guarantee (calleeFtnPtr .isNonNull ());
897900
901+ // Note: This won't work when PLTGOT is involved, because each method will have its
902+ // unique PLT stub address.
903+ if (calleeFtnPtr .equal (InterpreterMethodPointerHolder .getMethodNotCompiledHandler ())) {
904+ VMError .shouldNotReachHere ("Trying to dispatch to compiled code for AOT method " + seedMethod + " but it was not compiled because it was not seen as reachable by analysis" );
905+ }
906+
898907 // wrapping of exceptions is done in leaveInterpreter
899908 retObj = InterpreterStubSection .leaveInterpreter (calleeFtnPtr , targetMethod , targetMethod .getDeclaringClass (), calleeArgs );
900909 } else {
0 commit comments