This is an automated email from the ASF dual-hosted git repository. emilles pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/groovy.git
commit 99aa8bdb4ecb19e3b3b8e2ba813137b8d160f747 Author: Eric Milles <eric.mil...@thomsonreuters.com> AuthorDate: Fri Apr 5 19:19:52 2024 -0500 minor items --- .../codehaus/groovy/vmplugin/v8/IndyInterface.java | 31 +++++++++------------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v8/IndyInterface.java b/src/main/java/org/codehaus/groovy/vmplugin/v8/IndyInterface.java index b719d5e641..606328a1ea 100644 --- a/src/main/java/org/codehaus/groovy/vmplugin/v8/IndyInterface.java +++ b/src/main/java/org/codehaus/groovy/vmplugin/v8/IndyInterface.java @@ -346,25 +346,20 @@ public class IndyInterface { * Core method for indy method selection using runtime types. */ public static Object selectMethod(CacheableCallSite callSite, Class<?> sender, String methodName, int callID, Boolean safeNavigation, Boolean thisCall, Boolean spreadCall, Object dummyReceiver, Object[] arguments) throws Throwable { - final MethodHandleWrapper mhw = fallback(callSite, sender, methodName, callID, safeNavigation, thisCall, spreadCall, dummyReceiver, arguments); - - if (callSite instanceof CacheableCallSite) { - CacheableCallSite cacheableCallSite = (CacheableCallSite) callSite; - - final MethodHandle defaultTarget = cacheableCallSite.getDefaultTarget(); - final long fallbackCount = cacheableCallSite.incrementFallbackCount(); - if ((fallbackCount > INDY_FALLBACK_THRESHOLD) && (cacheableCallSite.getTarget() != defaultTarget)) { - cacheableCallSite.setTarget(defaultTarget); - if (LOG_ENABLED) LOG.info("call site target reset to default, preparing outside invocation"); - - cacheableCallSite.resetFallbackCount(); - } + MethodHandleWrapper mhw = fallback(callSite, sender, methodName, callID, safeNavigation, thisCall, spreadCall, dummyReceiver, arguments); + + MethodHandle defaultTarget = callSite.getDefaultTarget(); + long fallbackCount = callSite.incrementFallbackCount(); + if ((fallbackCount > INDY_FALLBACK_THRESHOLD) && (callSite.getTarget() != defaultTarget)) { + callSite.setTarget(defaultTarget); + if (LOG_ENABLED) LOG.info("call site target reset to default, preparing outside invocation"); + callSite.resetFallbackCount(); + } - if (defaultTarget == cacheableCallSite.getTarget()) { - // correct the stale methodhandle in the inline cache of callsite - // it is important but impacts the performance somehow when cache misses frequently - doWithCallSite(callSite, arguments, (cs, receiver) -> cs.put(receiver.getClass().getName(), mhw)); - } + if (callSite.getTarget() == defaultTarget) { + // correct the stale methodhandle in the inline cache of callsite + // it is important but impacts the performance somehow when cache misses frequently + doWithCallSite(callSite, arguments, (cs, receiver) -> cs.put(receiver.getClass().getName(), mhw)); } return mhw.getCachedMethodHandle().invokeExact(arguments);