Mercurial > hg > openjdk > jdk8u > nashorn
changeset 1636:4c1aa7b8c43c jdk8u76-b02
Merge
author | robm |
---|---|
date | Wed, 23 Dec 2015 00:51:07 +0000 |
parents | 12b2f943fc6e (current diff) ab5cb7c26321 (diff) |
children | 3f80f041ae70 3c65556df04e |
files | |
diffstat | 10 files changed, 210 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/make/build.xml Mon Dec 21 15:23:00 2015 -0800 +++ b/make/build.xml Wed Dec 23 00:51:07 2015 +0000 @@ -356,6 +356,13 @@ permission java.util.PropertyPermission "nashorn.test.*", "read"; }; +grant codeBase "file:/${basedir}/test/script/basic/apply_to_call/*" { + permission java.io.FilePermission "${basedir}/test/script/-", "read"; + permission java.io.FilePermission "$${user.dir}", "read"; + permission java.util.PropertyPermission "user.dir", "read"; + permission java.util.PropertyPermission "nashorn.test.*", "read"; +}; + grant codeBase "file:/${basedir}/test/script/basic/parser/*" { permission java.io.FilePermission "${basedir}/test/script/-", "read"; permission java.io.FilePermission "$${user.dir}", "read";
--- a/src/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java Mon Dec 21 15:23:00 2015 -0800 +++ b/src/jdk/nashorn/internal/runtime/FinalScriptFunctionData.java Wed Dec 23 00:51:07 2015 +0000 @@ -89,11 +89,16 @@ } @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; }
--- a/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java Mon Dec 21 15:23:00 2015 -0800 +++ b/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java Wed Dec 23 00:51:07 2015 +0000 @@ -894,7 +894,7 @@ } @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);
--- a/src/jdk/nashorn/internal/runtime/ScriptFunction.java Mon Dec 21 15:23:00 2015 -0800 +++ b/src/jdk/nashorn/internal/runtime/ScriptFunction.java Wed Dec 23 00:51:07 2015 +0000 @@ -937,6 +937,13 @@ } } + // Is this an unstable callsite which was earlier apply-to-call optimized? + // If so, earlier apply2call would have exploded arguments. We have to convert + // that as an array again! + if (isUnstable && NashornCallSiteDescriptor.isApplyToCall(desc)) { + boundHandle = MH.asCollector(boundHandle, Object[].class, type.parameterCount() - 2); + } + boundHandle = pairArguments(boundHandle, type); if (bestInvoker.getSwitchPoints() != null) {
--- a/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java Mon Dec 21 15:23:00 2015 -0800 +++ b/src/jdk/nashorn/internal/runtime/ScriptFunctionData.java Wed Dec 23 00:51:07 2015 +0000 @@ -357,9 +357,23 @@ * @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) @@ -367,7 +381,7 @@ } CompiledFunction getGeneric(final ScriptObject runtimeScope) { - return getBest(getGenericType(), runtimeScope, CompiledFunction.NO_FUNCTIONS); + return getBest(getGenericType(), runtimeScope, CompiledFunction.NO_FUNCTIONS, false); } /**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8145550.js Wed Dec 23 00:51:07 2015 +0000 @@ -0,0 +1,33 @@ +/* + * 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 -Dnashorn.unstable.relink.threshold=1 + * @fork + * @run + */ + +load(__DIR__ + "NASHORN-421.js")
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/apply_to_call/JDK-8145669.js Wed Dec 23 00:51:07 2015 +0000 @@ -0,0 +1,33 @@ +/* + * 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-8145669: apply2call optimized callsite fails after becoming megamorphic + * + * @test + * @option -Dnashorn.unstable.relink.threshold=1 + * @fork + * @run + */ + +load(__DIR__ + "apply_to_call2.js");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/apply_to_call/JDK-8145669.js.EXPECTED Wed Dec 23 00:51:07 2015 +0000 @@ -0,0 +1,8 @@ +start +4711 +23 +17 +Overwriting call now +1 +2 +3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/apply_to_call/JDK-8145669_2.js Wed Dec 23 00:51:07 2015 +0000 @@ -0,0 +1,33 @@ +/* + * 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-8145669: apply2call optimized callsite fails after becoming megamorphic + * + * @test + * @option -Dnashorn.unstable.relink.threshold=1 + * @fork + * @run + */ + +load(__DIR__ + "apply_to_call_varargs.js");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/apply_to_call/JDK-8145669_2.js.EXPECTED Wed Dec 23 00:51:07 2015 +0000 @@ -0,0 +1,66 @@ +[red=0, green=255, blue=255] +undefined +[red=1, green=255, blue=255] +undefined +[red=2, green=255, blue=255] +undefined +[red=3, green=255, blue=255] +undefined +[red=4, green=255, blue=255] +undefined +[red=5, green=255, blue=255] +undefined +[red=6, green=255, blue=255] +undefined +[red=7, green=255, blue=255] +undefined +[red=8, green=255, blue=255] +undefined +[red=9, green=255, blue=255] +undefined +[red=10, green=255, blue=255] +undefined +[red=11, green=255, blue=255] +undefined +[red=12, green=255, blue=255] +undefined +[red=13, green=255, blue=255] +undefined +[red=14, green=255, blue=255] +undefined +[red=15, green=255, blue=255] +undefined +Swapping out call +[red=0, green=255, blue=255] +undefined +[red=1, green=255, blue=255] +undefined +[red=2, green=255, blue=255] +undefined +[red=3, green=255, blue=255] +undefined +[red=4, green=255, blue=255] +undefined +[red=5, green=255, blue=255] +undefined +[red=6, green=255, blue=255] +undefined +[red=7, green=255, blue=255] +undefined +[red=8, green=255, blue=255] +undefined +[red=9, green=255, blue=255] +undefined +[red=10, green=255, blue=255] +undefined +[red=11, green=255, blue=255] +undefined +[red=12, green=255, blue=255] +undefined +[red=13, green=255, blue=255] +undefined +[red=14, green=255, blue=255] +undefined +[red=15, green=255, blue=255] +undefined +All done!