Top Description Inners Fields Constructors Methods
jdk.vm.ci.hotspot

public Class HotSpotSpeculationLog

extends Object
implements SpeculationLog
Class Inheritance
All Implemented Interfaces
jdk.vm.ci.meta.SpeculationLog
Known Direct Subclasses
jdk.vm.ci.hotspot.SharedHotSpotSpeculationLog
Static Imports
jdk.vm.ci.hotspot.CompilerToVM.compilerToVM

Implements a SpeculationLog that can be used to: The choice of constructor determines whether the native failed speculations list is managed by a HotSpotSpeculationLog object.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
private static class
HotSpotSpeculationLog.LogCleaner

Frees the native memory resources associated with HotSpotSpeculationLogs once they become reclaimable.

Field Summary

Modifier and TypeField and Description
private byte[][]
failedSpeculations

The list of failed speculations read from native memory via CompilerToVM#getFailedSpeculations.

private long
failedSpeculationsAddress

Address of a pointer to a set of failed speculations.

private final boolean
private static final byte[]
private List<SpeculationLog.SpeculationReason>
private List<byte[]>
speculations

Speculations made during the compilation associated with this log.

Constructor Summary

AccessConstructor and Description
public
HotSpotSpeculationLog()

Creates a speculation log that manages a failed speculation list.

public
HotSpotSpeculationLog(long
an address in native memory at which the pointer to the externally managed sailed speculation list resides
failedSpeculationsAddress
)

Creates a speculation log that reads from an externally managed failed speculation list.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

false if the speculation could not be appended to the list
addFailedSpeculation
(SpeculationLog.Speculation speculation)

Adds speculation to the native list of failed speculations.

public void
collectFailedSpeculations()

Implements jdk.vm.ci.meta.SpeculationLog.collectFailedSpeculations.

Updates the set of failed speculations recorded in this log.

private static boolean

Returns:

true if needle is in haystack[fromIndex..haystack.length-1]
contains
(byte[][] haystack, int fromIndex, byte[] needle)

private static int
decodeIndex(long indexAndLength)

private static int
decodeLength(long indexAndLength)

private static byte[]
private static long
encodeIndexAndLength(int index, int length)

public long
getFailedSpeculationsAddress()

Gets the address of the pointer to the native failed speculations list.

pack-priv byte[]
getFlattenedSpeculations(boolean validate)

public boolean
hasSpeculations()

Implements jdk.vm.ci.meta.SpeculationLog.hasSpeculations.

Returns if this log has speculations.

public SpeculationLog.Speculation
public boolean
managesFailedSpeculations()

Returns true if the value returned by getFailedSpeculationsAddress() is only valid only as long as this object is alive, false otherwise.

public boolean

Returns:

true if the given speculation can be performed, i.e., it never failed so far, otherwise return false. Note, that this method returns consistent results for any given speculation for the entire lifetime of the enclosing SpeculationLog object. This means that speculations failed during a compilation will not be updated.
maySpeculate
(SpeculationLog.SpeculationReason reason)

Implements jdk.vm.ci.meta.SpeculationLog.maySpeculate.

If this method returns true, the compiler is allowed to speculate with the given reason.

public SpeculationLog.Speculation
speculate(SpeculationLog.SpeculationReason
an object representing the reason for the speculation
reason
)

Implements jdk.vm.ci.meta.SpeculationLog.speculate.

Registers a speculation performed by the compiler.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

failedSpeculationsback to summary
private byte[][] failedSpeculations

The list of failed speculations read from native memory via CompilerToVM#getFailedSpeculations.

failedSpeculationsAddressback to summary
private long failedSpeculationsAddress

Address of a pointer to a set of failed speculations. The address is recorded in the nmethod compiled with this speculation log such that when it fails a speculation, the speculation is added to the list.

managesFailedSpeculationsback to summary
private final boolean managesFailedSpeculations
NO_FLATTENED_SPECULATIONSback to summary
private static final byte[] NO_FLATTENED_SPECULATIONS
speculationReasonsback to summary
private List<SpeculationLog.SpeculationReason> speculationReasons
speculationsback to summary
private List<byte[]> speculations

Speculations made during the compilation associated with this log.

Constructor Detail

HotSpotSpeculationLogback to summary
public HotSpotSpeculationLog()

Creates a speculation log that manages a failed speculation list. That is, when this object dies, the native resources of the list are freed.

See Also
managesFailedSpeculations(), getFailedSpeculationsAddress()
HotSpotSpeculationLogback to summary
public HotSpotSpeculationLog(long failedSpeculationsAddress)

Creates a speculation log that reads from an externally managed failed speculation list. That is, the lifetime of the list is independent of this object.

Parameters
failedSpeculationsAddress:long

an address in native memory at which the pointer to the externally managed sailed speculation list resides

Method Detail

addFailedSpeculationback to summary
public boolean addFailedSpeculation(SpeculationLog.Speculation speculation)

Adds speculation to the native list of failed speculations. To update this object's view of the failed speculations, collectFailedSpeculations() must be called after this method returns. This method exists primarily for testing purposes. Speculations are normally only added to the list by HotSpot during deoptimization.

Returns:boolean

false if the speculation could not be appended to the list

collectFailedSpeculationsback to summary
public void collectFailedSpeculations()

Implements jdk.vm.ci.meta.SpeculationLog.collectFailedSpeculations.

Doc from jdk.vm.ci.meta.SpeculationLog.collectFailedSpeculations.

Updates the set of failed speculations recorded in this log. This must be called before compilation.

Annotations
@Override
containsback to summary
private static boolean contains(byte[][] haystack, int fromIndex, byte[] needle)
Returns:boolean

true if needle is in haystack[fromIndex..haystack.length-1]

decodeIndexback to summary
private static int decodeIndex(long indexAndLength)
decodeLengthback to summary
private static int decodeLength(long indexAndLength)
encodeback to summary
private static byte[] encode(SpeculationLog.SpeculationReason reason)
encodeIndexAndLengthback to summary
private static long encodeIndexAndLength(int index, int length)
getFailedSpeculationsAddressback to summary
public long getFailedSpeculationsAddress()

Gets the address of the pointer to the native failed speculations list.

See Also
managesFailedSpeculations()
getFlattenedSpeculationsback to summary
pack-priv byte[] getFlattenedSpeculations(boolean validate)
hasSpeculationsback to summary
public boolean hasSpeculations()

Implements jdk.vm.ci.meta.SpeculationLog.hasSpeculations.

Doc from jdk.vm.ci.meta.SpeculationLog.hasSpeculations.

Returns if this log has speculations.

Returns:boolean

true if there are speculations, false otherwise

Annotations
@Override
lookupSpeculationback to summary
public SpeculationLog.Speculation lookupSpeculation(JavaConstant constant)

Implements jdk.vm.ci.meta.SpeculationLog.lookupSpeculation.

Doc from jdk.vm.ci.meta.SpeculationLog.lookupSpeculation.

Given a JavaConstant previously returned from MetaAccessProvider#encodeSpeculation(Speculation) return the original Speculation object.

Annotations
@Override
managesFailedSpeculationsback to summary
public boolean managesFailedSpeculations()

Returns true if the value returned by getFailedSpeculationsAddress() is only valid only as long as this object is alive, false otherwise.

maySpeculateback to summary
public boolean maySpeculate(SpeculationLog.SpeculationReason reason)

Implements jdk.vm.ci.meta.SpeculationLog.maySpeculate.

Doc from jdk.vm.ci.meta.SpeculationLog.maySpeculate.

If this method returns true, the compiler is allowed to speculate with the given reason.

Returns:boolean

true if the given speculation can be performed, i.e., it never failed so far, otherwise return false. Note, that this method returns consistent results for any given speculation for the entire lifetime of the enclosing SpeculationLog object. This means that speculations failed during a compilation will not be updated.

Annotations
@Override
speculateback to summary
public SpeculationLog.Speculation speculate(SpeculationLog.SpeculationReason reason)

Implements jdk.vm.ci.meta.SpeculationLog.speculate.

Doc from jdk.vm.ci.meta.SpeculationLog.speculate.

Registers a speculation performed by the compiler. The compiler must guard every call to this method for a specific reason with a call to maySpeculate(SpeculationReason). This API is subject to a benign race where a during the course of a compilation another thread might fail a speculation such that maySpeculate(SpeculationReason) will return false but an earlier call returned true. This method will still return a working Speculation in that case but the compile will eventually be invalidated and the compile attempted again without the now invalid speculation.

Parameters
reason:SpeculationLog.SpeculationReason

an object representing the reason for the speculation

Returns:SpeculationLog.Speculation

a compiler constant encapsulating the provided reason. It is usually passed as an argument to the deoptimization function.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
jdk.vm.ci.hotspot back to summary

public final Class HotSpotSpeculationLog.HotSpotSpeculation

extends Speculation
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final byte[]
private final JavaConstant
id

A speculation id is a long encoding a length (low 5 bits) and an index into a byte[].

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public JavaConstant
public String
toString()

Overrides jdk.vm.ci.meta.SpeculationLog.Speculation.toString.

Returns a string representation of the object.

Inherited from jdk.vm.ci.meta.SpeculationLog.Speculation:
equalsgetReasonhashCode

Field Detail

encodingback to summary
private final byte[] encoding
idback to summary
private final JavaConstant id

A speculation id is a long encoding a length (low 5 bits) and an index into a byte[]. Combined, the index and length denote where the encoded speculation is in a flattened speculations array.

Constructor Detail

HotSpotSpeculationback to summary
pack-priv HotSpotSpeculation(SpeculationLog.SpeculationReason reason, JavaConstant id, byte[] encoding)

Method Detail

getEncodingback to summary
public JavaConstant getEncoding()
toStringback to summary
public String toString()

Overrides jdk.vm.ci.meta.SpeculationLog.Speculation.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
jdk.vm.ci.hotspot back to summary

private final Class HotSpotSpeculationLog.LogCleaner

extends Cleaner
Class Inheritance

Frees the native memory resources associated with HotSpotSpeculationLogs once they become reclaimable.

Field Summary

Modifier and TypeField and Description
pack-priv final long

Constructor Summary

AccessConstructor and Description
pack-priv
LogCleaner(HotSpotSpeculationLog referent, long address)

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
doCleanup()

Implements abstract jdk.vm.ci.hotspot.Cleaner.doCleanup.

Performs the cleanup action now that this object's referent has become weakly reachable.

Inherited from jdk.vm.ci.hotspot.Cleaner:
clean

Field Detail

addressback to summary
pack-priv final long address

Constructor Detail

LogCleanerback to summary
pack-priv LogCleaner(HotSpotSpeculationLog referent, long address)

Method Detail

doCleanupback to summary
pack-priv boolean doCleanup()

Implements abstract jdk.vm.ci.hotspot.Cleaner.doCleanup.

Doc from jdk.vm.ci.hotspot.Cleaner.doCleanup.

Performs the cleanup action now that this object's referent has become weakly reachable.

Returns:boolean

true if the clean up action cleared the referent of an oop handle and requires a subsequent call to CompilerToVM#releaseClearedOopHandles() to reclaim the resources of the handle itself

Annotations
@Override