8022853: add ability to load uncompressed object and Klass references in a compressed environment to Unsafe
authortwisti
Mon, 27 Apr 2015 09:02:48 -0700
changeset 30361 76bb3472a9dd
parent 30360 c34ae192d75f
child 30364 429945d7189c
child 30659 f7d610c0c95d
8022853: add ability to load uncompressed object and Klass references in a compressed environment to Unsafe Reviewed-by: coleenp, jrose, kvn
jdk/src/java.base/share/classes/sun/misc/Unsafe.java
--- a/jdk/src/java.base/share/classes/sun/misc/Unsafe.java	Mon Apr 27 10:13:21 2015 +0200
+++ b/jdk/src/java.base/share/classes/sun/misc/Unsafe.java	Mon Apr 27 09:02:48 2015 -0700
@@ -183,7 +183,7 @@
      * <p>
      * Unless the reference {@code x} being stored is either null
      * or matches the field type, the results are undefined.
-     * If the reference {@code o} is non-null, car marks or
+     * If the reference {@code o} is non-null, card marks or
      * other store barriers for that object (if the VM requires them)
      * are updated.
      * @see #putInt(Object, long, int)
@@ -219,6 +219,35 @@
     /** @see #putInt(Object, long, int) */
     public native void    putDouble(Object o, long offset, double x);
 
+    // These read VM internal data.
+
+    /**
+     * Fetches an uncompressed reference value from a given native variable
+     * ignoring the VM's compressed references mode.
+     *
+     * @param address a memory address locating the variable
+     * @return the value fetched from the indicated native variable
+     */
+    public native Object getUncompressedObject(long address);
+
+    /**
+     * Fetches the {@link java.lang.Class} Java mirror for the given native
+     * metaspace {@code Klass} pointer.
+     *
+     * @param metaspaceKlass a native metaspace {@code Klass} pointer
+     * @return the {@link java.lang.Class} Java mirror
+     */
+    public native Class<?> getJavaMirror(long metaspaceKlass);
+
+    /**
+     * Fetches a native metaspace {@code Klass} pointer for the given Java
+     * object.
+     *
+     * @param o Java heap object for which to fetch the class pointer
+     * @return a native metaspace {@code Klass} pointer
+     */
+    public native long getKlassPointer(Object o);
+
     // These work on values in the C heap.
 
     /**