public final class GraalDirectives extends Object
| Modifier and Type | Field and Description |
|---|---|
static double |
FASTPATH_PROBABILITY |
static double |
LIKELY_PROBABILITY |
static double |
SLOWPATH_PROBABILITY |
static double |
UNLIKELY_PROBABILITY |
| Constructor and Description |
|---|
GraalDirectives() |
| Modifier and Type | Method and Description |
|---|---|
static <T> T |
assumeStableDimension(T t,
int i)
A call to this method will assume a stable dimension array if
t is a constant array
and i a constant integer. |
static void |
bindToRegister(boolean value)
Forces a value to be kept in a register.
|
static void |
bindToRegister(byte value)
Forces a value to be kept in a register.
|
static void |
bindToRegister(char value)
Forces a value to be kept in a register.
|
static void |
bindToRegister(double value)
Forces a value to be kept in a register.
|
static void |
bindToRegister(float value)
Forces a value to be kept in a register.
|
static void |
bindToRegister(int value)
Forces a value to be kept in a register.
|
static void |
bindToRegister(long value)
Forces a value to be kept in a register.
|
static void |
bindToRegister(Object value)
Forces a value to be kept in a register.
|
static void |
bindToRegister(short value)
Forces a value to be kept in a register.
|
static void |
blackhole(boolean value)
Consume a value, making sure the compiler doesn't optimize away the computation of this
value, even if it is otherwise unused.
|
static void |
blackhole(byte value)
Consume a value, making sure the compiler doesn't optimize away the computation of this
value, even if it is otherwise unused.
|
static void |
blackhole(char value)
Consume a value, making sure the compiler doesn't optimize away the computation of this
value, even if it is otherwise unused.
|
static void |
blackhole(double value)
Consume a value, making sure the compiler doesn't optimize away the computation of this
value, even if it is otherwise unused.
|
static void |
blackhole(float value)
Consume a value, making sure the compiler doesn't optimize away the computation of this
value, even if it is otherwise unused.
|
static void |
blackhole(int value)
Consume a value, making sure the compiler doesn't optimize away the computation of this
value, even if it is otherwise unused.
|
static void |
blackhole(long value)
Consume a value, making sure the compiler doesn't optimize away the computation of this
value, even if it is otherwise unused.
|
static void |
blackhole(Object value)
Consume a value, making sure the compiler doesn't optimize away the computation of this
value, even if it is otherwise unused.
|
static void |
blackhole(short value)
Consume a value, making sure the compiler doesn't optimize away the computation of this
value, even if it is otherwise unused.
|
static void |
breakpoint()
Raise a SIGTRAP that can be used as a breakpoint for a native debugger such as gdb.
|
static void |
controlFlowAnchor()
A call to this method will never be duplicated by control flow optimizations in the compiler.
|
static void |
deoptimize()
Directive for the compiler to fall back to the bytecode interpreter at this point.
|
static void |
deoptimize(DeoptimizationAction action,
DeoptimizationReason reason,
boolean withSpeculation)
Directive for the compiler to fall back to the bytecode interpreter at this point.
|
static void |
deoptimize(DeoptimizationAction action,
DeoptimizationReason reason,
SpeculationReason speculation)
Directive for the compiler to fall back to the bytecode interpreter at this point.
|
static void |
deoptimizeAndInvalidate()
Directive for the compiler to fall back to the bytecode interpreter at this point.
|
static void |
ensureVirtualized(Object object)
Ensures that the given object will be virtual (escape analyzed) at all points that are
dominated by the current position.
|
static void |
ensureVirtualizedHere(Object object)
Ensures that the given object will be virtual at the current position.
|
static <T> T |
guardingNonNull(T value) |
static boolean |
inCompiledCode()
Returns a boolean value indicating whether the method is executed in Graal-compiled code.
|
static boolean |
inIntrinsic()
Determines if the method is called within the scope of a Graal intrinsic.
|
static boolean |
injectBranchProbability(double probability,
boolean condition)
Injects a probability for the given condition into the profiling information of a branch
instruction.
|
static boolean |
injectIterationCount(double iterations,
boolean condition)
Injects an average iteration count of a loop into the probability information of a loop exit
condition.
|
static boolean |
isCompilationConstant(boolean value) |
static boolean |
isCompilationConstant(byte value) |
static boolean |
isCompilationConstant(char value) |
static boolean |
isCompilationConstant(double value) |
static boolean |
isCompilationConstant(float value) |
static boolean |
isCompilationConstant(int value) |
static boolean |
isCompilationConstant(long value) |
static boolean |
isCompilationConstant(Object value)
Returns a boolean indicating whether or not a given value is seen as constant in optimized
code.
|
static boolean |
isCompilationConstant(short value) |
static void |
log(String value)
Prints a string to the log stream.
|
static void |
log(String format,
long value)
Prints a formatted string to the log stream.
|
static void |
log(String format,
long v1,
long v2)
Prints a formatted string to the log stream.
|
static void |
log(String format,
long v1,
long v2,
long v3)
Prints a formatted string to the log stream.
|
static void |
neverStripMine()
A call to this method will disable strip mining of the enclosing loop in the compiler.
|
static boolean |
opaque(boolean value)
Do nothing, but also make sure the compiler doesn't do any optimizations across this call.
|
static byte |
opaque(byte value)
Do nothing, but also make sure the compiler doesn't do any optimizations across this call.
|
static char |
opaque(char value)
Do nothing, but also make sure the compiler doesn't do any optimizations across this call.
|
static double |
opaque(double value)
Do nothing, but also make sure the compiler doesn't do any optimizations across this call.
|
static float |
opaque(float value)
Do nothing, but also make sure the compiler doesn't do any optimizations across this call.
|
static int |
opaque(int value)
Do nothing, but also make sure the compiler doesn't do any optimizations across this call.
|
static long |
opaque(long value)
Do nothing, but also make sure the compiler doesn't do any optimizations across this call.
|
static short |
opaque(short value)
Do nothing, but also make sure the compiler doesn't do any optimizations across this call.
|
static <T> T |
opaque(T value)
Do nothing, but also make sure the compiler doesn't do any optimizations across this call.
|
static void |
sideEffect()
A call to this method will force the compiler to assume this instruction has a visible memory
effect killing all memory locations.
|
static int |
sideEffect(int a)
A call to this method will force the compiler to assume this instruction has a visible memory
effect killing all memory locations.
|
static long |
sideEffect(long a)
A call to this method will force the compiler to assume this instruction has a visible memory
effect killing all memory locations.
|
static void |
spillRegisters()
Spills all caller saved registers.
|
static <P> P |
trustedBox(P o)
Inject information into the compiler to assume that the input is an object created via a
primitive boxing operation.
|
public static final double LIKELY_PROBABILITY
public static final double UNLIKELY_PROBABILITY
public static final double SLOWPATH_PROBABILITY
public static final double FASTPATH_PROBABILITY
public static void deoptimize(DeoptimizationAction action,
DeoptimizationReason reason,
SpeculationReason speculation)
action - the action to take with respect to the code being deoptimizedreason - the reason to use for the deoptimizationspeculation - a speculation to be attached to the deoptimizationpublic static void deoptimize(DeoptimizationAction action,
DeoptimizationReason reason,
boolean withSpeculation)
action - the action to take with respect to the code being deoptimizedreason - the reason to use for the deoptimizationwithSpeculation - if true, then a speculation will be attached to the deoptimizationpublic static void deoptimize()
GraalDirectives.deoptimize(DeoptimizationAction, DeoptimizationReason, boolean) with
DeoptimizationAction.None, DeoptimizationReason.TransferToInterpreter and
false as arguments.public static void deoptimizeAndInvalidate()
GraalDirectives.deoptimize(DeoptimizationAction, DeoptimizationReason, boolean) with
DeoptimizationAction.InvalidateReprofile,
DeoptimizationReason.TransferToInterpreter and false as arguments.public static boolean inCompiledCode()
public static boolean inIntrinsic()
public static void controlFlowAnchor()
public static void neverStripMine()
public static <T> T assumeStableDimension(T t,
int i)
t is a constant array
and i a constant integer.public static void sideEffect()
public static <P> P trustedBox(P o)
public static int sideEffect(int a)
public static long sideEffect(long a)
public static boolean injectBranchProbability(double probability,
boolean condition)
if (injectBranchProbability(0.9, a > b)) {
// ...
}
There are predefined constants for commonly used probabilities (see
GraalDirectives.LIKELY_PROBABILITY , GraalDirectives.UNLIKELY_PROBABILITY, GraalDirectives.SLOWPATH_PROBABILITY,
GraalDirectives.FASTPATH_PROBABILITY ).probability - the probability value between 0.0 and 1.0 that should be injectedpublic static boolean injectIterationCount(double iterations,
boolean condition)
for (int i = 0; injectIterationCount(500, i < array.length); i++) {
// ...
}
iterations - the expected number of iterations that should be injectedpublic static void blackhole(boolean value)
public static void blackhole(byte value)
public static void blackhole(short value)
public static void blackhole(char value)
public static void blackhole(int value)
public static void blackhole(long value)
public static void blackhole(float value)
public static void blackhole(double value)
public static void blackhole(Object value)
public static void bindToRegister(boolean value)
public static void bindToRegister(byte value)
public static void bindToRegister(short value)
public static void bindToRegister(char value)
public static void bindToRegister(int value)
public static void bindToRegister(long value)
public static void bindToRegister(float value)
public static void bindToRegister(double value)
public static void bindToRegister(Object value)
public static void spillRegisters()
public static boolean opaque(boolean value)
public static byte opaque(byte value)
public static short opaque(short value)
public static char opaque(char value)
public static int opaque(int value)
public static long opaque(long value)
public static float opaque(float value)
public static double opaque(double value)
public static <T> T opaque(T value)
public static <T> T guardingNonNull(T value)
public static void ensureVirtualized(Object object)
public static void ensureVirtualizedHere(Object object)
public static void breakpoint()
public static boolean isCompilationConstant(Object value)
public static boolean isCompilationConstant(boolean value)
public static boolean isCompilationConstant(byte value)
public static boolean isCompilationConstant(short value)
public static boolean isCompilationConstant(char value)
public static boolean isCompilationConstant(int value)
public static boolean isCompilationConstant(float value)
public static boolean isCompilationConstant(long value)
public static boolean isCompilationConstant(double value)
public static void log(String value)
public static void log(String format, long value)
format - a C style printf format value that can contain at most one conversion specifier
(i.e., a sequence of characters starting with '%').value - the value associated with the conversion specifierpublic static void log(String format, long v1, long v2)
format - a C style printf format value that can contain at most two conversion
specifiers (i.e., a sequence of characters starting with '%').v1 - the value associated with the first conversion specifierv2 - the value associated with the second conversion specifierpublic static void log(String format, long v1, long v2, long v3)
format - a C style printf format value that can contain at most three conversion
specifiers (i.e., a sequence of characters starting with '%').v1 - the value associated with the first conversion specifierv2 - the value associated with the second conversion specifierv3 - the value associated with the third conversion specifier