Mercurial > hg > openjdk > jdk9 > nashorn
changeset 872:0625a45b5333
8044171: Make optimistic exception handlers smaller
Reviewed-by: hannesw, lagergren
author | attila |
---|---|
date | Tue, 03 Jun 2014 11:31:06 +0200 |
parents | f855686309df |
children | eff9df533685 |
files | src/jdk/nashorn/internal/codegen/CodeGenerator.java src/jdk/nashorn/internal/runtime/RewriteException.java |
diffstat | 2 files changed, 23 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/src/jdk/nashorn/internal/codegen/CodeGenerator.java Tue Jun 03 14:13:03 2014 +0530 +++ b/src/jdk/nashorn/internal/codegen/CodeGenerator.java Tue Jun 03 11:31:06 2014 +0200 @@ -187,10 +187,10 @@ private static final String SCRIPTFUNCTION_IMPL_NAME = Type.getInternalName(ScriptFunctionImpl.class); private static final Type SCRIPTFUNCTION_IMPL_TYPE = Type.typeFor(ScriptFunction.class); - private static final Call INIT_REWRITE_EXCEPTION = CompilerConstants.specialCallNoLookup(RewriteException.class, - "<init>", void.class, UnwarrantedOptimismException.class, Object[].class, String[].class); - private static final Call INIT_REWRITE_EXCEPTION_REST_OF = CompilerConstants.specialCallNoLookup(RewriteException.class, - "<init>", void.class, UnwarrantedOptimismException.class, Object[].class, String[].class, int[].class); + private static final Call CREATE_REWRITE_EXCEPTION = CompilerConstants.staticCallNoLookup(RewriteException.class, + "create", RewriteException.class, UnwarrantedOptimismException.class, Object[].class, String[].class); + private static final Call CREATE_REWRITE_EXCEPTION_REST_OF = CompilerConstants.staticCallNoLookup(RewriteException.class, + "create", RewriteException.class, UnwarrantedOptimismException.class, Object[].class, String[].class, int[].class); private static final Call ENSURE_INT = CompilerConstants.staticCallNoLookup(OptimisticReturnFilters.class, "ensureInt", int.class, Object.class, int.class); @@ -4952,16 +4952,12 @@ // At this point we have the UnwarrantedOptimismException and the Object[] with local variables on // stack. We need to create a RewriteException, push two references to it below the constructor // arguments, invoke the constructor, and throw the exception. - method._new(RewriteException.class); - method.dup(2); - method.dup(2); - method.pop(); loadConstant(getByteCodeSymbolNames(fn)); if (isRestOf()) { loadConstant(getContinuationEntryPoints()); - method.invoke(INIT_REWRITE_EXCEPTION_REST_OF); + method.invoke(CREATE_REWRITE_EXCEPTION_REST_OF); } else { - method.invoke(INIT_REWRITE_EXCEPTION); + method.invoke(CREATE_REWRITE_EXCEPTION); } method.athrow(); }
--- a/src/jdk/nashorn/internal/runtime/RewriteException.java Tue Jun 03 14:13:03 2014 +0530 +++ b/src/jdk/nashorn/internal/runtime/RewriteException.java Tue Jun 03 11:31:06 2014 +0200 @@ -82,6 +82,17 @@ /** Call for asserting the length of an array. */ public static final Call ASSERT_ARRAY_LENGTH = staticCallNoLookup(RewriteException.class, "assertArrayLength", void.class, Object[].class, int.class); + private RewriteException( + final UnwarrantedOptimismException e, + final Object[] byteCodeSlots, + final String[] byteCodeSymbolNames, + final int[] previousContinuationEntryPoints) { + super("", e, false, Context.DEBUG); + this.byteCodeSlots = byteCodeSlots; + this.runtimeScope = mergeSlotsWithScope(byteCodeSlots, byteCodeSymbolNames); + this.previousContinuationEntryPoints = previousContinuationEntryPoints; + } + /** * Constructor for a rewrite exception thrown from an optimistic function. * @param e the {@link UnwarrantedOptimismException} that triggered this exception. @@ -91,12 +102,12 @@ * effort to assist evaluation of expressions for their types by the compiler doing the deoptimizing recompilation, * and can thus be incomplete - the more complete it is, the more expressions can be evaluated by the compiler, and * the more unnecessary deoptimizing compilations can be avoided. + * @return a new rewrite exception */ - public RewriteException( - final UnwarrantedOptimismException e, + public static RewriteException create(final UnwarrantedOptimismException e, final Object[] byteCodeSlots, final String[] byteCodeSymbolNames) { - this(e, byteCodeSlots, byteCodeSymbolNames, null); + return create(e, byteCodeSlots, byteCodeSymbolNames, null); } /** @@ -110,16 +121,13 @@ * the more unnecessary deoptimizing compilations can be avoided. * @param previousContinuationEntryPoints an array of continuation entry points that were already executed during * one logical invocation of the function (a rest-of triggering a rest-of triggering a...) + * @return a new rewrite exception */ - public RewriteException( - final UnwarrantedOptimismException e, + public static RewriteException create(final UnwarrantedOptimismException e, final Object[] byteCodeSlots, final String[] byteCodeSymbolNames, final int[] previousContinuationEntryPoints) { - super("", e, false, Context.DEBUG); - this.byteCodeSlots = byteCodeSlots; - this.runtimeScope = mergeSlotsWithScope(byteCodeSlots, byteCodeSymbolNames); - this.previousContinuationEntryPoints = previousContinuationEntryPoints; + return new RewriteException(e, byteCodeSlots, byteCodeSymbolNames, previousContinuationEntryPoints); } /**