mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-12 19:35:24 +00:00
8044171: Make optimistic exception handlers smaller
Reviewed-by: hannesw, lagergren
This commit is contained in:
parent
dba2bf3f02
commit
11fb0e2143
@ -187,10 +187,10 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex
|
||||
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 @@ final class CodeGenerator extends NodeOperatorVisitor<CodeGeneratorLexicalContex
|
||||
// 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();
|
||||
}
|
||||
|
||||
@ -82,6 +82,17 @@ public class RewriteException extends Exception {
|
||||
/** 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 @@ public class RewriteException extends Exception {
|
||||
* 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 @@ public class RewriteException extends Exception {
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user