You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2021/01/25 12:49:14 UTC
[groovy] branch GROOVY_3_0_X updated: GROOVY-9681: apply
GROOVY-9515 patch to v7.IndyInterface
This is an automated email from the ASF dual-hosted git repository.
sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/GROOVY_3_0_X by this push:
new 7391299 GROOVY-9681: apply GROOVY-9515 patch to v7.IndyInterface
7391299 is described below
commit 7391299b7c2400aa4eda638e5ca51221420d226e
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sun Jan 24 13:44:21 2021 -0600
GROOVY-9681: apply GROOVY-9515 patch to v7.IndyInterface
---
.../org/codehaus/groovy/vmplugin/v7/IndyInterface.java | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyInterface.java b/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyInterface.java
index fff40836..587241d 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyInterface.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v7/IndyInterface.java
@@ -32,6 +32,7 @@ import java.lang.invoke.MethodType;
import java.lang.invoke.MutableCallSite;
import java.lang.invoke.SwitchPoint;
import java.util.Map;
+import java.util.Optional;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.logging.Level;
@@ -50,6 +51,8 @@ import java.util.stream.Stream;
public class IndyInterface {
private static final long INDY_OPTIMIZE_THRESHOLD = SystemUtil.getLongSafe("groovy.indy.optimize.threshold", 100_000L);
+ private static final MethodHandleWrapper NULL_METHOD_HANDLE_WRAPPER = new MethodHandleWrapper(null, null, false);
+
/**
* flags for method and property calls
*/
@@ -258,13 +261,18 @@ public class IndyInterface {
MethodHandleWrapper mhw =
doWithCallSite(
callSite, arguments,
- (cs, receiver) ->
- cs.getAndPut(
+ (CacheableCallSite ccs, Object receiver) ->
+ ccs.getAndPut(
receiver.getClass().getName(),
- c -> fallback(callSite, sender, methodName, callID, safeNavigation, thisCall, spreadCall, dummyReceiver, arguments)
+ c -> Optional.of(fallback(callSite, sender, methodName, callID, safeNavigation, thisCall, spreadCall, dummyReceiver, arguments))
+ .filter(MethodHandleWrapper::isCanSetTarget).orElse(NULL_METHOD_HANDLE_WRAPPER)
)
);
+ if (mhw == NULL_METHOD_HANDLE_WRAPPER) {
+ mhw = fallback(callSite, sender, methodName, callID, safeNavigation, thisCall, spreadCall, dummyReceiver, arguments);
+ }
+
if (mhw.isCanSetTarget() && (callSite.getTarget() != mhw.getTargetMethodHandle()) && (mhw.getLatestHitCount() > INDY_OPTIMIZE_THRESHOLD)) {
callSite.setTarget(mhw.getTargetMethodHandle());
if (LOG_ENABLED) LOG.info("call site target set, preparing outside invocation");