src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java
changeset 48380 597f69e5f1e3
parent 48247 fa5a47cad0c9
child 48411 4ff5c5206427
equal deleted inserted replaced
48379:5382baab8371 48380:597f69e5f1e3
  1277         assert lc.getUsedSlotCount() == method.getFirstTemp();
  1277         assert lc.getUsedSlotCount() == method.getFirstTemp();
  1278         return true;
  1278         return true;
  1279     }
  1279     }
  1280 
  1280 
  1281     boolean useOptimisticTypes() {
  1281     boolean useOptimisticTypes() {
  1282         return !lc.inSplitNode() && compiler.useOptimisticTypes();
  1282         return !lc.inSplitLiteral() && compiler.useOptimisticTypes();
  1283     }
  1283     }
  1284 
  1284 
  1285     @Override
  1285     @Override
  1286     public Node leaveBlock(final Block block) {
  1286     public Node leaveBlock(final Block block) {
  1287         popBlockScope(block);
  1287         popBlockScope(block);
  2915 
  2915 
  2916             // NOTE: when this is no longer needed, SplitIntoFunctions will no longer have to add IS_SPLIT
  2916             // NOTE: when this is no longer needed, SplitIntoFunctions will no longer have to add IS_SPLIT
  2917             // to synthetic functions, and FunctionNode.needsCallee() will no longer need to test for isSplit().
  2917             // to synthetic functions, and FunctionNode.needsCallee() will no longer need to test for isSplit().
  2918             final int literalSlot = fixScopeSlot(currentFunction, 3);
  2918             final int literalSlot = fixScopeSlot(currentFunction, 3);
  2919 
  2919 
  2920             lc.enterSplitNode();
  2920             lc.enterSplitLiteral();
  2921 
  2921 
  2922             creator.populateRange(method, literalType, literalSlot, splitRange.getLow(), splitRange.getHigh());
  2922             creator.populateRange(method, literalType, literalSlot, splitRange.getLow(), splitRange.getHigh());
  2923 
  2923 
  2924             method._return();
  2924             method._return();
  2925             lc.exitSplitNode();
  2925             lc.exitSplitLiteral();
  2926             method.end();
  2926             method.end();
  2927             lc.releaseSlots();
  2927             lc.releaseSlots();
  2928             popMethodEmitter();
  2928             popMethodEmitter();
  2929 
  2929 
  2930             assert method == savedMethod;
  2930             assert method == savedMethod;
  4652 
  4652 
  4653         OptimisticOperation(final Optimistic optimistic, final TypeBounds resultBounds) {
  4653         OptimisticOperation(final Optimistic optimistic, final TypeBounds resultBounds) {
  4654             this.optimistic = optimistic;
  4654             this.optimistic = optimistic;
  4655             this.expression = (Expression)optimistic;
  4655             this.expression = (Expression)optimistic;
  4656             this.resultBounds = resultBounds;
  4656             this.resultBounds = resultBounds;
  4657             this.isOptimistic = isOptimistic(optimistic) && useOptimisticTypes() &&
  4657             this.isOptimistic = isOptimistic(optimistic)
  4658                     // Operation is only effectively optimistic if its type, after being coerced into the result bounds
  4658                     // Operation is only effectively optimistic if its type, after being coerced into the result bounds
  4659                     // is narrower than the upper bound.
  4659                     // is narrower than the upper bound.
  4660                     resultBounds.within(Type.generic(((Expression)optimistic).getType())).narrowerThan(resultBounds.widest);
  4660                     && resultBounds.within(Type.generic(((Expression)optimistic).getType())).narrowerThan(resultBounds.widest);
       
  4661             // Optimistic operations need to be executed in optimistic context, else unwarranted optimism will go unnoticed
       
  4662             assert !this.isOptimistic || useOptimisticTypes();
  4661         }
  4663         }
  4662 
  4664 
  4663         MethodEmitter emit() {
  4665         MethodEmitter emit() {
  4664             return emit(0);
  4666             return emit(0);
  4665         }
  4667         }