mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-11 02:48:20 +00:00
8078612: Persistent code cache should support more configurations
Reviewed-by: lagergren, attila
This commit is contained in:
parent
b3fa231c01
commit
08e8a63ab5
@ -189,7 +189,7 @@ public abstract class CodeStore implements Loggable {
|
||||
* @param paramTypes parameter types
|
||||
* @return a string representing the function
|
||||
*/
|
||||
public static String getCacheKey(final int functionId, final Type[] paramTypes) {
|
||||
public static String getCacheKey(final Object functionId, final Type[] paramTypes) {
|
||||
final StringBuilder b = new StringBuilder().append(functionId);
|
||||
if(paramTypes != null && paramTypes.length > 0) {
|
||||
b.append('-');
|
||||
@ -275,7 +275,7 @@ public abstract class CodeStore implements Loggable {
|
||||
|
||||
@Override
|
||||
public StoredScript load(final Source source, final String functionKey) {
|
||||
if (source.getLength() < minSize) {
|
||||
if (belowThreshold(source)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@ -1228,10 +1228,11 @@ public final class Context {
|
||||
|
||||
StoredScript storedScript = null;
|
||||
FunctionNode functionNode = null;
|
||||
// We only use the code store here if optimistic types are disabled. With optimistic types, initial compilation
|
||||
// just creates a thin wrapper, and actual code is stored per function in RecompilableScriptFunctionData.
|
||||
final boolean useCodeStore = codeStore != null && !env._parse_only && !env._optimistic_types;
|
||||
final String cacheKey = useCodeStore ? CodeStore.getCacheKey(0, null) : null;
|
||||
// Don't use code store if optimistic types is enabled but lazy compilation is not.
|
||||
// This would store a full script compilation with many wrong optimistic assumptions that would
|
||||
// do more harm than good on later runs with both optimistic types and lazy compilation enabled.
|
||||
final boolean useCodeStore = codeStore != null && !env._parse_only && (!env._optimistic_types || env._lazy_compilation);
|
||||
final String cacheKey = useCodeStore ? CodeStore.getCacheKey("script", null) : null;
|
||||
|
||||
if (useCodeStore) {
|
||||
storedScript = codeStore.load(source, cacheKey);
|
||||
|
||||
@ -113,7 +113,7 @@ public class ErrorManager {
|
||||
|
||||
// Pointer to column.
|
||||
for (int i = 0; i < column; i++) {
|
||||
if (sourceLine.charAt(i) == '\t') {
|
||||
if (i < sourceLine.length() && sourceLine.charAt(i) == '\t') {
|
||||
sb.append('\t');
|
||||
} else {
|
||||
sb.append(' ');
|
||||
|
||||
@ -491,7 +491,7 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp
|
||||
log.info("Parameter type specialization of '", functionName, "' signature: ", actualCallSiteType);
|
||||
}
|
||||
|
||||
final boolean persistentCache = usePersistentCodeCache() && persist;
|
||||
final boolean persistentCache = persist && usePersistentCodeCache();
|
||||
String cacheKey = null;
|
||||
if (persistentCache) {
|
||||
final TypeMap typeMap = typeMap(actualCallSiteType);
|
||||
@ -518,8 +518,7 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp
|
||||
}
|
||||
|
||||
boolean usePersistentCodeCache() {
|
||||
final ScriptEnvironment env = installer.getOwner();
|
||||
return env._persistent_cache && env._optimistic_types;
|
||||
return installer != null && installer.getOwner()._persistent_cache;
|
||||
}
|
||||
|
||||
private MethodType explicitParams(final MethodType callSiteType) {
|
||||
|
||||
35
nashorn/test/script/basic/JDK-8078612_eager_1a.js
Normal file
35
nashorn/test/script/basic/JDK-8078612_eager_1a.js
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* JDK-8078612: Persistent code cache should support more configurations
|
||||
*
|
||||
* @test
|
||||
* @runif external.prototype
|
||||
* @option -pcc
|
||||
* @option --lazy-compilation=false
|
||||
* @option -Dnashorn.persistent.code.cache=build/nashorn_code_cache
|
||||
* @fork
|
||||
*/
|
||||
|
||||
load(__DIR__ + 'prototype.js');
|
||||
@ -0,0 +1 @@
|
||||
parsed and compiled ok prototype.js
|
||||
35
nashorn/test/script/basic/JDK-8078612_eager_1b.js
Normal file
35
nashorn/test/script/basic/JDK-8078612_eager_1b.js
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* JDK-8078612: Persistent code cache should support more configurations
|
||||
*
|
||||
* @test
|
||||
* @runif external.prototype
|
||||
* @option -pcc
|
||||
* @option --lazy-compilation=false
|
||||
* @option -Dnashorn.persistent.code.cache=build/nashorn_code_cache
|
||||
* @fork
|
||||
*/
|
||||
|
||||
load(__DIR__ + 'prototype.js');
|
||||
@ -0,0 +1 @@
|
||||
parsed and compiled ok prototype.js
|
||||
35
nashorn/test/script/basic/JDK-8078612_eager_2a.js
Normal file
35
nashorn/test/script/basic/JDK-8078612_eager_2a.js
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* JDK-8078612: Persistent code cache should support more configurations
|
||||
*
|
||||
* @test
|
||||
* @runif external.yui
|
||||
* @option -pcc
|
||||
* @option --lazy-compilation=false
|
||||
* @option -Dnashorn.persistent.code.cache=build/nashorn_code_cache
|
||||
* @fork
|
||||
*/
|
||||
|
||||
load(__DIR__ + 'yui.js');
|
||||
@ -0,0 +1,2 @@
|
||||
parsed and compiled ok yui-min.js
|
||||
parsed and compiled ok yui.js
|
||||
35
nashorn/test/script/basic/JDK-8078612_eager_2b.js
Normal file
35
nashorn/test/script/basic/JDK-8078612_eager_2b.js
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/**
|
||||
* JDK-8078612: Persistent code cache should support more configurations
|
||||
*
|
||||
* @test
|
||||
* @runif external.yui
|
||||
* @option -pcc
|
||||
* @option --lazy-compilation=false
|
||||
* @option -Dnashorn.persistent.code.cache=build/nashorn_code_cache
|
||||
* @fork
|
||||
*/
|
||||
|
||||
load(__DIR__ + 'yui.js');
|
||||
@ -0,0 +1,2 @@
|
||||
parsed and compiled ok yui-min.js
|
||||
parsed and compiled ok yui.js
|
||||
@ -162,7 +162,7 @@ public class CodeStoreAndPathTest {
|
||||
e.eval(code3);// less than minimum size for storing
|
||||
// adding code1 and code2.
|
||||
final DirectoryStream<Path> stream = Files.newDirectoryStream(codeCachePath);
|
||||
checkCompiledScripts(stream, 2);
|
||||
checkCompiledScripts(stream, 4);
|
||||
}
|
||||
|
||||
private static Path getCodeCachePath(final boolean optimistic) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user