jdk.nashorn.internal.ir.Optimistic Java Examples
The following examples show how to use
jdk.nashorn.internal.ir.Optimistic.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OptimisticTypesCalculator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void tagNeverOptimistic(final Expression expr) { if(expr instanceof Optimistic) { final int pp = ((Optimistic)expr).getProgramPoint(); if(isValid(pp)) { neverOptimistic.peek().set(pp); } } }
Example #2
Source File: OptimisticTypesCalculator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override protected Node leaveDefault(final Node node) { if(node instanceof Optimistic) { return leaveOptimistic((Optimistic)node); } return node; }
Example #3
Source File: OptimisticTypesCalculator.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override protected Node leaveDefault(final Node node) { if(node instanceof Optimistic) { return leaveOptimistic((Optimistic)node); } return node; }
Example #4
Source File: OptimisticTypesCalculator.java From hottub with GNU General Public License v2.0 | 5 votes |
private Expression leaveOptimistic(final Optimistic opt) { final int pp = opt.getProgramPoint(); if(isValid(pp) && !neverOptimistic.peek().get(pp)) { return (Expression)opt.setType(compiler.getOptimisticType(opt)); } return (Expression)opt; }
Example #5
Source File: TypeEvaluator.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
Type getOptimisticType(final Optimistic node) { assert compiler.useOptimisticTypes(); final int programPoint = node.getProgramPoint(); final Type validType = compiler.getInvalidatedProgramPointType(programPoint); if (validType != null) { return validType; } final Type mostOptimisticType = node.getMostOptimisticType(); final Type evaluatedType = getEvaluatedType(node); if (evaluatedType != null) { if (evaluatedType.widerThan(mostOptimisticType)) { final Type newValidType = evaluatedType.isObject() || evaluatedType.isBoolean() ? Type.OBJECT : evaluatedType; // Update invalidatedProgramPoints so we don't re-evaluate the expression next time. This is a heuristic // as we're doing a tradeoff. Re-evaluating expressions on each recompile takes time, but it might // notice a widening in the type of the expression and thus prevent an unnecessary deoptimization later. // We'll presume though that the types of expressions are mostly stable, so if we evaluated it in one // compilation, we'll keep to that and risk a low-probability deoptimization if its type gets widened // in the future. compiler.addInvalidatedProgramPoint(node.getProgramPoint(), newValidType); } return evaluatedType; } return mostOptimisticType; }
Example #6
Source File: OptimisticTypesCalculator.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private void tagNeverOptimistic(final Expression expr) { if(expr instanceof Optimistic) { final int pp = ((Optimistic)expr).getProgramPoint(); if(isValid(pp)) { neverOptimistic.peek().set(pp); } } }
Example #7
Source File: OptimisticTypesCalculator.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private Expression leaveOptimistic(final Optimistic opt) { final int pp = opt.getProgramPoint(); if(isValid(pp) && !neverOptimistic.peek().get(pp)) { return (Expression)opt.setType(compiler.getOptimisticType(opt)); } return (Expression)opt; }
Example #8
Source File: OptimisticTypesCalculator.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override protected Node leaveDefault(final Node node) { if(node instanceof Optimistic) { return leaveOptimistic((Optimistic)node); } return node; }
Example #9
Source File: OptimisticTypesCalculator.java From hottub with GNU General Public License v2.0 | 5 votes |
private void tagNeverOptimistic(final Expression expr) { if(expr instanceof Optimistic) { final int pp = ((Optimistic)expr).getProgramPoint(); if(isValid(pp)) { neverOptimistic.peek().set(pp); } } }
Example #10
Source File: TypeEvaluator.java From hottub with GNU General Public License v2.0 | 5 votes |
Type getOptimisticType(final Optimistic node) { assert compiler.useOptimisticTypes(); final int programPoint = node.getProgramPoint(); final Type validType = compiler.getInvalidatedProgramPointType(programPoint); if (validType != null) { return validType; } final Type mostOptimisticType = node.getMostOptimisticType(); final Type evaluatedType = getEvaluatedType(node); if (evaluatedType != null) { if (evaluatedType.widerThan(mostOptimisticType)) { final Type newValidType = evaluatedType.isObject() || evaluatedType.isBoolean() ? Type.OBJECT : evaluatedType; // Update invalidatedProgramPoints so we don't re-evaluate the expression next time. This is a heuristic // as we're doing a tradeoff. Re-evaluating expressions on each recompile takes time, but it might // notice a widening in the type of the expression and thus prevent an unnecessary deoptimization later. // We'll presume though that the types of expressions are mostly stable, so if we evaluated it in one // compilation, we'll keep to that and risk a low-probability deoptimization if its type gets widened // in the future. compiler.addInvalidatedProgramPoint(node.getProgramPoint(), newValidType); } return evaluatedType; } return mostOptimisticType; }
Example #11
Source File: OptimisticTypesCalculator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private Expression leaveOptimistic(final Optimistic opt) { final int pp = opt.getProgramPoint(); if(isValid(pp) && !neverOptimistic.peek().get(pp)) { return (Expression)opt.setType(compiler.getOptimisticType(opt)); } return (Expression)opt; }
Example #12
Source File: TypeEvaluator.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
Type getOptimisticType(final Optimistic node) { assert compiler.useOptimisticTypes(); final int programPoint = node.getProgramPoint(); final Type validType = compiler.getInvalidatedProgramPointType(programPoint); if (validType != null) { return validType; } final Type mostOptimisticType = node.getMostOptimisticType(); final Type evaluatedType = getEvaluatedType(node); if (evaluatedType != null) { if (evaluatedType.widerThan(mostOptimisticType)) { final Type newValidType = evaluatedType.isObject() || evaluatedType.isBoolean() ? Type.OBJECT : evaluatedType; // Update invalidatedProgramPoints so we don't re-evaluate the expression next time. This is a heuristic // as we're doing a tradeoff. Re-evaluating expressions on each recompile takes time, but it might // notice a widening in the type of the expression and thus prevent an unnecessary deoptimization later. // We'll presume though that the types of expressions are mostly stable, so if we evaluated it in one // compilation, we'll keep to that and risk a low-probability deoptimization if its type gets widened // in the future. compiler.addInvalidatedProgramPoint(node.getProgramPoint(), newValidType); } return evaluatedType; } return mostOptimisticType; }
Example #13
Source File: OptimisticTypesCalculator.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private void tagNeverOptimistic(final Expression expr) { if(expr instanceof Optimistic) { final int pp = ((Optimistic)expr).getProgramPoint(); if(isValid(pp)) { neverOptimistic.peek().set(pp); } } }
Example #14
Source File: OptimisticTypesCalculator.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private Expression leaveOptimistic(final Optimistic opt) { final int pp = opt.getProgramPoint(); if(isValid(pp) && !neverOptimistic.peek().get(pp)) { return (Expression)opt.setType(compiler.getOptimisticType(opt)); } return (Expression)opt; }
Example #15
Source File: OptimisticTypesCalculator.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override protected Node leaveDefault(final Node node) { if(node instanceof Optimistic) { return leaveOptimistic((Optimistic)node); } return node; }
Example #16
Source File: TypeEvaluator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
Type getOptimisticType(final Optimistic node) { assert compiler.useOptimisticTypes(); final int programPoint = node.getProgramPoint(); final Type validType = compiler.getInvalidatedProgramPointType(programPoint); if (validType != null) { return validType; } final Type mostOptimisticType = node.getMostOptimisticType(); final Type evaluatedType = getEvaluatedType(node); if (evaluatedType != null) { if (evaluatedType.widerThan(mostOptimisticType)) { final Type newValidType = evaluatedType.isObject() || evaluatedType.isBoolean() ? Type.OBJECT : evaluatedType; // Update invalidatedProgramPoints so we don't re-evaluate the expression next time. This is a heuristic // as we're doing a tradeoff. Re-evaluating expressions on each recompile takes time, but it might // notice a widening in the type of the expression and thus prevent an unnecessary deoptimization later. // We'll presume though that the types of expressions are mostly stable, so if we evaluated it in one // compilation, we'll keep to that and risk a low-probability deoptimization if its type gets widened // in the future. compiler.addInvalidatedProgramPoint(node.getProgramPoint(), newValidType); } return evaluatedType; } return mostOptimisticType; }
Example #17
Source File: OptimisticTypesCalculator.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
@Override protected Node leaveDefault(final Node node) { if(node instanceof Optimistic) { return leaveOptimistic((Optimistic)node); } return node; }
Example #18
Source File: TypeEvaluator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
Type getOptimisticType(final Optimistic node) { assert compiler.useOptimisticTypes(); final int programPoint = node.getProgramPoint(); final Type validType = compiler.getInvalidatedProgramPointType(programPoint); if (validType != null) { return validType; } final Type mostOptimisticType = node.getMostOptimisticType(); final Type evaluatedType = getEvaluatedType(node); if (evaluatedType != null) { if (evaluatedType.widerThan(mostOptimisticType)) { final Type newValidType = evaluatedType.isObject() || evaluatedType.isBoolean() ? Type.OBJECT : evaluatedType; // Update invalidatedProgramPoints so we don't re-evaluate the expression next time. This is a heuristic // as we're doing a tradeoff. Re-evaluating expressions on each recompile takes time, but it might // notice a widening in the type of the expression and thus prevent an unnecessary deoptimization later. // We'll presume though that the types of expressions are mostly stable, so if we evaluated it in one // compilation, we'll keep to that and risk a low-probability deoptimization if its type gets widened // in the future. compiler.addInvalidatedProgramPoint(node.getProgramPoint(), newValidType); } return evaluatedType; } return mostOptimisticType; }
Example #19
Source File: OptimisticTypesCalculator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private void tagNeverOptimistic(final Expression expr) { if(expr instanceof Optimistic) { final int pp = ((Optimistic)expr).getProgramPoint(); if(isValid(pp)) { neverOptimistic.peek().set(pp); } } }
Example #20
Source File: OptimisticTypesCalculator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private Expression leaveOptimistic(final Optimistic opt) { final int pp = opt.getProgramPoint(); if(isValid(pp) && !neverOptimistic.peek().get(pp)) { return (Expression)opt.setType(compiler.getOptimisticType(opt)); } return (Expression)opt; }
Example #21
Source File: OptimisticTypesCalculator.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override protected Node leaveDefault(final Node node) { if(node instanceof Optimistic) { return leaveOptimistic((Optimistic)node); } return node; }
Example #22
Source File: OptimisticTypesCalculator.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
private Expression leaveOptimistic(final Optimistic opt) { final int pp = opt.getProgramPoint(); if(isValid(pp) && !neverOptimistic.peek().get(pp)) { return (Expression)opt.setType(compiler.getOptimisticType(opt)); } return (Expression)opt; }
Example #23
Source File: OptimisticTypesCalculator.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
private void tagNeverOptimistic(final Expression expr) { if(expr instanceof Optimistic) { final int pp = ((Optimistic)expr).getProgramPoint(); if(isValid(pp)) { neverOptimistic.peek().set(pp); } } }
Example #24
Source File: TypeEvaluator.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
Type getOptimisticType(final Optimistic node) { assert compiler.useOptimisticTypes(); final int programPoint = node.getProgramPoint(); final Type validType = compiler.getInvalidatedProgramPointType(programPoint); if (validType != null) { return validType; } final Type mostOptimisticType = node.getMostOptimisticType(); final Type evaluatedType = getEvaluatedType(node); if (evaluatedType != null) { if (evaluatedType.widerThan(mostOptimisticType)) { final Type newValidType = evaluatedType.isObject() || evaluatedType.isBoolean() ? Type.OBJECT : evaluatedType; // Update invalidatedProgramPoints so we don't re-evaluate the expression next time. This is a heuristic // as we're doing a tradeoff. Re-evaluating expressions on each recompile takes time, but it might // notice a widening in the type of the expression and thus prevent an unnecessary deoptimization later. // We'll presume though that the types of expressions are mostly stable, so if we evaluated it in one // compilation, we'll keep to that and risk a low-probability deoptimization if its type gets widened // in the future. compiler.addInvalidatedProgramPoint(node.getProgramPoint(), newValidType); } return evaluatedType; } return mostOptimisticType; }
Example #25
Source File: TypeEvaluator.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
Type getOptimisticType(final Optimistic node) { assert compiler.useOptimisticTypes(); final int programPoint = node.getProgramPoint(); final Type validType = compiler.getInvalidatedProgramPointType(programPoint); if (validType != null) { return validType; } final Type mostOptimisticType = node.getMostOptimisticType(); final Type evaluatedType = getEvaluatedType(node); if (evaluatedType != null) { if (evaluatedType.widerThan(mostOptimisticType)) { final Type newValidType = evaluatedType.isObject() || evaluatedType.isBoolean() ? Type.OBJECT : evaluatedType; // Update invalidatedProgramPoints so we don't re-evaluate the expression next time. This is a heuristic // as we're doing a tradeoff. Re-evaluating expressions on each recompile takes time, but it might // notice a widening in the type of the expression and thus prevent an unnecessary deoptimization later. // We'll presume though that the types of expressions are mostly stable, so if we evaluated it in one // compilation, we'll keep to that and risk a low-probability deoptimization if its type gets widened // in the future. compiler.addInvalidatedProgramPoint(node.getProgramPoint(), newValidType); } return evaluatedType; } return mostOptimisticType; }
Example #26
Source File: OptimisticTypesCalculator.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private void tagNeverOptimistic(final Expression expr) { if(expr instanceof Optimistic) { final int pp = ((Optimistic)expr).getProgramPoint(); if(isValid(pp)) { neverOptimistic.peek().set(pp); } } }
Example #27
Source File: OptimisticTypesCalculator.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private Expression leaveOptimistic(final Optimistic opt) { final int pp = opt.getProgramPoint(); if(isValid(pp) && !neverOptimistic.peek().get(pp)) { return (Expression)opt.setType(compiler.getOptimisticType(opt)); } return (Expression)opt; }
Example #28
Source File: OptimisticTypesCalculator.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override protected Node leaveDefault(final Node node) { if(node instanceof Optimistic) { return leaveOptimistic((Optimistic)node); } return node; }
Example #29
Source File: ProgramPoints.java From hottub with GNU General Public License v2.0 | 4 votes |
private Expression setProgramPoint(final Optimistic optimistic) { if (noProgramPoint.contains(optimistic)) { return (Expression)optimistic; } return (Expression)(optimistic.canBeOptimistic() ? optimistic.setProgramPoint(next()) : optimistic); }
Example #30
Source File: TypeEvaluator.java From jdk8u_nashorn with GNU General Public License v2.0 | 4 votes |
private Type getEvaluatedType(final Optimistic expr) { if (expr instanceof IdentNode) { if (runtimeScope == null) { return null; } return getPropertyType(runtimeScope, ((IdentNode)expr).getName()); } else if (expr instanceof AccessNode) { final AccessNode accessNode = (AccessNode)expr; final Object base = evaluateSafely(accessNode.getBase()); if (!(base instanceof ScriptObject)) { return null; } return getPropertyType((ScriptObject)base, accessNode.getProperty()); } else if (expr instanceof IndexNode) { final IndexNode indexNode = (IndexNode)expr; final Object base = evaluateSafely(indexNode.getBase()); if(base instanceof NativeArray || base instanceof ArrayBufferView) { // NOTE: optimistic array getters throw UnwarrantedOptimismException based on the type of their // underlying array storage, not based on values of individual elements. Thus, a LongArrayData will // throw UOE for every optimistic int linkage attempt, even if the long value being returned in the // first invocation would be representable as int. That way, we can presume that the array's optimistic // type is the most optimistic type for which an element getter has a chance of executing successfully. return ((ScriptObject)base).getArray().getOptimisticType(); } } else if (expr instanceof CallNode) { // Currently, we'll only try to guess the return type of immediately invoked function expressions with no // parameters, that is (function() { ... })(). We could do better, but these are all heuristics and we can // gradually introduce them as needed. An easy one would be to do the same for .call(this) idiom. final CallNode callExpr = (CallNode)expr; final Expression fnExpr = callExpr.getFunction(); // Skip evaluation if running with eager compilation as we may violate constraints in RecompilableScriptFunctionData if (fnExpr instanceof FunctionNode && compiler.getContext().getEnv()._lazy_compilation) { final FunctionNode fn = (FunctionNode)fnExpr; if (callExpr.getArgs().isEmpty()) { final RecompilableScriptFunctionData data = compiler.getScriptFunctionData(fn.getId()); if (data != null) { final Type returnType = Type.typeFor(data.getReturnType(EMPTY_INVOCATION_TYPE, runtimeScope)); if (returnType == Type.BOOLEAN) { // We don't have optimistic booleans. In fact, optimistic call sites getting back boolean // currently deoptimize all the way to Object. return Type.OBJECT; } assert returnType == Type.INT || returnType == Type.NUMBER || returnType == Type.OBJECT; return returnType; } } } } return null; }