public final class GraalServices extends Object
| Modifier and Type | Method and Description |
|---|---|
static VirtualObject |
createVirtualObject(ResolvedJavaType type,
int id,
boolean isAutoBox)
Creates a new
VirtualObject based on a given existing object, with the given
contents. |
static double |
fma(double a,
double b,
double c)
Returns the fused multiply add of the three arguments; that is, returns the exact product of
the first two arguments summed with the third argument and then rounded once to the nearest
double. |
static float |
fma(float a,
float b,
float c)
Returns the fused multiply add of the three arguments; that is, returns the exact product of
the first two arguments summed with the third argument and then rounded once to the nearest
float. |
static Infopoint |
genImplicitException(int pcOffset,
int dispatchOffset,
DebugInfo debugInfo)
Constructs an info point for an implicit exception dispatch.
|
static InputStream |
getClassfileAsStream(Class<?> c)
Gets the class file bytes for
c. |
static long |
getCurrentThreadAllocatedBytes()
Convenience method for calling
GraalServices.getThreadAllocatedBytes(long) with the id of the
current thread. |
static long |
getCurrentThreadCpuTime()
Returns the total CPU time for the current thread in nanoseconds.
|
static String |
getExecutionID()
Gets a unique identifier for this execution such as a process ID or a
fixed timestamp.
|
static long |
getGlobalTimeStamp()
Gets a time stamp for the current process.
|
static List<String> |
getInputArguments()
Gets the input arguments passed to the Java virtual machine which does not include the
arguments to the
main method. |
static int |
getJavaUpdateVersion()
Gets the update-release counter for the current Java runtime.
|
static long |
getThreadAllocatedBytes(long id)
Returns an approximation of the total amount of memory, in bytes, allocated in heap memory
for the thread of the specified ID.
|
static boolean |
hasLookupReferencedType()
Returns true if JVMCI supports the
ConstantPool.lookupReferencedType API. |
static boolean |
isCurrentThreadCpuTimeSupported()
Determines if the Java virtual machine supports CPU time measurement for the current thread.
|
static boolean |
isThreadAllocatedMemorySupported()
Determines if the Java virtual machine implementation supports thread memory allocation
measurement.
|
static boolean |
isToStringTrusted(Class<?> c)
Determines if invoking
Object.toString() on an instance of c will only run
trusted code. |
static <S> Iterable<S> |
load(Class<S> service)
Gets an
Iterable of the providers available for a given service. |
static <S> S |
loadSingle(Class<S> service,
boolean required)
Gets the provider for a given service for which at most one provider must be available.
|
static JavaType |
lookupReferencedType(ConstantPool constantPool,
int cpi,
int opcode)
Looks up the type referenced by the constant pool entry at
cpi as referenced by the
opcode bytecode instruction. |
static boolean |
supportsArbitraryImplicitException()
Returns whether JVMCI supports arbitrary implicit exception dispatch.
|
public static <S> Iterable<S> load(Class<S> service)
Iterable of the providers available for a given service.public static <S> S loadSingle(Class<S> service, boolean required)
service - the service whose provider is being requestedrequired - specifies if an InternalError should be thrown if no provider of
service is availablenullpublic static InputStream getClassfileAsStream(Class<?> c) throws IOException
c.IOExceptionpublic static boolean isToStringTrusted(Class<?> c)
Object.toString() on an instance of c will only run
trusted code.public static String getExecutionID()
public static long getGlobalTimeStamp()
public static long getThreadAllocatedBytes(long id)
If the thread of the specified ID is not alive or does not exist, this method returns
-1. If thread memory allocation measurement is disabled, this method returns
-1. A thread is alive if it has been started and has not yet died.
If thread memory allocation measurement is enabled after the thread has started, the Java virtual machine implementation may choose any time up to and including the time that the capability is enabled as the point where thread memory allocation measurement starts.
id - the thread ID of a thread-1 otherwise.IllegalArgumentException - if id <= 0.UnsupportedOperationException - if the Java virtual machine implementation does not
support thread memory allocation
measurement.public static long getCurrentThreadAllocatedBytes()
GraalServices.getThreadAllocatedBytes(long) with the id of the
current thread.public static long getCurrentThreadCpuTime()
-1 otherwise.UnsupportedOperationException - if the Java virtual machine does not
support CPU time measurement for
the current threadpublic static boolean isThreadAllocatedMemorySupported()
public static boolean isCurrentThreadCpuTimeSupported()
public static List<String> getInputArguments()
main method. This method returns an empty list if there is no input
argument to the Java virtual machine.
Some Java virtual machine implementations may take input arguments from multiple different sources: for examples, arguments passed from the application that launches the Java virtual machine such as the 'java' command, environment variables, configuration files, etc.
Typically, not all command-line options to the 'java' command are passed to the Java virtual machine. Thus, the returned input arguments may not include all command-line options.
null if they are unavailablepublic static float fma(float a,
float b,
float c)
float.public static double fma(double a,
double b,
double c)
double.public static VirtualObject createVirtualObject(ResolvedJavaType type,
int id,
boolean isAutoBox)
VirtualObject based on a given existing object, with the given
contents. If type is an instance class then VirtualObject.getValues() provides
the values for the fields returned by getInstanceFields(true). If type is an array then the length of
VirtualObject.getValues() determines the array length.type - the type of the object whose allocation was removed during compilation. This can
be either an instance or an array type.id - a unique id that identifies the object within the debug information for one
position in the compiled code.isAutoBox - a flag that tells the runtime that the object may be a boxed primitive that
needs to be obtained from the box cache instead of creating a new instance.VirtualObject instance.public static int getJavaUpdateVersion()
Runtime.Versionpublic static JavaType lookupReferencedType(ConstantPool constantPool,
int cpi,
int opcode)
cpi as referenced by the
opcode bytecode instruction.cpi - the index of a constant pool entry that references a typeopcode - the opcode of the instruction with cpi as an operandInternalError - if GraalServices.hasLookupReferencedType() returns falsepublic static boolean hasLookupReferencedType()
ConstantPool.lookupReferencedType API.public static boolean supportsArbitraryImplicitException()
public static Infopoint genImplicitException(int pcOffset,
int dispatchOffset,
DebugInfo debugInfo)
pcOffset - the exceptional PC offsetdispatchOffset - the continuation PC offsetdebugInfo - debugging information at the exceptional PCInternalError - if GraalServices.supportsArbitraryImplicitException() returns false
and pcOffset != dispatchOffset