diff options
author | attila <none@none> | 2014-10-15 16:00:21 +0200 |
---|---|---|
committer | attila <none@none> | 2014-10-15 16:00:21 +0200 |
commit | 782c43fa485c634061e65eb1bee4425e7abf563f (patch) | |
tree | 95fdb25c12f5b65a4be2c1e4b8673a02a01636ed /src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java | |
parent | eb8718db00794bc2fb43c5ce000a602d5eb86217 (diff) | |
download | jdk8u_nashorn-782c43fa485c634061e65eb1bee4425e7abf563f.tar.gz |
8060241: Immediately invoked function expressions cause lot of deoptimization
Reviewed-by: hannesw, lagergren
Diffstat (limited to 'src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java')
-rw-r--r-- | src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java b/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java index f3ad2339..2e0b33bf 100644 --- a/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java +++ b/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java @@ -676,6 +676,22 @@ public final class RecompilableScriptFunctionData extends ScriptFunctionData imp return addCode(lookup(fnInit).asType(toType), fnInit.getInvalidatedProgramPoints(), callSiteType, fnInit.getFlags()); } + /** + * Returns the return type of a function specialization for particular parameter types.<br> + * <b>Be aware that the way this is implemented, it forces full materialization (compilation and installation) of + * code for that specialization.</b> + * @param callSiteType the parameter types at the call site. It must include the mandatory {@code callee} and + * {@code this} parameters, so it needs to start with at least {@code ScriptFunction.class} and + * {@code Object.class} class. Since the return type of the function is calculated from the code itself, it is + * irrelevant and should be set to {@code Object.class}. + * @param runtimeScope a current runtime scope. Can be null but when it's present it will be used as a source of + * current runtime values that can improve the compiler's type speculations (and thus reduce the need for later + * recompilations) if the specialization is not already present and thus needs to be freshly compiled. + * @return the return type of the function specialization. + */ + public Class<?> getReturnType(final MethodType callSiteType, final ScriptObject runtimeScope) { + return getBest(callSiteType, runtimeScope, CompiledFunction.NO_FUNCTIONS).type().returnType(); + } @Override synchronized CompiledFunction getBest(final MethodType callSiteType, final ScriptObject runtimeScope, final Collection<CompiledFunction> forbidden) { |