jdk.nashorn.internal.codegen.Compiler.CompilationPhases Java Examples
The following examples show how to use
jdk.nashorn.internal.codegen.Compiler.CompilationPhases.
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: CompilationPhase.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
@Override FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { final CompileUnit outermostCompileUnit = compiler.addCompileUnit(0L); FunctionNode newFunctionNode; //ensure elementTypes, postsets and presets exist for splitter and arraynodes newFunctionNode = transformFunction(fn, new SimpleNodeVisitor() { @Override public LiteralNode<?> leaveLiteralNode(final LiteralNode<?> literalNode) { return literalNode.initialize(lc); } }); newFunctionNode = new Splitter(compiler, newFunctionNode, outermostCompileUnit).split(newFunctionNode, true); newFunctionNode = transformFunction(newFunctionNode, new SplitIntoFunctions(compiler)); assert newFunctionNode.getCompileUnit() == outermostCompileUnit : "fn=" + fn.getName() + ", fn.compileUnit (" + newFunctionNode.getCompileUnit() + ") != " + outermostCompileUnit; assert newFunctionNode.isStrict() == compiler.isStrict() : "functionNode.isStrict() != compiler.isStrict() for " + quote(newFunctionNode.getName()); return newFunctionNode; }
Example #2
Source File: CompilationPhase.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { final FunctionNode newFunctionNode = transformFunction(fn, new LocalVariableTypesCalculator(compiler)); final ScriptEnvironment senv = compiler.getScriptEnvironment(); final PrintWriter err = senv.getErr(); //TODO separate phase for the debug printouts for abstraction and clarity if (senv._print_lower_ast || fn.getFlag(FunctionNode.IS_PRINT_LOWER_AST)) { err.println("Lower AST for: " + quote(newFunctionNode.getName())); err.println(new ASTWriter(newFunctionNode)); } if (senv._print_lower_parse || fn.getFlag(FunctionNode.IS_PRINT_LOWER_PARSE)) { err.println("Lower AST for: " + quote(newFunctionNode.getName())); err.println(new PrintVisitor(newFunctionNode)); } return newFunctionNode; }
Example #3
Source File: CompilationPhase.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { final CompileUnit outermostCompileUnit = compiler.addCompileUnit(0L); FunctionNode newFunctionNode; //ensure elementTypes, postsets and presets exist for splitter and arraynodes newFunctionNode = transformFunction(fn, new SimpleNodeVisitor() { @Override public LiteralNode<?> leaveLiteralNode(final LiteralNode<?> literalNode) { return literalNode.initialize(lc); } }); newFunctionNode = new Splitter(compiler, newFunctionNode, outermostCompileUnit).split(newFunctionNode, true); newFunctionNode = transformFunction(newFunctionNode, new SplitIntoFunctions(compiler)); assert newFunctionNode.getCompileUnit() == outermostCompileUnit : "fn=" + fn.getName() + ", fn.compileUnit (" + newFunctionNode.getCompileUnit() + ") != " + outermostCompileUnit; assert newFunctionNode.isStrict() == compiler.isStrict() : "functionNode.isStrict() != compiler.isStrict() for " + quote(newFunctionNode.getName()); return newFunctionNode; }
Example #4
Source File: CompilationPhase.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
@Override FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { final FunctionNode newFunctionNode = transformFunction(fn, new LocalVariableTypesCalculator(compiler)); final ScriptEnvironment senv = compiler.getScriptEnvironment(); final PrintWriter err = senv.getErr(); //TODO separate phase for the debug printouts for abstraction and clarity if (senv._print_lower_ast || fn.getFlag(FunctionNode.IS_PRINT_LOWER_AST)) { err.println("Lower AST for: " + quote(newFunctionNode.getName())); err.println(new ASTWriter(newFunctionNode)); } if (senv._print_lower_parse || fn.getFlag(FunctionNode.IS_PRINT_LOWER_PARSE)) { err.println("Lower AST for: " + quote(newFunctionNode.getName())); err.println(new PrintVisitor(newFunctionNode)); } return newFunctionNode; }
Example #5
Source File: CompilationPhase.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
@Override FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { final CompileUnit outermostCompileUnit = compiler.addCompileUnit(0L); FunctionNode newFunctionNode; //ensure elementTypes, postsets and presets exist for splitter and arraynodes newFunctionNode = transformFunction(fn, new SimpleNodeVisitor() { @Override public LiteralNode<?> leaveLiteralNode(final LiteralNode<?> literalNode) { return literalNode.initialize(lc); } }); newFunctionNode = new Splitter(compiler, newFunctionNode, outermostCompileUnit).split(newFunctionNode, true); newFunctionNode = transformFunction(newFunctionNode, new SplitIntoFunctions(compiler)); assert newFunctionNode.getCompileUnit() == outermostCompileUnit : "fn=" + fn.getName() + ", fn.compileUnit (" + newFunctionNode.getCompileUnit() + ") != " + outermostCompileUnit; assert newFunctionNode.isStrict() == compiler.isStrict() : "functionNode.isStrict() != compiler.isStrict() for " + quote(newFunctionNode.getName()); return newFunctionNode; }
Example #6
Source File: CompilationPhase.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
@Override FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { final FunctionNode newFunctionNode = transformFunction(fn, new LocalVariableTypesCalculator(compiler)); final ScriptEnvironment senv = compiler.getScriptEnvironment(); final PrintWriter err = senv.getErr(); //TODO separate phase for the debug printouts for abstraction and clarity if (senv._print_lower_ast || fn.getFlag(FunctionNode.IS_PRINT_LOWER_AST)) { err.println("Lower AST for: " + quote(newFunctionNode.getName())); err.println(new ASTWriter(newFunctionNode)); } if (senv._print_lower_parse || fn.getFlag(FunctionNode.IS_PRINT_LOWER_PARSE)) { err.println("Lower AST for: " + quote(newFunctionNode.getName())); err.println(new PrintVisitor(newFunctionNode)); } return newFunctionNode; }
Example #7
Source File: CompilationPhase.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { final CompileUnit outermostCompileUnit = compiler.addCompileUnit(0L); FunctionNode newFunctionNode; //ensure elementTypes, postsets and presets exist for splitter and arraynodes newFunctionNode = transformFunction(fn, new SimpleNodeVisitor() { @Override public LiteralNode<?> leaveLiteralNode(final LiteralNode<?> literalNode) { return literalNode.initialize(lc); } }); newFunctionNode = new Splitter(compiler, newFunctionNode, outermostCompileUnit).split(newFunctionNode, true); newFunctionNode = transformFunction(newFunctionNode, new SplitIntoFunctions(compiler)); assert newFunctionNode.getCompileUnit() == outermostCompileUnit : "fn=" + fn.getName() + ", fn.compileUnit (" + newFunctionNode.getCompileUnit() + ") != " + outermostCompileUnit; assert newFunctionNode.isStrict() == compiler.isStrict() : "functionNode.isStrict() != compiler.isStrict() for " + quote(newFunctionNode.getName()); return newFunctionNode; }
Example #8
Source File: CompilationPhase.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
@Override FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { final CompileUnit outermostCompileUnit = compiler.addCompileUnit(0L); FunctionNode newFunctionNode; //ensure elementTypes, postsets and presets exist for splitter and arraynodes newFunctionNode = transformFunction(fn, new SimpleNodeVisitor() { @Override public LiteralNode<?> leaveLiteralNode(final LiteralNode<?> literalNode) { return literalNode.initialize(lc); } }); newFunctionNode = new Splitter(compiler, newFunctionNode, outermostCompileUnit).split(newFunctionNode, true); newFunctionNode = transformFunction(newFunctionNode, new SplitIntoFunctions(compiler)); assert newFunctionNode.getCompileUnit() == outermostCompileUnit : "fn=" + fn.getName() + ", fn.compileUnit (" + newFunctionNode.getCompileUnit() + ") != " + outermostCompileUnit; assert newFunctionNode.isStrict() == compiler.isStrict() : "functionNode.isStrict() != compiler.isStrict() for " + quote(newFunctionNode.getName()); return newFunctionNode; }
Example #9
Source File: CompilationPhase.java From hottub with GNU General Public License v2.0 | 6 votes |
@Override FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { final FunctionNode newFunctionNode = transformFunction(fn, new LocalVariableTypesCalculator(compiler)); final ScriptEnvironment senv = compiler.getScriptEnvironment(); final PrintWriter err = senv.getErr(); //TODO separate phase for the debug printouts for abstraction and clarity if (senv._print_lower_ast || fn.getFlag(FunctionNode.IS_PRINT_LOWER_AST)) { err.println("Lower AST for: " + quote(newFunctionNode.getName())); err.println(new ASTWriter(newFunctionNode)); } if (senv._print_lower_parse || fn.getFlag(FunctionNode.IS_PRINT_LOWER_PARSE)) { err.println("Lower AST for: " + quote(newFunctionNode.getName())); err.println(new PrintVisitor(newFunctionNode)); } return newFunctionNode; }
Example #10
Source File: RecompilableScriptFunctionData.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private FunctionInitializer compileTypeSpecialization(final MethodType actualCallSiteType, final ScriptObject runtimeScope, final boolean persist) { // We're creating an empty script object for holding local variables. AssignSymbols will populate it with // explicit Undefined values for undefined local variables (see AssignSymbols#defineSymbol() and // CompilationEnvironment#declareLocalSymbol()). if (log.isEnabled()) { log.info("Parameter type specialization of '", functionName, "' signature: ", actualCallSiteType); } final boolean persistentCache = persist && usePersistentCodeCache(); String cacheKey = null; if (persistentCache) { final TypeMap typeMap = typeMap(actualCallSiteType); final Type[] paramTypes = typeMap == null ? null : typeMap.getParameterTypes(functionNodeId); cacheKey = CodeStore.getCacheKey(functionNodeId, paramTypes); final CodeInstaller<ScriptEnvironment> newInstaller = getInstallerForNewCode(); final StoredScript script = newInstaller.loadScript(source, cacheKey); if (script != null) { Compiler.updateCompilationId(script.getCompilationId()); return script.installFunction(this, newInstaller); } } final FunctionNode fn = reparse(); final Compiler compiler = getCompiler(fn, actualCallSiteType, runtimeScope); final FunctionNode compiledFn = compiler.compile(fn, isSerialized() ? CompilationPhases.COMPILE_ALL_SERIALIZED : CompilationPhases.COMPILE_ALL); if (persist && !compiledFn.getFlag(FunctionNode.HAS_APPLY_TO_CALL_SPECIALIZATION)) { compiler.persistClassInfo(cacheKey, compiledFn); } return new FunctionInitializer(compiledFn, compiler.getInvalidatedProgramPoints()); }
Example #11
Source File: CompilationPhase.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static CompileUnit createNewCompileUnit(final Compiler compiler, final CompilationPhases phases) { final StringBuilder sb = new StringBuilder(compiler.nextCompileUnitName()); if (phases.isRestOfCompilation()) { sb.append("$restOf"); } //it's ok to not copy the initCount, methodCount and clinitCount here, as codegen is what //fills those out anyway. Thus no need for a copy constructor return compiler.createCompileUnit(sb.toString(), 0); }
Example #12
Source File: RecompilableScriptFunctionData.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private FunctionInitializer compileTypeSpecialization(final MethodType actualCallSiteType, final ScriptObject runtimeScope, final boolean persist) { // We're creating an empty script object for holding local variables. AssignSymbols will populate it with // explicit Undefined values for undefined local variables (see AssignSymbols#defineSymbol() and // CompilationEnvironment#declareLocalSymbol()). if (log.isEnabled()) { log.info("Parameter type specialization of '", functionName, "' signature: ", actualCallSiteType); } final boolean persistentCache = persist && usePersistentCodeCache(); String cacheKey = null; if (persistentCache) { final TypeMap typeMap = typeMap(actualCallSiteType); final Type[] paramTypes = typeMap == null ? null : typeMap.getParameterTypes(functionNodeId); cacheKey = CodeStore.getCacheKey(functionNodeId, paramTypes); final CodeInstaller newInstaller = getInstallerForNewCode(); final StoredScript script = newInstaller.loadScript(source, cacheKey); if (script != null) { Compiler.updateCompilationId(script.getCompilationId()); return script.installFunction(this, newInstaller); } } final FunctionNode fn = reparse(); final Compiler compiler = getCompiler(fn, actualCallSiteType, runtimeScope); final FunctionNode compiledFn = compiler.compile(fn, fn.isCached() ? CompilationPhases.COMPILE_ALL_CACHED : CompilationPhases.COMPILE_ALL); if (persist && !compiledFn.hasApplyToCallSpecialization()) { compiler.persistClassInfo(cacheKey, compiledFn); } return new FunctionInitializer(compiledFn, compiler.getInvalidatedProgramPoints()); }
Example #13
Source File: CompilationPhase.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private CompileUnit createCompileUnit(final CompileUnit oldUnit, final Set<CompileUnit> unitSet, final Map<CompileUnit, CompileUnit> unitMap, final Compiler compiler, final CompilationPhases phases) { final CompileUnit newUnit = createNewCompileUnit(compiler, phases); unitMap.put(oldUnit, newUnit); unitSet.add(newUnit); return newUnit; }
Example #14
Source File: CompilationPhase.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { if (!compiler.isOnDemandCompilation()) { // Only do this on initial preprocessing of the source code. For on-demand compilations from // source, FindScopeDepths#leaveFunctionNode() calls data.setCachedAst() for the sole function // being compiled. transformFunction(fn, new CacheAst(compiler)); } // NOTE: we're returning the original fn as we have destructively modified the cached functions by // removing their bodies. This step is associating FunctionNode objects with // RecompilableScriptFunctionData; it's not really modifying the AST. return fn; }
Example #15
Source File: CompilationPhase.java From hottub with GNU General Public License v2.0 | 5 votes |
private static CompileUnit createNewCompileUnit(final Compiler compiler, final CompilationPhases phases) { final StringBuilder sb = new StringBuilder(compiler.nextCompileUnitName()); if (phases.isRestOfCompilation()) { sb.append("$restOf"); } //it's ok to not copy the initCount, methodCount and clinitCount here, as codegen is what //fills those out anyway. Thus no need for a copy constructor return compiler.createCompileUnit(sb.toString(), 0); }
Example #16
Source File: CompilationPhase.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { // It's not necessary to guard the marking of symbols as locals with this "if" condition for // correctness, it's just an optimization -- runtime type calculation is not used when the compilation // is not an on-demand optimistic compilation, so we can skip locals marking then. if (compiler.useOptimisticTypes() && compiler.isOnDemandCompilation()) { fn.getBody().accept(new SimpleNodeVisitor() { @Override public boolean enterFunctionNode(final FunctionNode functionNode) { // OTOH, we must not declare symbols from nested functions to be locals. As we're doing on-demand // compilation, and we're skipping parsing the function bodies for nested functions, this // basically only means their parameters. It'd be enough to mistakenly declare to be a local a // symbol in the outer function named the same as one of the parameters, though. return false; }; @Override public boolean enterBlock(final Block block) { for (final Symbol symbol: block.getSymbols()) { if (!symbol.isScope()) { compiler.declareLocalSymbol(symbol.getName()); } } return true; }; }); } return fn; }
Example #17
Source File: CompilationPhase.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { if (compiler.useOptimisticTypes()) { return transformFunction(fn, new OptimisticTypesCalculator(compiler)); } return fn; }
Example #18
Source File: CompilationPhase.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { if (!compiler.isOnDemandCompilation()) { // Only do this on initial preprocessing of the source code. For on-demand compilations from // source, FindScopeDepths#leaveFunctionNode() calls data.setCachedAst() for the sole function // being compiled. transformFunction(fn, new CacheAst(compiler)); } // NOTE: we're returning the original fn as we have destructively modified the cached functions by // removing their bodies. This step is associating FunctionNode objects with // RecompilableScriptFunctionData; it's not really modifying the AST. return fn; }
Example #19
Source File: CompilationPhase.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { final Set<CompileUnit> unitSet = CompileUnit.createCompileUnitSet(); final Map<CompileUnit, CompileUnit> unitMap = new HashMap<>(); // Ensure that the FunctionNode's compile unit is the first in the list of new units. Install phase // will use that as the root class. createCompileUnit(fn.getCompileUnit(), unitSet, unitMap, compiler, phases); final FunctionNode newFn = transformFunction(fn, new ReplaceCompileUnits() { @Override CompileUnit getReplacement(final CompileUnit oldUnit) { final CompileUnit existing = unitMap.get(oldUnit); if (existing != null) { return existing; } return createCompileUnit(oldUnit, unitSet, unitMap, compiler, phases); } @Override public Node leaveFunctionNode(final FunctionNode fn2) { return super.leaveFunctionNode( // restore flags for deserialized nested function nodes compiler.getScriptFunctionData(fn2.getId()).restoreFlags(lc, fn2)); }; }); compiler.replaceCompileUnits(unitSet); return newFn; }
Example #20
Source File: CompilationPhase.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static CompileUnit createNewCompileUnit(final Compiler compiler, final CompilationPhases phases) { final StringBuilder sb = new StringBuilder(compiler.nextCompileUnitName()); if (phases.isRestOfCompilation()) { sb.append("$restOf"); } //it's ok to not copy the initCount, methodCount and clinitCount here, as codegen is what //fills those out anyway. Thus no need for a copy constructor return compiler.createCompileUnit(sb.toString(), 0); }
Example #21
Source File: RecompilableScriptFunctionData.java From hottub with GNU General Public License v2.0 | 5 votes |
private FunctionInitializer compileTypeSpecialization(final MethodType actualCallSiteType, final ScriptObject runtimeScope, final boolean persist) { // We're creating an empty script object for holding local variables. AssignSymbols will populate it with // explicit Undefined values for undefined local variables (see AssignSymbols#defineSymbol() and // CompilationEnvironment#declareLocalSymbol()). if (log.isEnabled()) { log.info("Parameter type specialization of '", functionName, "' signature: ", actualCallSiteType); } final boolean persistentCache = persist && usePersistentCodeCache(); String cacheKey = null; if (persistentCache) { final TypeMap typeMap = typeMap(actualCallSiteType); final Type[] paramTypes = typeMap == null ? null : typeMap.getParameterTypes(functionNodeId); cacheKey = CodeStore.getCacheKey(functionNodeId, paramTypes); final CodeInstaller newInstaller = getInstallerForNewCode(); final StoredScript script = newInstaller.loadScript(source, cacheKey); if (script != null) { Compiler.updateCompilationId(script.getCompilationId()); return script.installFunction(this, newInstaller); } } final FunctionNode fn = reparse(); final Compiler compiler = getCompiler(fn, actualCallSiteType, runtimeScope); final FunctionNode compiledFn = compiler.compile(fn, fn.isCached() ? CompilationPhases.COMPILE_ALL_CACHED : CompilationPhases.COMPILE_ALL); if (persist && !compiledFn.hasApplyToCallSpecialization()) { compiler.persistClassInfo(cacheKey, compiledFn); } return new FunctionInitializer(compiledFn, compiler.getInvalidatedProgramPoints()); }
Example #22
Source File: RecompilableScriptFunctionData.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private FunctionInitializer compileTypeSpecialization(final MethodType actualCallSiteType, final ScriptObject runtimeScope, final boolean persist) { // We're creating an empty script object for holding local variables. AssignSymbols will populate it with // explicit Undefined values for undefined local variables (see AssignSymbols#defineSymbol() and // CompilationEnvironment#declareLocalSymbol()). if (log.isEnabled()) { log.info("Parameter type specialization of '", functionName, "' signature: ", actualCallSiteType); } final boolean persistentCache = persist && usePersistentCodeCache(); String cacheKey = null; if (persistentCache) { final TypeMap typeMap = typeMap(actualCallSiteType); final Type[] paramTypes = typeMap == null ? null : typeMap.getParameterTypes(functionNodeId); cacheKey = CodeStore.getCacheKey(functionNodeId, paramTypes); final CodeInstaller newInstaller = getInstallerForNewCode(); final StoredScript script = newInstaller.loadScript(source, cacheKey); if (script != null) { Compiler.updateCompilationId(script.getCompilationId()); return script.installFunction(this, newInstaller); } } final FunctionNode fn = reparse(); final Compiler compiler = getCompiler(fn, actualCallSiteType, runtimeScope); final FunctionNode compiledFn = compiler.compile(fn, fn.isCached() ? CompilationPhases.COMPILE_ALL_CACHED : CompilationPhases.COMPILE_ALL); if (persist && !compiledFn.hasApplyToCallSpecialization()) { compiler.persistClassInfo(cacheKey, compiledFn); } return new FunctionInitializer(compiledFn, compiler.getInvalidatedProgramPoints()); }
Example #23
Source File: CompilationPhase.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
@Override FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { // It's not necessary to guard the marking of symbols as locals with this "if" condition for // correctness, it's just an optimization -- runtime type calculation is not used when the compilation // is not an on-demand optimistic compilation, so we can skip locals marking then. if (compiler.useOptimisticTypes() && compiler.isOnDemandCompilation()) { fn.getBody().accept(new SimpleNodeVisitor() { @Override public boolean enterFunctionNode(final FunctionNode functionNode) { // OTOH, we must not declare symbols from nested functions to be locals. As we're doing on-demand // compilation, and we're skipping parsing the function bodies for nested functions, this // basically only means their parameters. It'd be enough to mistakenly declare to be a local a // symbol in the outer function named the same as one of the parameters, though. return false; }; @Override public boolean enterBlock(final Block block) { for (final Symbol symbol: block.getSymbols()) { if (!symbol.isScope()) { compiler.declareLocalSymbol(symbol.getName()); } } return true; }; }); } return fn; }
Example #24
Source File: CompilationPhase.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
@Override FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { if (compiler.useOptimisticTypes()) { return transformFunction(fn, new OptimisticTypesCalculator(compiler)); } return fn; }
Example #25
Source File: CompilationPhase.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private CompileUnit createCompileUnit(final CompileUnit oldUnit, final Set<CompileUnit> unitSet, final Map<CompileUnit, CompileUnit> unitMap, final Compiler compiler, final CompilationPhases phases) { final CompileUnit newUnit = createNewCompileUnit(compiler, phases); unitMap.put(oldUnit, newUnit); unitSet.add(newUnit); return newUnit; }
Example #26
Source File: CompilationPhase.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static CompileUnit createNewCompileUnit(final Compiler compiler, final CompilationPhases phases) { final StringBuilder sb = new StringBuilder(compiler.nextCompileUnitName()); if (phases.isRestOfCompilation()) { sb.append("$restOf"); } //it's ok to not copy the initCount, methodCount and clinitCount here, as codegen is what //fills those out anyway. Thus no need for a copy constructor return compiler.createCompileUnit(sb.toString(), 0); }
Example #27
Source File: CompilationPhase.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
@Override FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { if (compiler.useOptimisticTypes()) { return transformFunction(fn, new OptimisticTypesCalculator(compiler)); } return fn; }
Example #28
Source File: RecompilableScriptFunctionData.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private FunctionInitializer compileTypeSpecialization(final MethodType actualCallSiteType, final ScriptObject runtimeScope, final boolean persist) { // We're creating an empty script object for holding local variables. AssignSymbols will populate it with // explicit Undefined values for undefined local variables (see AssignSymbols#defineSymbol() and // CompilationEnvironment#declareLocalSymbol()). if (log.isEnabled()) { log.info("Parameter type specialization of '", functionName, "' signature: ", actualCallSiteType); } final boolean persistentCache = persist && usePersistentCodeCache(); String cacheKey = null; if (persistentCache) { final TypeMap typeMap = typeMap(actualCallSiteType); final Type[] paramTypes = typeMap == null ? null : typeMap.getParameterTypes(functionNodeId); cacheKey = CodeStore.getCacheKey(functionNodeId, paramTypes); final CodeInstaller newInstaller = getInstallerForNewCode(); final StoredScript script = newInstaller.loadScript(source, cacheKey); if (script != null) { Compiler.updateCompilationId(script.getCompilationId()); return script.installFunction(this, newInstaller); } } final FunctionNode fn = reparse(); final Compiler compiler = getCompiler(fn, actualCallSiteType, runtimeScope); final FunctionNode compiledFn = compiler.compile(fn, fn.isCached() ? CompilationPhases.COMPILE_ALL_CACHED : CompilationPhases.COMPILE_ALL); if (persist && !compiledFn.hasApplyToCallSpecialization()) { compiler.persistClassInfo(cacheKey, compiledFn); } return new FunctionInitializer(compiledFn, compiler.getInvalidatedProgramPoints()); }
Example #29
Source File: CompilationPhase.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override FunctionNode transform(final Compiler compiler, final CompilationPhases phases, final FunctionNode fn) { if (!compiler.isOnDemandCompilation()) { // Only do this on initial preprocessing of the source code. For on-demand compilations from // source, FindScopeDepths#leaveFunctionNode() calls data.setCachedAst() for the sole function // being compiled. transformFunction(fn, new CacheAst(compiler)); } // NOTE: we're returning the original fn as we have destructively modified the cached functions by // removing their bodies. This step is associating FunctionNode objects with // RecompilableScriptFunctionData; it's not really modifying the AST. return fn; }
Example #30
Source File: CompilationPhase.java From hottub with GNU General Public License v2.0 | 5 votes |
private CompileUnit createCompileUnit(final CompileUnit oldUnit, final Set<CompileUnit> unitSet, final Map<CompileUnit, CompileUnit> unitMap, final Compiler compiler, final CompilationPhases phases) { final CompileUnit newUnit = createNewCompileUnit(compiler, phases); unitMap.put(oldUnit, newUnit); unitSet.add(newUnit); return newUnit; }