8145550: Megamorphic invoke should use CompiledFunction variants without any LinkLogic
Reviewed-by: jlaskey, hannesw, attila
This commit is contained in:
parent
2cee75db22
commit
e760e9cbf3
@ -98,6 +98,10 @@ public final class NativeFunction {
|
||||
public static Object apply(final Object self, final Object thiz, final Object array) {
|
||||
checkCallable(self);
|
||||
|
||||
System.out.println("self " + self);
|
||||
System.out.println("thiz " + thiz);
|
||||
System.out.println("array " + array);
|
||||
|
||||
final Object[] args = toApplyArgs(array);
|
||||
|
||||
if (self instanceof ScriptFunction) {
|
||||
|
@ -89,11 +89,16 @@ final class FinalScriptFunctionData extends ScriptFunctionData {
|
||||
}
|
||||
|
||||
@Override
|
||||
CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden) {
|
||||
CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden, boolean linkLogicOkay) {
|
||||
assert isValidCallSite(callSiteType) : callSiteType;
|
||||
|
||||
CompiledFunction best = null;
|
||||
for (final CompiledFunction candidate: code) {
|
||||
if (!linkLogicOkay && candidate.hasLinkLogic()) {
|
||||
// Skip! Version with no link logic is desired, but this one has link logic!
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!forbidden.contains(candidate) && candidate.betterThanFinal(best, callSiteType)) {
|
||||
best = candidate;
|
||||
}
|
||||
|
@ -886,7 +886,7 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp
|
||||
}
|
||||
|
||||
@Override
|
||||
synchronized CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden) {
|
||||
synchronized CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden, final boolean linkLogicOkay) {
|
||||
assert isValidCallSite(callSiteType) : callSiteType;
|
||||
|
||||
CompiledFunction existingBest = pickFunction(callSiteType, false);
|
||||
|
@ -373,9 +373,23 @@ public abstract class ScriptFunctionData implements Serializable {
|
||||
* @param runtimeScope the runtime scope. It can be used to evaluate types of scoped variables to guide the
|
||||
* optimistic compilation, should the call to this method trigger code compilation. Can be null if current runtime
|
||||
* scope is not known, but that might cause compilation of code that will need more deoptimization passes.
|
||||
* @param linkLogicOkay is a CompiledFunction with a LinkLogic acceptable?
|
||||
* @return the best function for the specified call site type.
|
||||
*/
|
||||
abstract CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden);
|
||||
abstract CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden, final boolean linkLogicOkay);
|
||||
|
||||
/**
|
||||
* Returns the best function for the specified call site type.
|
||||
* @param callSiteType The call site type. Call site types are expected to have the form
|
||||
* {@code (callee, this[, args...])}.
|
||||
* @param runtimeScope the runtime scope. It can be used to evaluate types of scoped variables to guide the
|
||||
* optimistic compilation, should the call to this method trigger code compilation. Can be null if current runtime
|
||||
* scope is not known, but that might cause compilation of code that will need more deoptimization passes.
|
||||
* @return the best function for the specified call site type.
|
||||
*/
|
||||
final CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden) {
|
||||
return getBest(callSiteType, runtimeScope, forbidden, true);
|
||||
}
|
||||
|
||||
boolean isValidCallSite(final MethodType callSiteType) {
|
||||
return callSiteType.parameterCount() >= 2 && // Must have at least (callee, this)
|
||||
@ -383,7 +397,7 @@ public abstract class ScriptFunctionData implements Serializable {
|
||||
}
|
||||
|
||||
CompiledFunction getGeneric(final ScriptObject runtimeScope) {
|
||||
return getBest(getGenericType(), runtimeScope, CompiledFunction.NO_FUNCTIONS);
|
||||
return getBest(getGenericType(), runtimeScope, CompiledFunction.NO_FUNCTIONS, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
32
nashorn/test/script/basic/JDK-8145550.js
Normal file
32
nashorn/test/script/basic/JDK-8145550.js
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 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-8141537: Megamorphic invoke should use CompiledFunction variants without any LinkLogic
|
||||
*
|
||||
* @test
|
||||
* @option --unstable-relink-threshold=1
|
||||
* @run
|
||||
*/
|
||||
|
||||
load(__DIR__ + "NASHORN-421.js")
|
Loading…
Reference in New Issue
Block a user