changeset 4574:b5074ea960b9

7085860: JSR 292: implement CallSite.setTargetNormal and setTargetVolatile as native methods Reviewed-by: jrose, never
author twisti
date Mon, 16 Jan 2012 01:47:42 -0800
parents 6e94688e622d
children 40037f37550d
files src/share/classes/java/lang/invoke/CallSite.java src/share/classes/java/lang/invoke/MethodHandleNatives.java
diffstat 2 files changed, 8 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/lang/invoke/CallSite.java	Fri Jan 13 12:46:37 2012 +0800
+++ b/src/share/classes/java/lang/invoke/CallSite.java	Mon Jan 16 01:47:42 2012 -0800
@@ -267,7 +267,7 @@
 
     /*package-private*/
     void setTargetNormal(MethodHandle newTarget) {
-        target = newTarget;
+        MethodHandleNatives.setCallSiteTargetNormal(this, newTarget);
     }
     /*package-private*/
     MethodHandle getTargetVolatile() {
@@ -275,7 +275,7 @@
     }
     /*package-private*/
     void setTargetVolatile(MethodHandle newTarget) {
-        unsafe.putObjectVolatile(this, TARGET_OFFSET, newTarget);
+        MethodHandleNatives.setCallSiteTargetVolatile(this, newTarget);
     }
 
     // this implements the upcall from the JVM, MethodHandleNatives.makeDynamicCallSite:
--- a/src/share/classes/java/lang/invoke/MethodHandleNatives.java	Fri Jan 13 12:46:37 2012 +0800
+++ b/src/share/classes/java/lang/invoke/MethodHandleNatives.java	Mon Jan 16 01:47:42 2012 -0800
@@ -61,15 +61,6 @@
     /** Initialize a method type, once per form. */
     static native void init(MethodType self);
 
-    /** Tell the JVM about a class's bootstrap method. */
-    static native void registerBootstrap(Class<?> caller, MethodHandle bootstrapMethod);
-
-    /** Ask the JVM about a class's bootstrap method. */
-    static native MethodHandle getBootstrap(Class<?> caller);
-
-    /** Tell the JVM that we need to change the target of an invokedynamic. */
-    static native void setCallSiteTarget(CallSite site, MethodHandle target);
-
     /** Fetch the vmtarget field.
      *  It will be sanitized as necessary to avoid exposing non-Java references.
      *  This routine is for debugging and reflection.
@@ -122,6 +113,12 @@
 
     static final boolean COUNT_GWT;
 
+    /// CallSite support
+
+    /** Tell the JVM that we need to change the target of a CallSite. */
+    static native void setCallSiteTargetNormal(CallSite site, MethodHandle target);
+    static native void setCallSiteTargetVolatile(CallSite site, MethodHandle target);
+
     private static native void registerNatives();
     static {
         registerNatives();