< prev index next >

src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java

Print this page
rev 1901 : 8135251: Use Unsafe.defineAnonymousClass for loading Nashorn script code
Reviewed-by: hannesw, lagergren, sundar


 639     }
 640 
 641     private static ScriptObject newLocals(final ScriptObject runtimeScope) {
 642         final ScriptObject locals = Global.newEmptyInstance();
 643         locals.setProto(runtimeScope);
 644         return locals;
 645     }
 646 
 647     private Compiler getCompiler(final FunctionNode fn, final MethodType actualCallSiteType, final ScriptObject runtimeScope) {
 648         return getCompiler(fn, actualCallSiteType, newLocals(runtimeScope), null, null);
 649     }
 650 
 651     /**
 652      * Returns a code installer for installing new code. If we're using either optimistic typing or loader-per-compile,
 653      * then asks for a code installer with a new class loader; otherwise just uses the current installer. We use
 654      * a new class loader with optimistic typing so that deoptimized code can get reclaimed by GC.
 655      * @return a code installer for installing new code.
 656      */
 657     private CodeInstaller getInstallerForNewCode() {
 658         final ScriptEnvironment env = installer.getContext().getEnv();
 659         return env._optimistic_types || env._loader_per_compile ? installer.withNewLoader() : installer;
 660     }
 661 
 662     Compiler getCompiler(final FunctionNode functionNode, final MethodType actualCallSiteType,
 663             final ScriptObject runtimeScope, final Map<Integer, Type> invalidatedProgramPoints,
 664             final int[] continuationEntryPoints) {
 665         final TypeMap typeMap = typeMap(actualCallSiteType);
 666         final Type[] paramTypes = typeMap == null ? null : typeMap.getParameterTypes(functionNodeId);
 667         final Object typeInformationFile = OptimisticTypesPersistence.getLocationDescriptor(source, functionNodeId, paramTypes);
 668         return Compiler.forOnDemandCompilation(
 669                 getInstallerForNewCode(),
 670                 functionNode.getSource(),  // source
 671                 isStrict() | functionNode.isStrict(), // is strict
 672                 this,       // compiledFunction, i.e. this RecompilableScriptFunctionData
 673                 typeMap,    // type map
 674                 getEffectiveInvalidatedProgramPoints(invalidatedProgramPoints, typeInformationFile), // invalidated program points
 675                 typeInformationFile,
 676                 continuationEntryPoints, // continuation entry points
 677                 runtimeScope); // runtime scope
 678     }
 679 




 639     }
 640 
 641     private static ScriptObject newLocals(final ScriptObject runtimeScope) {
 642         final ScriptObject locals = Global.newEmptyInstance();
 643         locals.setProto(runtimeScope);
 644         return locals;
 645     }
 646 
 647     private Compiler getCompiler(final FunctionNode fn, final MethodType actualCallSiteType, final ScriptObject runtimeScope) {
 648         return getCompiler(fn, actualCallSiteType, newLocals(runtimeScope), null, null);
 649     }
 650 
 651     /**
 652      * Returns a code installer for installing new code. If we're using either optimistic typing or loader-per-compile,
 653      * then asks for a code installer with a new class loader; otherwise just uses the current installer. We use
 654      * a new class loader with optimistic typing so that deoptimized code can get reclaimed by GC.
 655      * @return a code installer for installing new code.
 656      */
 657     private CodeInstaller getInstallerForNewCode() {
 658         final ScriptEnvironment env = installer.getContext().getEnv();
 659         return env._optimistic_types || env._loader_per_compile ? installer.getOnDemandCompilationInstaller() : installer;
 660     }
 661 
 662     Compiler getCompiler(final FunctionNode functionNode, final MethodType actualCallSiteType,
 663             final ScriptObject runtimeScope, final Map<Integer, Type> invalidatedProgramPoints,
 664             final int[] continuationEntryPoints) {
 665         final TypeMap typeMap = typeMap(actualCallSiteType);
 666         final Type[] paramTypes = typeMap == null ? null : typeMap.getParameterTypes(functionNodeId);
 667         final Object typeInformationFile = OptimisticTypesPersistence.getLocationDescriptor(source, functionNodeId, paramTypes);
 668         return Compiler.forOnDemandCompilation(
 669                 getInstallerForNewCode(),
 670                 functionNode.getSource(),  // source
 671                 isStrict() | functionNode.isStrict(), // is strict
 672                 this,       // compiledFunction, i.e. this RecompilableScriptFunctionData
 673                 typeMap,    // type map
 674                 getEffectiveInvalidatedProgramPoints(invalidatedProgramPoints, typeInformationFile), // invalidated program points
 675                 typeInformationFile,
 676                 continuationEntryPoints, // continuation entry points
 677                 runtimeScope); // runtime scope
 678     }
 679 


< prev index next >