< prev index next >

src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/CompiledFunction.java

Print this page




 890 
 891         if (!canBeDeoptimized) {
 892             return restOf;
 893         }
 894 
 895         // If rest-of is itself optimistic, we must make sure that we can repeat a deoptimization if it, too hits an exception.
 896         return MH.catchException(restOf, RewriteException.class, createRewriteExceptionHandler());
 897 
 898     }
 899 
 900     private static class OptimismInfo {
 901         // TODO: this is pointing to its owning ScriptFunctionData. Re-evaluate if that's okay.
 902         private final RecompilableScriptFunctionData data;
 903         private final Map<Integer, Type> invalidatedProgramPoints;
 904         private SwitchPoint optimisticAssumptions;
 905         private final DebugLogger log;
 906 
 907         OptimismInfo(final RecompilableScriptFunctionData data, final Map<Integer, Type> invalidatedProgramPoints) {
 908             this.data = data;
 909             this.log  = data.getLogger();
 910             this.invalidatedProgramPoints = invalidatedProgramPoints == null ? new TreeMap<Integer, Type>() : invalidatedProgramPoints;
 911             newOptimisticAssumptions();
 912         }
 913 
 914         private void newOptimisticAssumptions() {
 915             optimisticAssumptions = new SwitchPoint();
 916         }
 917 
 918         boolean requestRecompile(final RewriteException e) {
 919             final Type retType            = e.getReturnType();
 920             final Type previousFailedType = invalidatedProgramPoints.put(e.getProgramPoint(), retType);
 921 
 922             if (previousFailedType != null && !previousFailedType.narrowerThan(retType)) {
 923                 final StackTraceElement[] stack      = e.getStackTrace();
 924                 final String              functionId = stack.length == 0 ?
 925                         data.getName() :
 926                         stack[0].getClassName() + "." + stack[0].getMethodName();
 927 
 928                 log.info("RewriteException for an already invalidated program point ", e.getProgramPoint(), " in ", functionId, ". This is okay for a recursive function invocation, but a bug otherwise.");
 929 
 930                 return false;




 890 
 891         if (!canBeDeoptimized) {
 892             return restOf;
 893         }
 894 
 895         // If rest-of is itself optimistic, we must make sure that we can repeat a deoptimization if it, too hits an exception.
 896         return MH.catchException(restOf, RewriteException.class, createRewriteExceptionHandler());
 897 
 898     }
 899 
 900     private static class OptimismInfo {
 901         // TODO: this is pointing to its owning ScriptFunctionData. Re-evaluate if that's okay.
 902         private final RecompilableScriptFunctionData data;
 903         private final Map<Integer, Type> invalidatedProgramPoints;
 904         private SwitchPoint optimisticAssumptions;
 905         private final DebugLogger log;
 906 
 907         OptimismInfo(final RecompilableScriptFunctionData data, final Map<Integer, Type> invalidatedProgramPoints) {
 908             this.data = data;
 909             this.log  = data.getLogger();
 910             this.invalidatedProgramPoints = invalidatedProgramPoints == null ? new TreeMap<>() : invalidatedProgramPoints;
 911             newOptimisticAssumptions();
 912         }
 913 
 914         private void newOptimisticAssumptions() {
 915             optimisticAssumptions = new SwitchPoint();
 916         }
 917 
 918         boolean requestRecompile(final RewriteException e) {
 919             final Type retType            = e.getReturnType();
 920             final Type previousFailedType = invalidatedProgramPoints.put(e.getProgramPoint(), retType);
 921 
 922             if (previousFailedType != null && !previousFailedType.narrowerThan(retType)) {
 923                 final StackTraceElement[] stack      = e.getStackTrace();
 924                 final String              functionId = stack.length == 0 ?
 925                         data.getName() :
 926                         stack[0].getClassName() + "." + stack[0].getMethodName();
 927 
 928                 log.info("RewriteException for an already invalidated program point ", e.getProgramPoint(), " in ", functionId, ". This is okay for a recursive function invocation, but a bug otherwise.");
 929 
 930                 return false;


< prev index next >