< prev index next >

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

Print this page




  55             int matchFlags, Class<?> caller, int skip, MemberName[] results);
  56 
  57     /// Field layout queries parallel to jdk.internal.misc.Unsafe:
  58     static native long objectFieldOffset(MemberName self);  // e.g., returns vmindex
  59     static native long staticFieldOffset(MemberName self);  // e.g., returns vmindex
  60     static native Object staticFieldBase(MemberName self);  // e.g., returns clazz
  61     static native Object getMemberVMInfo(MemberName self);  // returns {vmindex,vmtarget}
  62 
  63     /// CallSite support
  64 
  65     /** Tell the JVM that we need to change the target of a CallSite. */
  66     static native void setCallSiteTargetNormal(CallSite site, MethodHandle target);
  67     static native void setCallSiteTargetVolatile(CallSite site, MethodHandle target);
  68 
  69     static native void copyOutBootstrapArguments(Class<?> caller, int[] indexInfo,
  70                                                  int start, int end,
  71                                                  Object[] buf, int pos,
  72                                                  boolean resolve,
  73                                                  Object ifNotAvailable);
  74 



  75     /** Represents a context to track nmethod dependencies on CallSite instance target. */
  76     static class CallSiteContext implements Runnable {
  77         //@Injected JVM_nmethodBucket* vmdependencies;
  78         //@Injected jlong last_cleanup;
  79 
  80         static CallSiteContext make(CallSite cs) {
  81             final CallSiteContext newContext = new CallSiteContext();
  82             // CallSite instance is tracked by a Cleanable which clears native
  83             // structures allocated for CallSite context. Though the CallSite can
  84             // become unreachable, its Context is retained by the Cleanable instance
  85             // (which is referenced from Cleaner instance which is referenced from
  86             // CleanerFactory class) until cleanup is performed.
  87             CleanerFactory.cleaner().register(cs, newContext);
  88             return newContext;
  89         }
  90 
  91         @Override
  92         public void run() {
  93             MethodHandleNatives.clearCallSiteContext(this);
  94         }


 120             MN_REFERENCE_KIND_MASK = 0x0F000000 >> MN_REFERENCE_KIND_SHIFT,
 121             // The SEARCH_* bits are not for MN.flags but for the matchFlags argument of MHN.getMembers:
 122             MN_SEARCH_SUPERCLASSES = 0x00100000,
 123             MN_SEARCH_INTERFACES   = 0x00200000;
 124 
 125         /**
 126          * Constant pool reference-kind codes, as used by CONSTANT_MethodHandle CP entries.
 127          */
 128         static final byte
 129             REF_NONE                    = 0,  // null value
 130             REF_getField                = 1,
 131             REF_getStatic               = 2,
 132             REF_putField                = 3,
 133             REF_putStatic               = 4,
 134             REF_invokeVirtual           = 5,
 135             REF_invokeStatic            = 6,
 136             REF_invokeSpecial           = 7,
 137             REF_newInvokeSpecial        = 8,
 138             REF_invokeInterface         = 9,
 139             REF_LIMIT                  = 10;









 140     }
 141 
 142     static boolean refKindIsValid(int refKind) {
 143         return (refKind > REF_NONE && refKind < REF_LIMIT);
 144     }
 145     static boolean refKindIsField(byte refKind) {
 146         assert(refKindIsValid(refKind));
 147         return (refKind <= REF_putStatic);
 148     }
 149     static boolean refKindIsGetter(byte refKind) {
 150         assert(refKindIsValid(refKind));
 151         return (refKind <= REF_getStatic);
 152     }
 153     static boolean refKindIsSetter(byte refKind) {
 154         return refKindIsField(refKind) && !refKindIsGetter(refKind);
 155     }
 156     static boolean refKindIsMethod(byte refKind) {
 157         return !refKindIsField(refKind) && (refKind != REF_newInvokeSpecial);
 158     }
 159     static boolean refKindIsConstructor(byte refKind) {




  55             int matchFlags, Class<?> caller, int skip, MemberName[] results);
  56 
  57     /// Field layout queries parallel to jdk.internal.misc.Unsafe:
  58     static native long objectFieldOffset(MemberName self);  // e.g., returns vmindex
  59     static native long staticFieldOffset(MemberName self);  // e.g., returns vmindex
  60     static native Object staticFieldBase(MemberName self);  // e.g., returns clazz
  61     static native Object getMemberVMInfo(MemberName self);  // returns {vmindex,vmtarget}
  62 
  63     /// CallSite support
  64 
  65     /** Tell the JVM that we need to change the target of a CallSite. */
  66     static native void setCallSiteTargetNormal(CallSite site, MethodHandle target);
  67     static native void setCallSiteTargetVolatile(CallSite site, MethodHandle target);
  68 
  69     static native void copyOutBootstrapArguments(Class<?> caller, int[] indexInfo,
  70                                                  int start, int end,
  71                                                  Object[] buf, int pos,
  72                                                  boolean resolve,
  73                                                  Object ifNotAvailable);
  74 
  75     /// ClassData support
  76     static native Object classData(Class<?> lookupClass);
  77 
  78     /** Represents a context to track nmethod dependencies on CallSite instance target. */
  79     static class CallSiteContext implements Runnable {
  80         //@Injected JVM_nmethodBucket* vmdependencies;
  81         //@Injected jlong last_cleanup;
  82 
  83         static CallSiteContext make(CallSite cs) {
  84             final CallSiteContext newContext = new CallSiteContext();
  85             // CallSite instance is tracked by a Cleanable which clears native
  86             // structures allocated for CallSite context. Though the CallSite can
  87             // become unreachable, its Context is retained by the Cleanable instance
  88             // (which is referenced from Cleaner instance which is referenced from
  89             // CleanerFactory class) until cleanup is performed.
  90             CleanerFactory.cleaner().register(cs, newContext);
  91             return newContext;
  92         }
  93 
  94         @Override
  95         public void run() {
  96             MethodHandleNatives.clearCallSiteContext(this);
  97         }


 123             MN_REFERENCE_KIND_MASK = 0x0F000000 >> MN_REFERENCE_KIND_SHIFT,
 124             // The SEARCH_* bits are not for MN.flags but for the matchFlags argument of MHN.getMembers:
 125             MN_SEARCH_SUPERCLASSES = 0x00100000,
 126             MN_SEARCH_INTERFACES   = 0x00200000;
 127 
 128         /**
 129          * Constant pool reference-kind codes, as used by CONSTANT_MethodHandle CP entries.
 130          */
 131         static final byte
 132             REF_NONE                    = 0,  // null value
 133             REF_getField                = 1,
 134             REF_getStatic               = 2,
 135             REF_putField                = 3,
 136             REF_putStatic               = 4,
 137             REF_invokeVirtual           = 5,
 138             REF_invokeStatic            = 6,
 139             REF_invokeSpecial           = 7,
 140             REF_newInvokeSpecial        = 8,
 141             REF_invokeInterface         = 9,
 142             REF_LIMIT                  = 10;
 143 
 144         /**
 145          * Flags for Lookup.ClassProperty
 146          */
 147         static final int
 148             NESTMATE_CLASS            = 0x00000001,
 149             NONFINDABLE_CLASS         = 0x00000002,
 150             WEAK_CLASS                = 0x00000004,
 151             ACCESS_VM_ANNOTATIONS     = 0x00100000;
 152     }
 153 
 154     static boolean refKindIsValid(int refKind) {
 155         return (refKind > REF_NONE && refKind < REF_LIMIT);
 156     }
 157     static boolean refKindIsField(byte refKind) {
 158         assert(refKindIsValid(refKind));
 159         return (refKind <= REF_putStatic);
 160     }
 161     static boolean refKindIsGetter(byte refKind) {
 162         assert(refKindIsValid(refKind));
 163         return (refKind <= REF_getStatic);
 164     }
 165     static boolean refKindIsSetter(byte refKind) {
 166         return refKindIsField(refKind) && !refKindIsGetter(refKind);
 167     }
 168     static boolean refKindIsMethod(byte refKind) {
 169         return !refKindIsField(refKind) && (refKind != REF_newInvokeSpecial);
 170     }
 171     static boolean refKindIsConstructor(byte refKind) {


< prev index next >