< prev index next >

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

Print this page




1386         // This would store a full script compilation with many wrong optimistic assumptions that would
1387         // do more harm than good on later runs with both optimistic types and lazy compilation enabled.
1388         final boolean useCodeStore = codeStore != null && !env._parse_only && (!env._optimistic_types || env._lazy_compilation);
1389         final String cacheKey = useCodeStore ? CodeStore.getCacheKey("script", null) : null;
1390 
1391         if (useCodeStore) {
1392             storedScript = codeStore.load(source, cacheKey);
1393         }
1394 
1395         if (storedScript == null) {
1396             if (env._dest_dir != null) {
1397                 source.dump(env._dest_dir);
1398             }
1399 
1400             functionNode = new Parser(env, source, errMan, strict, getLogger(Parser.class)).parse();
1401 
1402             if (errMan.hasErrors()) {
1403                 return null;
1404             }
1405 
1406             if (env._print_ast || functionNode.getFlag(FunctionNode.IS_PRINT_AST)) {
1407                 getErr().println(new ASTWriter(functionNode));
1408             }
1409 
1410             if (env._print_parse || functionNode.getFlag(FunctionNode.IS_PRINT_PARSE)) {
1411                 getErr().println(new PrintVisitor(functionNode, true, false));
1412             }
1413         }
1414 
1415         if (env._parse_only) {
1416             return null;
1417         }
1418 
1419         final URL          url    = source.getURL();
1420         final CodeSource   cs     = new CodeSource(url, (CodeSigner[])null);
1421         final CodeInstaller installer;
1422         if (!env.useAnonymousClasses(isEval) || env._persistent_cache || !env._lazy_compilation) {
1423             // Persistent code cache and eager compilation preclude use of VM anonymous classes
1424             final ScriptLoader loader = env._loader_per_compile ? createNewLoader() : scriptLoader;
1425             installer = new NamedContextCodeInstaller(this, cs, loader);
1426         } else {
1427             installer = new AnonymousContextCodeInstaller(this, cs,
1428                     anonymousHostClasses.getOrCreate(cs, (key) ->
1429                             createNewLoader().installClass(
1430                                     // NOTE: we're defining these constants in AnonymousContextCodeInstaller so they are not




1386         // This would store a full script compilation with many wrong optimistic assumptions that would
1387         // do more harm than good on later runs with both optimistic types and lazy compilation enabled.
1388         final boolean useCodeStore = codeStore != null && !env._parse_only && (!env._optimistic_types || env._lazy_compilation);
1389         final String cacheKey = useCodeStore ? CodeStore.getCacheKey("script", null) : null;
1390 
1391         if (useCodeStore) {
1392             storedScript = codeStore.load(source, cacheKey);
1393         }
1394 
1395         if (storedScript == null) {
1396             if (env._dest_dir != null) {
1397                 source.dump(env._dest_dir);
1398             }
1399 
1400             functionNode = new Parser(env, source, errMan, strict, getLogger(Parser.class)).parse();
1401 
1402             if (errMan.hasErrors()) {
1403                 return null;
1404             }
1405 
1406             if (env._print_ast || functionNode.getDebugFlag(FunctionNode.DEBUG_PRINT_AST)) {
1407                 getErr().println(new ASTWriter(functionNode));
1408             }
1409 
1410             if (env._print_parse || functionNode.getDebugFlag(FunctionNode.DEBUG_PRINT_PARSE)) {
1411                 getErr().println(new PrintVisitor(functionNode, true, false));
1412             }
1413         }
1414 
1415         if (env._parse_only) {
1416             return null;
1417         }
1418 
1419         final URL          url    = source.getURL();
1420         final CodeSource   cs     = new CodeSource(url, (CodeSigner[])null);
1421         final CodeInstaller installer;
1422         if (!env.useAnonymousClasses(isEval) || env._persistent_cache || !env._lazy_compilation) {
1423             // Persistent code cache and eager compilation preclude use of VM anonymous classes
1424             final ScriptLoader loader = env._loader_per_compile ? createNewLoader() : scriptLoader;
1425             installer = new NamedContextCodeInstaller(this, cs, loader);
1426         } else {
1427             installer = new AnonymousContextCodeInstaller(this, cs,
1428                     anonymousHostClasses.getOrCreate(cs, (key) ->
1429                             createNewLoader().installClass(
1430                                     // NOTE: we're defining these constants in AnonymousContextCodeInstaller so they are not


< prev index next >