44 /// MethodName support 45 46 static native void init(MemberName self, Object ref); 47 static native void expand(MemberName self); 48 static native void resolve(MemberName self, Class<?> caller); 49 static native int getMembers(Class<?> defc, String matchName, String matchSig, 50 int matchFlags, Class<?> caller, int skip, MemberName[] results); 51 52 /// MethodHandle support 53 54 /** Initialize the method handle to adapt the call. */ 55 static native void init(AdapterMethodHandle self, MethodHandle target, int argnum); 56 /** Initialize the method handle to call the correct method, directly. */ 57 static native void init(BoundMethodHandle self, Object target, int argnum); 58 /** Initialize the method handle to call as if by an invoke* instruction. */ 59 static native void init(DirectMethodHandle self, Object ref, boolean doDispatch, Class<?> caller); 60 61 /** Initialize a method type, once per form. */ 62 static native void init(MethodType self); 63 64 /** Tell the JVM about a class's bootstrap method. */ 65 static native void registerBootstrap(Class<?> caller, MethodHandle bootstrapMethod); 66 67 /** Ask the JVM about a class's bootstrap method. */ 68 static native MethodHandle getBootstrap(Class<?> caller); 69 70 /** Tell the JVM that we need to change the target of an invokedynamic. */ 71 static native void setCallSiteTarget(CallSite site, MethodHandle target); 72 73 /** Fetch the vmtarget field. 74 * It will be sanitized as necessary to avoid exposing non-Java references. 75 * This routine is for debugging and reflection. 76 */ 77 static native Object getTarget(MethodHandle self, int format); 78 79 /** Fetch the name of the handled method, if available. 80 * This routine is for debugging and reflection. 81 */ 82 static MemberName getMethodName(MethodHandle self) { 83 return (MemberName) getTarget(self, ETF_METHOD_NAME); 84 } 85 86 /** Fetch the reflective version of the handled method, if available. 87 */ 88 static AccessibleObject getTargetMethod(MethodHandle self) { 89 return (AccessibleObject) getTarget(self, ETF_REFLECT_METHOD); 90 } 91 92 /** Fetch the target of this method handle. 105 * which=0 retrieves MethodHandlePushLimit 106 * which=1 retrieves stack slot push size (in address units) 107 */ 108 static native int getConstant(int which); 109 110 /** Java copy of MethodHandlePushLimit in range 2..255. */ 111 static final int JVM_PUSH_LIMIT; 112 /** JVM stack motion (in words) after one slot is pushed, usually -1. 113 */ 114 static final int JVM_STACK_MOVE_UNIT; 115 116 /** Which conv-ops are implemented by the JVM? */ 117 static final int CONV_OP_IMPLEMENTED_MASK; 118 /** Derived mode flag. Only false on some old JVM implementations. */ 119 static final boolean HAVE_RICOCHET_FRAMES; 120 121 static final int OP_ROT_ARGS_DOWN_LIMIT_BIAS; 122 123 static final boolean COUNT_GWT; 124 125 private static native void registerNatives(); 126 static { 127 registerNatives(); 128 int k; 129 JVM_PUSH_LIMIT = getConstant(Constants.GC_JVM_PUSH_LIMIT); 130 JVM_STACK_MOVE_UNIT = getConstant(Constants.GC_JVM_STACK_MOVE_UNIT); 131 k = getConstant(Constants.GC_CONV_OP_IMPLEMENTED_MASK); 132 CONV_OP_IMPLEMENTED_MASK = (k != 0) ? k : DEFAULT_CONV_OP_IMPLEMENTED_MASK; 133 k = getConstant(Constants.GC_OP_ROT_ARGS_DOWN_LIMIT_BIAS); 134 OP_ROT_ARGS_DOWN_LIMIT_BIAS = (k != 0) ? (byte)k : -1; 135 HAVE_RICOCHET_FRAMES = (CONV_OP_IMPLEMENTED_MASK & (1<<OP_COLLECT_ARGS)) != 0; 136 COUNT_GWT = getConstant(Constants.GC_COUNT_GWT) != 0; 137 //sun.reflect.Reflection.registerMethodsToFilter(MethodHandleImpl.class, "init"); 138 } 139 140 // All compile-time constants go here. 141 // There is an opportunity to check them against the JVM's idea of them. 142 static class Constants { 143 Constants() { } // static only 144 // MethodHandleImpl | 44 /// MethodName support 45 46 static native void init(MemberName self, Object ref); 47 static native void expand(MemberName self); 48 static native void resolve(MemberName self, Class<?> caller); 49 static native int getMembers(Class<?> defc, String matchName, String matchSig, 50 int matchFlags, Class<?> caller, int skip, MemberName[] results); 51 52 /// MethodHandle support 53 54 /** Initialize the method handle to adapt the call. */ 55 static native void init(AdapterMethodHandle self, MethodHandle target, int argnum); 56 /** Initialize the method handle to call the correct method, directly. */ 57 static native void init(BoundMethodHandle self, Object target, int argnum); 58 /** Initialize the method handle to call as if by an invoke* instruction. */ 59 static native void init(DirectMethodHandle self, Object ref, boolean doDispatch, Class<?> caller); 60 61 /** Initialize a method type, once per form. */ 62 static native void init(MethodType self); 63 64 /** Fetch the vmtarget field. 65 * It will be sanitized as necessary to avoid exposing non-Java references. 66 * This routine is for debugging and reflection. 67 */ 68 static native Object getTarget(MethodHandle self, int format); 69 70 /** Fetch the name of the handled method, if available. 71 * This routine is for debugging and reflection. 72 */ 73 static MemberName getMethodName(MethodHandle self) { 74 return (MemberName) getTarget(self, ETF_METHOD_NAME); 75 } 76 77 /** Fetch the reflective version of the handled method, if available. 78 */ 79 static AccessibleObject getTargetMethod(MethodHandle self) { 80 return (AccessibleObject) getTarget(self, ETF_REFLECT_METHOD); 81 } 82 83 /** Fetch the target of this method handle. 96 * which=0 retrieves MethodHandlePushLimit 97 * which=1 retrieves stack slot push size (in address units) 98 */ 99 static native int getConstant(int which); 100 101 /** Java copy of MethodHandlePushLimit in range 2..255. */ 102 static final int JVM_PUSH_LIMIT; 103 /** JVM stack motion (in words) after one slot is pushed, usually -1. 104 */ 105 static final int JVM_STACK_MOVE_UNIT; 106 107 /** Which conv-ops are implemented by the JVM? */ 108 static final int CONV_OP_IMPLEMENTED_MASK; 109 /** Derived mode flag. Only false on some old JVM implementations. */ 110 static final boolean HAVE_RICOCHET_FRAMES; 111 112 static final int OP_ROT_ARGS_DOWN_LIMIT_BIAS; 113 114 static final boolean COUNT_GWT; 115 116 /// CallSite support 117 118 /** Tell the JVM that we need to change the target of a CallSite. */ 119 static native void setCallSiteTargetNormal(CallSite site, MethodHandle target); 120 static native void setCallSiteTargetVolatile(CallSite site, MethodHandle target); 121 122 private static native void registerNatives(); 123 static { 124 registerNatives(); 125 int k; 126 JVM_PUSH_LIMIT = getConstant(Constants.GC_JVM_PUSH_LIMIT); 127 JVM_STACK_MOVE_UNIT = getConstant(Constants.GC_JVM_STACK_MOVE_UNIT); 128 k = getConstant(Constants.GC_CONV_OP_IMPLEMENTED_MASK); 129 CONV_OP_IMPLEMENTED_MASK = (k != 0) ? k : DEFAULT_CONV_OP_IMPLEMENTED_MASK; 130 k = getConstant(Constants.GC_OP_ROT_ARGS_DOWN_LIMIT_BIAS); 131 OP_ROT_ARGS_DOWN_LIMIT_BIAS = (k != 0) ? (byte)k : -1; 132 HAVE_RICOCHET_FRAMES = (CONV_OP_IMPLEMENTED_MASK & (1<<OP_COLLECT_ARGS)) != 0; 133 COUNT_GWT = getConstant(Constants.GC_COUNT_GWT) != 0; 134 //sun.reflect.Reflection.registerMethodsToFilter(MethodHandleImpl.class, "init"); 135 } 136 137 // All compile-time constants go here. 138 // There is an opportunity to check them against the JVM's idea of them. 139 static class Constants { 140 Constants() { } // static only 141 // MethodHandleImpl |