public class HotSpotGraalConstantReflectionProvider extends HotSpotConstantReflectionProvider
HotSpotConstantReflectionProvider
to override the implementation of
readConstantFieldValue(JavaField, JavaConstant)
with Graal specific semantics.Modifier and Type | Class and Description |
---|---|
(package private) static class |
HotSpotGraalConstantReflectionProvider.ImmutableCodeLazy
Separate out the static initialization of
embeddable fields to eliminate cycles
between clinit and other locks that could lead to deadlock.
|
Modifier and Type | Field and Description |
---|---|
static ThreadLocal<Boolean> |
FieldReadEnabledInImmutableCode |
memoryAccess, methodHandleAccess, runtime
Constructor and Description |
---|
HotSpotGraalConstantReflectionProvider(HotSpotJVMCIRuntimeProvider runtime) |
Modifier and Type | Method and Description |
---|---|
private static boolean |
assertionsEnabled() |
private static boolean |
equalsIgnoringLine(StackTraceElement left,
StackTraceElement right)
Compares two
StackTraceElement s for equality, ignoring differences in
line number. |
protected boolean |
isFinalInstanceFieldValueConstant(JavaConstant value,
Class<?> receiverClass)
Determines if a value read from a
final instance field is considered constant. |
protected boolean |
isStableInstanceFieldValueConstant(JavaConstant value,
Class<? extends Object> receiverClass)
Determines if a value read from a
Stable instance field is considered constant. |
protected boolean |
isStaticFieldConstant(HotSpotResolvedJavaField field)
In AOT mode, some fields should never be embedded even for snippets/replacements.
|
JavaConstant |
readConstantFieldValue(JavaField field,
JavaConstant receiver)
Gets the constant value of this field.
|
asJavaType, boxPrimitive, constantEquals, forString, getMemoryAccessProvider, getMethodHandleAccess, readArrayElement, readArrayLength, readConstantArrayElement, readConstantArrayElementForOffset, readFieldValue, readStableFieldValue, unboxPrimitive
public static final ThreadLocal<Boolean> FieldReadEnabledInImmutableCode
public HotSpotGraalConstantReflectionProvider(HotSpotJVMCIRuntimeProvider runtime)
public JavaConstant readConstantFieldValue(JavaField field, JavaConstant receiver)
HotSpotConstantReflectionProvider
static final
field may not be
considered constant if its declaring class is not yet initialized or if it is a well known
field that can be updated via other means (e.g., System.setOut(java.io.PrintStream)
).
The value
field in OptionValue
is considered constant if the type of
receiver
is (assignable to) StableOptionValue
.
readConstantFieldValue
in interface ConstantReflectionProvider
readConstantFieldValue
in class HotSpotConstantReflectionProvider
receiver
- object from which this field's value is to be read. This value is ignored if
this field is static.null
if this field is not considered
constant by the runtimeprotected boolean isStaticFieldConstant(HotSpotResolvedJavaField field)
isStaticFieldConstant
in class HotSpotConstantReflectionProvider
private static boolean assertionsEnabled()
private static boolean equalsIgnoringLine(StackTraceElement left, StackTraceElement right)
StackTraceElement
s for equality, ignoring differences in
line number.protected boolean isFinalInstanceFieldValueConstant(JavaConstant value, Class<?> receiverClass)
HotSpotConstantReflectionProvider
final
instance field is considered constant. The
implementation in HotSpotConstantReflectionProvider
returns true if value
is
not the default value
for its kind or if
HotSpotConstantReflectionProvider.Options.TrustFinalDefaultFields
is true.isFinalInstanceFieldValueConstant
in class HotSpotConstantReflectionProvider
value
- a value read from a final
instance fieldreceiverClass
- the class
of object from which the
value
was readprotected boolean isStableInstanceFieldValueConstant(JavaConstant value, Class<? extends Object> receiverClass)
Stable
instance field is considered constant. The
implementation in HotSpotConstantReflectionProvider
returns true if value
is
not the default value
for its kind.
HotSpotVMConfig
has a lot of zero-value fields which we know are stable and want to
be considered as constants.isStableInstanceFieldValueConstant
in class HotSpotConstantReflectionProvider
value
- a value read from a Stable
fieldreceiverClass
- the class
of object from which the
value
was read