src/java.base/share/classes/java/lang/invoke/LambdaForm.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File jdk Sdiff src/java.base/share/classes/java/lang/invoke

src/java.base/share/classes/java/lang/invoke/LambdaForm.java

Print this page
rev 10589 : 8037209: Improvements and cleanups to bytecode assembly for lambda forms
Reviewed-by: vlivanov, psandoz
Contributed-by: john.r.rose@oracle.com
rev 10592 : 8050052: Small cleanups in java.lang.invoke code
Reviewed-by: ?
rev 10593 : 8050053: Improve caching of different invokers
Reviewed-by: vlivanov, ?
Contributed-by: john.r.rose@oracle.com
rev 10597 : 8050057: Improve caching of MethodHandle reinvokers
Reviewed-by: vlivanov, ?
Contributed-by: john.r.rose@oracle.com
rev 10598 : 8050200: Make LambdaForm intrinsics detection more robust
Reviewed-by: vlivanov, ?
Contributed-by: john.r.rose@oracle.com
rev 10605 : 8057657: Annotate LambdaForm parameters with types
Reviewed-by: vlivanov, ?
Contributed-by: john.r.rose@oracle.com
rev 10607 : imported patch 19.8057042.editor.0
rev 10608 : 8057042: LambdaFormEditor: derive new LFs from a base LF
Reviewed-by: vlivanov, ?
Contributed-by: john.r.rose@oracle.com
rev 10609 : 8057922: Improve LambdaForm sharing by using LambdaFormEditor more extensively
Reviewed-by: vlivanov, ?
Contributed-by: john.r.rose@oracle.com


 785             if (invocationCounter >= COMPILE_THRESHOLD) {
 786                 compileToBytecode();
 787             }
 788         }
 789         Object rval;
 790         try {
 791             assert(arityCheck(argumentValues));
 792             Object[] values = Arrays.copyOf(argumentValues, names.length);
 793             for (int i = argumentValues.length; i < values.length; i++) {
 794                 values[i] = interpretName(names[i], values);
 795             }
 796             rval = (result < 0) ? null : values[result];
 797         } catch (Throwable ex) {
 798             traceInterpreter("] throw =>", ex);
 799             throw ex;
 800         }
 801         traceInterpreter("] return =>", rval);
 802         return rval;
 803     }
 804 
 805     //** This transform is applied (statically) to every name.function. */
 806     /*
 807     private static MethodHandle eraseSubwordTypes(MethodHandle mh) {
 808         MethodType mt = mh.type();
 809         if (mt.hasPrimitives()) {
 810             mt = mt.changeReturnType(eraseSubwordType(mt.returnType()));
 811             for (int i = 0; i < mt.parameterCount(); i++) {
 812                 mt = mt.changeParameterType(i, eraseSubwordType(mt.parameterType(i)));
 813             }
 814             mh = MethodHandles.explicitCastArguments(mh, mt);
 815         }
 816         return mh;
 817     }
 818     private static Class<?> eraseSubwordType(Class<?> type) {
 819         if (!type.isPrimitive())  return type;
 820         if (type == int.class)  return type;
 821         Wrapper w = Wrapper.forPrimitiveType(type);
 822         if (w.isSubwordOrInt())  return int.class;
 823         return type;
 824     }
 825     */
 826 
 827     static void traceInterpreter(String event, Object obj, Object... args) {
 828         if (TRACE_INTERPRETER) {
 829             System.out.println("LFI: "+event+" "+(obj != null ? obj : "")+(args != null && args.length != 0 ? Arrays.asList(args) : ""));
 830         }
 831     }
 832     static void traceInterpreter(String event, Object obj) {
 833         traceInterpreter(event, obj, (Object[])null);
 834     }
 835     private boolean arityCheck(Object[] argumentValues) {
 836         assert(argumentValues.length == arity) : arity+"!="+Arrays.asList(argumentValues)+".length";
 837         // also check that the leading (receiver) argument is somehow bound to this LF:
 838         assert(argumentValues[0] instanceof MethodHandle) : "not MH: " + argumentValues[0];
 839         MethodHandle mh = (MethodHandle) argumentValues[0];
 840         assert(mh.internalForm() == this);
 841         // note:  argument #0 could also be an interface wrapper, in the future
 842         argumentTypesMatch(basicTypeSignature(), argumentValues);
 843         return true;
 844     }
 845     private boolean resultCheck(Object[] argumentValues, Object result) {
 846         MethodHandle mh = (MethodHandle) argumentValues[0];




 785             if (invocationCounter >= COMPILE_THRESHOLD) {
 786                 compileToBytecode();
 787             }
 788         }
 789         Object rval;
 790         try {
 791             assert(arityCheck(argumentValues));
 792             Object[] values = Arrays.copyOf(argumentValues, names.length);
 793             for (int i = argumentValues.length; i < values.length; i++) {
 794                 values[i] = interpretName(names[i], values);
 795             }
 796             rval = (result < 0) ? null : values[result];
 797         } catch (Throwable ex) {
 798             traceInterpreter("] throw =>", ex);
 799             throw ex;
 800         }
 801         traceInterpreter("] return =>", rval);
 802         return rval;
 803     }
 804 






















 805     static void traceInterpreter(String event, Object obj, Object... args) {
 806         if (TRACE_INTERPRETER) {
 807             System.out.println("LFI: "+event+" "+(obj != null ? obj : "")+(args != null && args.length != 0 ? Arrays.asList(args) : ""));
 808         }
 809     }
 810     static void traceInterpreter(String event, Object obj) {
 811         traceInterpreter(event, obj, (Object[])null);
 812     }
 813     private boolean arityCheck(Object[] argumentValues) {
 814         assert(argumentValues.length == arity) : arity+"!="+Arrays.asList(argumentValues)+".length";
 815         // also check that the leading (receiver) argument is somehow bound to this LF:
 816         assert(argumentValues[0] instanceof MethodHandle) : "not MH: " + argumentValues[0];
 817         MethodHandle mh = (MethodHandle) argumentValues[0];
 818         assert(mh.internalForm() == this);
 819         // note:  argument #0 could also be an interface wrapper, in the future
 820         argumentTypesMatch(basicTypeSignature(), argumentValues);
 821         return true;
 822     }
 823     private boolean resultCheck(Object[] argumentValues, Object result) {
 824         MethodHandle mh = (MethodHandle) argumentValues[0];


src/java.base/share/classes/java/lang/invoke/LambdaForm.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File