< prev index next >

src/java.base/share/classes/java/lang/invoke/CallSite.java

Print this page
rev 17358 : 8182487: Add Unsafe.objectFieldOffset(Class, String)
Reviewed-by: dsimms


 259     }
 260 
 261     private MethodHandle makeUninitializedCallSite(MethodType targetType) {
 262         MethodType basicType = targetType.basicType();
 263         MethodHandle invoker = basicType.form().cachedMethodHandle(MethodTypeForm.MH_UNINIT_CS);
 264         if (invoker == null) {
 265             invoker = uninitializedCallSiteHandle().asType(basicType);
 266             invoker = basicType.form().setCachedMethodHandle(MethodTypeForm.MH_UNINIT_CS, invoker);
 267         }
 268         // unchecked view is OK since no values will be received or returned
 269         return invoker.viewAsType(targetType, false);
 270     }
 271 
 272     // unsafe stuff:
 273     private static @Stable long TARGET_OFFSET;
 274     private static long getTargetOffset() {
 275         long offset = TARGET_OFFSET;
 276         if (offset > 0) {
 277             return offset;
 278         }
 279         try {
 280             offset = TARGET_OFFSET = UNSAFE.objectFieldOffset(CallSite.class.getDeclaredField("target"));
 281             assert(offset > 0);
 282             return offset;
 283         } catch (Exception ex) { throw newInternalError(ex); }
 284     }
 285 
 286     /*package-private*/
 287     void setTargetNormal(MethodHandle newTarget) {
 288         MethodHandleNatives.setCallSiteTargetNormal(this, newTarget);
 289     }
 290     /*package-private*/
 291     MethodHandle getTargetVolatile() {
 292         return (MethodHandle) UNSAFE.getObjectVolatile(this, getTargetOffset());
 293     }
 294     /*package-private*/
 295     void setTargetVolatile(MethodHandle newTarget) {
 296         MethodHandleNatives.setCallSiteTargetVolatile(this, newTarget);
 297     }
 298 
 299     // this implements the upcall from the JVM, MethodHandleNatives.linkCallSite:
 300     static CallSite makeSite(MethodHandle bootstrapMethod,
 301                              // Callee information:
 302                              String name, MethodType type,
 303                              // Extra arguments for BSM, if any:




 259     }
 260 
 261     private MethodHandle makeUninitializedCallSite(MethodType targetType) {
 262         MethodType basicType = targetType.basicType();
 263         MethodHandle invoker = basicType.form().cachedMethodHandle(MethodTypeForm.MH_UNINIT_CS);
 264         if (invoker == null) {
 265             invoker = uninitializedCallSiteHandle().asType(basicType);
 266             invoker = basicType.form().setCachedMethodHandle(MethodTypeForm.MH_UNINIT_CS, invoker);
 267         }
 268         // unchecked view is OK since no values will be received or returned
 269         return invoker.viewAsType(targetType, false);
 270     }
 271 
 272     // unsafe stuff:
 273     private static @Stable long TARGET_OFFSET;
 274     private static long getTargetOffset() {
 275         long offset = TARGET_OFFSET;
 276         if (offset > 0) {
 277             return offset;
 278         }
 279         offset = TARGET_OFFSET = UNSAFE.objectFieldOffset(CallSite.class, "target");

 280         assert(offset > 0);
 281         return offset;

 282     }
 283 
 284     /*package-private*/
 285     void setTargetNormal(MethodHandle newTarget) {
 286         MethodHandleNatives.setCallSiteTargetNormal(this, newTarget);
 287     }
 288     /*package-private*/
 289     MethodHandle getTargetVolatile() {
 290         return (MethodHandle) UNSAFE.getObjectVolatile(this, getTargetOffset());
 291     }
 292     /*package-private*/
 293     void setTargetVolatile(MethodHandle newTarget) {
 294         MethodHandleNatives.setCallSiteTargetVolatile(this, newTarget);
 295     }
 296 
 297     // this implements the upcall from the JVM, MethodHandleNatives.linkCallSite:
 298     static CallSite makeSite(MethodHandle bootstrapMethod,
 299                              // Callee information:
 300                              String name, MethodType type,
 301                              // Extra arguments for BSM, if any:


< prev index next >