< prev index next >
src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/CompilerToVM.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -21,10 +21,11 @@
* questions.
*/
package jdk.vm.ci.hotspot;
+import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime;
import static jdk.vm.ci.inittimer.InitTimer.timer;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
@@ -34,19 +35,18 @@
import jdk.vm.ci.hotspotvmconfig.HotSpotVMField;
import jdk.vm.ci.inittimer.InitTimer;
import jdk.vm.ci.meta.JavaType;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import jdk.vm.ci.meta.ResolvedJavaType;
-import jdk.vm.ci.meta.SpeculationLog;
import sun.misc.Unsafe;
/**
* Calls from Java into HotSpot. The behavior of all the methods in this class that take a native
* pointer as an argument (e.g., {@link #getSymbol(long)}) is undefined if the argument does not
* denote a valid native object.
*/
-public final class CompilerToVM {
+final class CompilerToVM {
/**
* Initializes the native part of the JVMCI runtime.
*/
private static native void registerNatives();
@@ -60,10 +60,18 @@
registerNatives();
}
}
/**
+ * Gets the {@link CompilerToVM} instance associated with the singleton
+ * {@link HotSpotJVMCIRuntime} instance.
+ */
+ public static CompilerToVM compilerToVM() {
+ return runtime().getCompilerToVM();
+ }
+
+ /**
* Copies the original bytecode of {@code method} into a new byte array and returns it.
*
* @return a new byte array containing the original bytecode of {@code method}
*/
native byte[] getBytecode(HotSpotResolvedJavaMethodImpl method);
@@ -299,11 +307,11 @@
* {@link HotSpotVMConfig#codeInstallResultCacheFull},
* {@link HotSpotVMConfig#codeInstallResultCodeTooLarge},
* {@link HotSpotVMConfig#codeInstallResultDependenciesFailed} or
* {@link HotSpotVMConfig#codeInstallResultDependenciesInvalid}.
*/
- public native int installCode(TargetDescription target, HotSpotCompiledCode compiledCode, InstalledCode code, SpeculationLog speculationLog);
+ native int installCode(TargetDescription target, HotSpotCompiledCode compiledCode, InstalledCode code, HotSpotSpeculationLog speculationLog);
public native int getMetadata(TargetDescription target, HotSpotCompiledCode compiledCode, HotSpotMetaData metaData);
/**
* Notifies the VM of statistics for a completed compilation.
@@ -315,22 +323,22 @@
* the bytecodes of all inlined methods
* @param time the amount time spent compiling {@code method}
* @param timeUnitsPerSecond the granularity of the units for the {@code time} value
* @param installedCode the nmethod installed as a result of the compilation
*/
- public synchronized native void notifyCompilationStatistics(int id, HotSpotResolvedJavaMethodImpl method, boolean osr, int processedBytecodes, long time, long timeUnitsPerSecond,
+ synchronized native void notifyCompilationStatistics(int id, HotSpotResolvedJavaMethodImpl method, boolean osr, int processedBytecodes, long time, long timeUnitsPerSecond,
InstalledCode installedCode);
/**
* Resets all compilation statistics.
*/
- public native void resetCompilationStatistics();
+ native void resetCompilationStatistics();
/**
* Initializes the fields of {@code config}.
*/
- native long initializeConfiguration();
+ native long initializeConfiguration(HotSpotVMConfig config);
/**
* Resolves the implementation of {@code method} for virtual dispatches on objects of dynamic
* type {@code exactReceiver}. This resolution process only searches "up" the class hierarchy of
* {@code exactReceiver}.
@@ -365,20 +373,20 @@
* in the code cache.
*
* @param address an address that may be called from any code in the code cache
* @return -1 if {@code address == 0}
*/
- public native long getMaxCallTargetOffset(long address);
+ native long getMaxCallTargetOffset(long address);
/**
* Gets a textual disassembly of {@code codeBlob}.
*
* @return a non-zero length string containing a disassembly of {@code codeBlob} or null if
* {@code codeBlob} could not be disassembled for some reason
*/
// The HotSpot disassembler seems not to be thread safe so it's better to synchronize its usage
- public synchronized native String disassembleCodeBlob(long codeBlob);
+ synchronized native String disassembleCodeBlob(InstalledCode installedCode);
/**
* Gets a stack trace element for {@code method} at bytecode index {@code bci}.
*/
native StackTraceElement getStackTraceElement(HotSpotResolvedJavaMethodImpl method, int bci);
@@ -452,16 +460,16 @@
/**
* Invalidates {@code installedCode} such that {@link InvalidInstalledCodeException} will be
* raised the next time {@code installedCode} is executed.
*/
- public native void invalidateInstalledCode(InstalledCode installedCode);
+ native void invalidateInstalledCode(InstalledCode installedCode);
/**
* Collects the current values of all JVMCI benchmark counters, summed up over all threads.
*/
- public native long[] collectCounters();
+ native long[] collectCounters();
/**
* Determines if {@code metaspaceMethodData} is mature.
*/
native boolean isMature(long metaspaceMethodData);
@@ -487,11 +495,11 @@
*
* @param frame the starting point of the search, where {@code null} refers to the topmost frame
* @param methods the methods to look for, where {@code null} means that any frame is returned
* @return the frame, or {@code null} if the end of the stack was reached during the search
*/
- public native HotSpotStackFrameReference getNextStackFrame(HotSpotStackFrameReference frame, HotSpotResolvedJavaMethodImpl[] methods, int initialSkip);
+ native HotSpotStackFrameReference getNextStackFrame(HotSpotStackFrameReference frame, ResolvedJavaMethod[] methods, int initialSkip);
/**
* Materializes all virtual objects within {@code stackFrame} updates its locals.
*
* @param invalidate if {@code true}, the compiled method for the stack frame will be
@@ -510,65 +518,87 @@
native int getVtableIndexForInterfaceMethod(HotSpotResolvedObjectTypeImpl type, HotSpotResolvedJavaMethodImpl method);
/**
* Determines if debug info should also be emitted at non-safepoint locations.
*/
- public native boolean shouldDebugNonSafepoints();
+
+ native boolean shouldDebugNonSafepoints();
/**
* Writes {@code length} bytes from {@code bytes} starting at offset {@code offset} to the
* HotSpot's log stream.
*
- * @exception NullPointerException if <code>bytes</code> is <code>null</code>.
+ * @exception NullPointerException if {@code bytes == null}
* @exception IndexOutOfBoundsException if copying would cause access of data outside array
- * bounds.
+ * bounds
*/
- public native void writeDebugOutput(byte[] bytes, int offset, int length);
+ native void writeDebugOutput(byte[] bytes, int offset, int length);
/**
* Flush HotSpot's log stream.
*/
- public native void flushDebugOutput();
+ native void flushDebugOutput();
/**
- * Read a value representing a metaspace Method* and return the
- * {@link HotSpotResolvedJavaMethodImpl} wrapping it. This method does no checking that the
- * location actually contains a valid Method*. If the {@code base} object is a
+ * Read a HotSpot Method* value from the memory location described by {@code base} plus
+ * {@code displacement} and return the {@link HotSpotResolvedJavaMethodImpl} wrapping it. This
+ * method does no checking that the memory location actually contains a valid pointer and may
+ * crash the VM if an invalid location is provided. If the {@code base} is null then
+ * {@code displacement} is used by itself. If {@code base} is a
* {@link HotSpotResolvedJavaMethodImpl}, {@link HotSpotConstantPool} or
* {@link HotSpotResolvedObjectTypeImpl} then the metaspace pointer is fetched from that object
- * and used as the base. Otherwise the object itself is used as the base.
+ * and added to {@code displacement}. Any other non-null object type causes an
+ * {@link IllegalArgumentException} to be thrown.
*
* @param base an object to read from or null
* @param displacement
* @return null or the resolved method for this location
*/
native HotSpotResolvedJavaMethodImpl getResolvedJavaMethod(Object base, long displacement);
/**
- * Read a value representing a metaspace ConstantPool* and return the
- * {@link HotSpotConstantPool} wrapping it. This method does no checking that the location
- * actually contains a valid ConstantPool*. If the {@code base} object is a
- * {@link HotSpotResolvedJavaMethodImpl}, {@link HotSpotConstantPool} or
- * {@link HotSpotResolvedObjectTypeImpl} then the metaspace pointer is fetched from that object
- * and used as the base. Otherwise the object itself is used as the base.
+ * Read a HotSpot ConstantPool* value from the memory location described by {@code base} plus
+ * {@code displacement} and return the {@link HotSpotConstantPool} wrapping it. This method does
+ * no checking that the memory location actually contains a valid pointer and may crash the VM
+ * if an invalid location is provided. If the {@code base} is null then {@code displacement} is
+ * used by itself. If {@code base} is a {@link HotSpotResolvedJavaMethodImpl},
+ * {@link HotSpotConstantPool} or {@link HotSpotResolvedObjectTypeImpl} then the metaspace
+ * pointer is fetched from that object and added to {@code displacement}. Any other non-null
+ * object type causes an {@link IllegalArgumentException} to be thrown.
*
* @param base an object to read from or null
* @param displacement
* @return null or the resolved method for this location
*/
native HotSpotConstantPool getConstantPool(Object base, long displacement);
/**
- * Read a value representing a metaspace Klass* and return the
- * {@link HotSpotResolvedObjectTypeImpl} wrapping it. The method does no checking that the
- * location actually contains a valid Klass*. If the {@code base} object is a
+ * Read a HotSpot Klass* value from the memory location described by {@code base} plus
+ * {@code displacement} and return the {@link HotSpotResolvedObjectTypeImpl} wrapping it. This
+ * method does no checking that the memory location actually contains a valid pointer and may
+ * crash the VM if an invalid location is provided. If the {@code base} is null then
+ * {@code displacement} is used by itself. If {@code base} is a
* {@link HotSpotResolvedJavaMethodImpl}, {@link HotSpotConstantPool} or
* {@link HotSpotResolvedObjectTypeImpl} then the metaspace pointer is fetched from that object
- * and used as the base. Otherwise the object itself is used as the base.
+ * and added to {@code displacement}. Any other non-null object type causes an
+ * {@link IllegalArgumentException} to be thrown.
*
* @param base an object to read from or null
* @param displacement
* @param compressed true if the location contains a compressed Klass*
* @return null or the resolved method for this location
*/
native HotSpotResolvedObjectTypeImpl getResolvedJavaType(Object base, long displacement, boolean compressed);
+
+ /**
+ * Return the size of the HotSpot ProfileData* pointed at by {@code position}. If
+ * {@code position} is outside the space of the MethodData then an
+ * {@link IllegalArgumentException} is thrown. A {@code position} inside the MethodData but that
+ * isn't pointing at a valid ProfileData will crash the VM.
+ *
+ * @param metaspaceMethodData
+ * @param position
+ * @return the size of the ProfileData item pointed at by {@code position}
+ * @throws IllegalArgumentException if an out of range position is given
+ */
+ native int methodDataProfileDataSize(long metaspaceMethodData, int position);
}
< prev index next >