< prev index next >

test/jdk/java/lang/invoke/common/test/java/lang/invoke/lib/InstructionHelper.java

Print this page
rev 47761 : 8186209: Tool support for ConstantDynamic
8186046: Minimal ConstantDynamic support
Reviewed-by: acorn
Contributed-by: lois.foltan@oracle.com, john.r.rose@oracle.com, paul.sandoz@oracle.com
* * *
Minor Hotspot code cleanup changes resulting from condy review
Summary: Addressed missing DynamicInError condition, removed unused TraceDynamicConstants
Reviewed-by: acorn, psandoz
rev 47762 : 8187742: Minimal set of bootstrap methods for constant dynamic
Contributed-by: brian.goetz@oracle.com, john.r.rose@oracle.com, paul.sandoz@oracle.com
Reviewed-by: forax


  73                                                               csym(l.lookupClass()), bsmMethodName, bsmType.toMethodDescriptorString(),
  74                                                               staticArgs);
  75                                               C.return_(BTH.tag(cref(type.returnType())));
  76                                           }
  77                                 ))
  78                 .build();
  79         Class<?> gc = l.defineClass(byteArray);
  80         return l.findStatic(gc, "m", type);
  81     }
  82 
  83     public static MethodHandle ldcMethodHandle(MethodHandles.Lookup l,
  84                                         int refKind, Class<?> owner, String name, MethodType type) throws Exception {
  85         return ldc(l, MethodHandle.class,
  86                    P -> P.putHandle(refKind, csym(owner), name, type.toMethodDescriptorString()));
  87     }
  88 
  89     public static MethodHandle ldcDynamicConstant(MethodHandles.Lookup l,
  90                                                   String name, Class<?> type,
  91                                                   String bsmMethodName, MethodType bsmType,
  92                                                   Consumer<PoolHelper.StaticArgListBuilder<String, String, byte[]>> staticArgs) throws Exception {
  93         return ldcDynamicConstant(l, name, cref(type), bsmMethodName, bsmType.toMethodDescriptorString(), staticArgs);







  94     }
  95 
  96     public static MethodHandle ldcDynamicConstant(MethodHandles.Lookup l,
  97                                                   String name, String type,
  98                                                   String bsmMethodName, String bsmType,
  99                                                   Consumer<PoolHelper.StaticArgListBuilder<String, String, byte[]>> staticArgs) throws Exception {







 100         return ldc(l, type,
 101                    P -> P.putDynamicConstant(name, type,
 102                                              csym(l.lookupClass()), bsmMethodName, bsmType,
 103                                              staticArgs));
 104     }
 105 
 106     public static MethodHandle ldc(MethodHandles.Lookup l,
 107                             Class<?> type,
 108                             Function<PoolHelper<String, String, byte[]>, Integer> poolFunc) throws Exception {
 109         return ldc(l, cref(type), poolFunc);
 110     }
 111 
 112     public static MethodHandle ldc(MethodHandles.Lookup l,
 113                                    String type,
 114                                    Function<PoolHelper<String, String, byte[]>, Integer> poolFunc) throws Exception {
 115         String methodType = "()" + type;
 116         byte[] byteArray = classBuilder(l)
 117                 .withMethod("m", "()" + type, M ->
 118                         M.withFlags(Flag.ACC_PUBLIC, Flag.ACC_STATIC)
 119                                 .withCode(TypedCodeBuilder::new,
 120                                           C -> {
 121                                               C.ldc(null, (P, v) -> poolFunc.apply(P));
 122                                               C.return_(BTH.tag(type));


  73                                                               csym(l.lookupClass()), bsmMethodName, bsmType.toMethodDescriptorString(),
  74                                                               staticArgs);
  75                                               C.return_(BTH.tag(cref(type.returnType())));
  76                                           }
  77                                 ))
  78                 .build();
  79         Class<?> gc = l.defineClass(byteArray);
  80         return l.findStatic(gc, "m", type);
  81     }
  82 
  83     public static MethodHandle ldcMethodHandle(MethodHandles.Lookup l,
  84                                         int refKind, Class<?> owner, String name, MethodType type) throws Exception {
  85         return ldc(l, MethodHandle.class,
  86                    P -> P.putHandle(refKind, csym(owner), name, type.toMethodDescriptorString()));
  87     }
  88 
  89     public static MethodHandle ldcDynamicConstant(MethodHandles.Lookup l,
  90                                                   String name, Class<?> type,
  91                                                   String bsmMethodName, MethodType bsmType,
  92                                                   Consumer<PoolHelper.StaticArgListBuilder<String, String, byte[]>> staticArgs) throws Exception {
  93         return ldcDynamicConstant(l, name, type, l.lookupClass(), bsmMethodName, bsmType, staticArgs);
  94     }
  95 
  96     public static MethodHandle ldcDynamicConstant(MethodHandles.Lookup l,
  97                                                   String name, Class<?> type,
  98                                                   Class<?> bsmClass, String bsmMethodName, MethodType bsmType,
  99                                                   Consumer<PoolHelper.StaticArgListBuilder<String, String, byte[]>> staticArgs) throws Exception {
 100         return ldcDynamicConstant(l, name, cref(type), csym(bsmClass), bsmMethodName, bsmType.toMethodDescriptorString(), staticArgs);
 101     }
 102 
 103     public static MethodHandle ldcDynamicConstant(MethodHandles.Lookup l,
 104                                                   String name, String type,
 105                                                   String bsmMethodName, String bsmType,
 106                                                   Consumer<PoolHelper.StaticArgListBuilder<String, String, byte[]>> staticArgs) throws Exception {
 107         return ldcDynamicConstant(l, name, type, csym(l.lookupClass()), bsmMethodName, bsmType, staticArgs);
 108     }
 109 
 110     public static MethodHandle ldcDynamicConstant(MethodHandles.Lookup l,
 111                                                   String name, String type,
 112                                                   String bsmClass, String bsmMethodName, String bsmType,
 113                                                   Consumer<PoolHelper.StaticArgListBuilder<String, String, byte[]>> staticArgs) throws Exception {
 114         return ldc(l, type,
 115                    P -> P.putDynamicConstant(name, type,
 116                                              bsmClass, bsmMethodName, bsmType,
 117                                              staticArgs));
 118     }
 119 
 120     public static MethodHandle ldc(MethodHandles.Lookup l,
 121                             Class<?> type,
 122                             Function<PoolHelper<String, String, byte[]>, Integer> poolFunc) throws Exception {
 123         return ldc(l, cref(type), poolFunc);
 124     }
 125 
 126     public static MethodHandle ldc(MethodHandles.Lookup l,
 127                                    String type,
 128                                    Function<PoolHelper<String, String, byte[]>, Integer> poolFunc) throws Exception {
 129         String methodType = "()" + type;
 130         byte[] byteArray = classBuilder(l)
 131                 .withMethod("m", "()" + type, M ->
 132                         M.withFlags(Flag.ACC_PUBLIC, Flag.ACC_STATIC)
 133                                 .withCode(TypedCodeBuilder::new,
 134                                           C -> {
 135                                               C.ldc(null, (P, v) -> poolFunc.apply(P));
 136                                               C.return_(BTH.tag(type));
< prev index next >