@Retention(value=RUNTIME) @Target(value={METHOD,CONSTRUCTOR}) public @interface Uninterruptible
For example, a method that allocates raw memory must not contain a safepoint at least until it has installed a DynamicHub on the memory and made sure that all the object references indicated by that DynamicHub are valid object references.
Methods annotated with Uninterruptible
can only call
Uninterruptible
.Fold
.KnownIntrinsics
.WordBase
.
Annotated methods give a terse Uninterruptible.reason()
why they are annotated. Often the reason is that
the method is called from some other method annotated with Uninterruptible
.
Annotated methods usually say that methods they call must be annotated with
Uninterruptible
, though they can use "calleeMustBe = false"
to
indicate that the callee need not be so annotated. I use that to avoid having to annotate the
whole stack printing mechanism when I am about to exit the virtual machine.
Annotated methods can use "callerMustBe = true"
to indicate that their
caller must also be annotated with Uninterruptible
. I use that, for example when a method
allocates uninitialized storage and returns a Pointer to it. Such a method must only be called
from a method annotated with Uninterruptible
.
Most methods annotated with Uninterruptible
can not be inlined into interruptible code,
because their operations might be intermingled into code that can cause safepoints. If a method
is so simple that it can always be inlined into interruptible code, the method can be annotated
with "mayBeInlined = true"
. Uninterruptible methods can always be inlined
into other uninterruptible methods.
Modifier and Type | Required Element and Description |
---|---|
String |
reason
Documents the reason why the annotated code must not be interruptible.
|
Modifier and Type | Optional Element and Description |
---|---|
boolean |
calleeMustBe
When true, the callee of the method must be annotated with
Uninterruptible too,
because if this method is uninterruptible it should not call methods that are interruptible. |
boolean |
callerMustBe
When true, the caller of the method must be annotated with
Uninterruptible too,
because the method returns a value that is unsafe to use in an interruptible method. |
boolean |
mayBeInlined
When true, this method may be inlined into interruptible code.
|
public abstract String reason
public abstract boolean callerMustBe
Uninterruptible
too,
because the method returns a value that is unsafe to use in an interruptible method.public abstract boolean calleeMustBe
Uninterruptible
too,
because if this method is uninterruptible it should not call methods that are interruptible.public abstract boolean mayBeInlined
NeverInline
.
The concern is that if an uninterruptible method is inlined, interruptible code such as allocation could be hoisted between the operations of the uninterruptible code. Simple uninterruptible methods like field accesses can be annotated to allow them to be inlined.