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 2022/05/12 14:08:49 UTC

[groovy] 01/01: Remove guards for receiver and parameter

This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch danielsun/lab-indy-20220512
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 48f8e951121bc6ec56734cde2a8c6b97c6149081
Author: Daniel Sun <su...@apache.org>
AuthorDate: Thu May 12 22:08:19 2022 +0800

    Remove guards for receiver and parameter
---
 .../org/codehaus/groovy/vmplugin/v8/Selector.java  | 47 +++++++++++-----------
 1 file changed, 23 insertions(+), 24 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/vmplugin/v8/Selector.java b/src/main/java/org/codehaus/groovy/vmplugin/v8/Selector.java
index 3301c18225..7090cc519d 100644
--- a/src/main/java/org/codehaus/groovy/vmplugin/v8/Selector.java
+++ b/src/main/java/org/codehaus/groovy/vmplugin/v8/Selector.java
@@ -85,7 +85,6 @@ import static org.codehaus.groovy.vmplugin.v8.IndyGuardsFiltersAndSignatures.MOP
 import static org.codehaus.groovy.vmplugin.v8.IndyGuardsFiltersAndSignatures.MOP_INVOKE_CONSTRUCTOR;
 import static org.codehaus.groovy.vmplugin.v8.IndyGuardsFiltersAndSignatures.MOP_INVOKE_METHOD;
 import static org.codehaus.groovy.vmplugin.v8.IndyGuardsFiltersAndSignatures.NULL_REF;
-import static org.codehaus.groovy.vmplugin.v8.IndyGuardsFiltersAndSignatures.SAME_CLASS;
 import static org.codehaus.groovy.vmplugin.v8.IndyGuardsFiltersAndSignatures.SAME_MC;
 import static org.codehaus.groovy.vmplugin.v8.IndyGuardsFiltersAndSignatures.SAM_CONVERSION;
 import static org.codehaus.groovy.vmplugin.v8.IndyGuardsFiltersAndSignatures.UNWRAP_EXCEPTION;
@@ -922,29 +921,29 @@ public abstract class Selector {
             if (LOG_ENABLED) LOG.info("added switch point guard");
 
             // guards for receiver and parameter
-            Class<?>[] pt = handle.type().parameterArray();
-            for (int i = 0; i < args.length; i++) {
-                Object arg = args[i];
-                Class<?> paramType = pt[i];
-                MethodHandle test;
-
-                if (arg == null) {
-                    test = IS_NULL.asType(MethodType.methodType(boolean.class, paramType));
-                    if (LOG_ENABLED) LOG.info("added null argument check at pos " + i);
-                } else {
-                    Class<?> argClass = arg.getClass();
-                    if (paramType.isPrimitive()) continue;
-                    //if (Modifier.isFinal(argClass.getModifiers()) && TypeHelper.argumentClassIsParameterClass(argClass,pt[i])) continue;
-                    test = SAME_CLASS.
-                            bindTo(argClass).
-                            asType(MethodType.methodType(boolean.class, paramType));
-                    if (LOG_ENABLED) LOG.info("added same class check at pos " + i);
-                }
-                Class<?>[] drops = new Class[i];
-                System.arraycopy(pt, 0, drops, 0, drops.length);
-                test = MethodHandles.dropArguments(test, 0, drops);
-                handle = MethodHandles.guardWithTest(test, handle, fallback);
-            }
+//            Class<?>[] pt = handle.type().parameterArray();
+//            for (int i = 0; i < args.length; i++) {
+//                Object arg = args[i];
+//                Class<?> paramType = pt[i];
+//                MethodHandle test;
+//
+//                if (arg == null) {
+//                    test = IS_NULL.asType(MethodType.methodType(boolean.class, paramType));
+//                    if (LOG_ENABLED) LOG.info("added null argument check at pos " + i);
+//                } else {
+//                    Class<?> argClass = arg.getClass();
+//                    if (paramType.isPrimitive()) continue;
+//                    //if (Modifier.isFinal(argClass.getModifiers()) && TypeHelper.argumentClassIsParameterClass(argClass,pt[i])) continue;
+//                    test = SAME_CLASS.
+//                            bindTo(argClass).
+//                            asType(MethodType.methodType(boolean.class, paramType));
+//                    if (LOG_ENABLED) LOG.info("added same class check at pos " + i);
+//                }
+//                Class<?>[] drops = new Class[i];
+//                System.arraycopy(pt, 0, drops, 0, drops.length);
+//                test = MethodHandles.dropArguments(test, 0, drops);
+//                handle = MethodHandles.guardWithTest(test, handle, fallback);
+//            }
         }
 
         /**