Class BytecodeOSRMetadata
java.lang.Object
com.oracle.truffle.runtime.BytecodeOSRMetadata
Represents the metadata required to perform OSR compilation on Graal. An instance of this class
is stored in the metadata field of a
BytecodeOSRNode.
Performance note: We do not require the metadata field to be volatile. As long as the
field is initialized under double-checked locking (as is done in
Accessor.RuntimeSupport.pollBytecodeOSRBackEdge(BytecodeOSRNode)), all threads will observe the same
metadata instance. The JMM guarantees that the instance's final fields will be safely initialized
before it is published; the non-final + non-volatile fields (e.g., the back edge counter) may not
be, but we tolerate this inaccuracy in order to avoid volatile accesses in the hot path.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BytecodeOSRMetadatastatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionvoidForce disabling of OSR compilation for this method.intbooleanIncrement back edge count and return whether compilation should be polled.booleanincrementAndPoll(int loopCountIncrement) booleanReturns whether OSR compilation is disabled for the current unit.voidrestoreFrame(com.oracle.truffle.api.impl.FrameWithoutBoxing source, com.oracle.truffle.api.impl.FrameWithoutBoxing target) Transfer state fromsourcetotarget.voidtransferFrame(com.oracle.truffle.api.impl.FrameWithoutBoxing source, com.oracle.truffle.api.impl.FrameWithoutBoxing target, Object targetMetadata) Transfer state fromsourcetotarget.
-
Field Details
-
DISABLED
-
OSR_POLL_INTERVAL
public static final int OSR_POLL_INTERVAL- See Also:
-
OSR_POLL_SHIFT
public static final int OSR_POLL_SHIFT- See Also:
-
-
Method Details
-
incrementAndPoll
public boolean incrementAndPoll()Increment back edge count and return whether compilation should be polled.When the OSR threshold is reached, this method will return true after every OSR_POLL_INTERVAL back-edges. This method is thread-safe, but could under-count.
-
incrementAndPoll
public boolean incrementAndPoll(int loopCountIncrement) -
isDisabled
public boolean isDisabled()Returns whether OSR compilation is disabled for the current unit. -
forceDisable
public void forceDisable()Force disabling of OSR compilation for this method. Used for testing purposes. -
transferFrame
public void transferFrame(com.oracle.truffle.api.impl.FrameWithoutBoxing source, com.oracle.truffle.api.impl.FrameWithoutBoxing target, Object targetMetadata) Transfer state fromsourcetotarget. Can be used to transfer state into an OSR frame. -
restoreFrame
public void restoreFrame(com.oracle.truffle.api.impl.FrameWithoutBoxing source, com.oracle.truffle.api.impl.FrameWithoutBoxing target) Transfer state fromsourcetotarget. Can be used to transfer state from an OSR frame to a parent frame. Overall less efficient than itscounterpart, mainly due to not being able to speculate on the source tags: While entering bytecode OSR is done through specific entry points (likely back edges), returning could be done from anywhere within a method body (through regular returns, or exception thrown). While we could theoretically have the same mechanism as on entries (caching encountered return state), we could not efficiently be able to retrieve from the cache (as we do not get the equivalent of theint osrBytecodeTargetfor returns), even ignoring the potential memory cost of such a cache. Therefore, we are doing a best-effort of copying over source to target, reading from the actual frames rather than a cache: If the tag cannot be constant-folded at this point, we get a switch in compiled code. Since we are at a boundary back to interpreted code, this cost should not be too high. -
getOSRCompilations
-
getBackEdgeCount
public int getBackEdgeCount()
-