45
46 static native void init(MemberName self, Object ref);
47 static native void expand(MemberName self);
48 static native MemberName resolve(MemberName self, Class<?> caller) throws LinkageError;
49 static native int getMembers(Class<?> defc, String matchName, String matchSig,
50 int matchFlags, Class<?> caller, int skip, MemberName[] results);
51
52 /// Field layout queries parallel to sun.misc.Unsafe:
53 static native long objectFieldOffset(MemberName self); // e.g., returns vmindex
54 static native long staticFieldOffset(MemberName self); // e.g., returns vmindex
55 static native Object staticFieldBase(MemberName self); // e.g., returns clazz
56 static native Object getMemberVMInfo(MemberName self); // returns {vmindex,vmtarget}
57
58 /// CallSite support
59
60 /** Tell the JVM that we need to change the target of a CallSite. */
61 static native void setCallSiteTargetNormal(CallSite site, MethodHandle target);
62 static native void setCallSiteTargetVolatile(CallSite site, MethodHandle target);
63
64 /** Invalidate CallSite context: clean up dependent nmethods and reset call site context to initial state (null). */
65 static native void invalidateDependentNMethods(CallSite site);
66
67 private static native void registerNatives();
68 static {
69 registerNatives();
70
71 // The JVM calls MethodHandleNatives.<clinit>. Cascade the <clinit> calls as needed:
72 MethodHandleImpl.initStatics();
73 }
74
75 /**
76 * Compile-time constants go here. This collection exists not only for
77 * reference from clients, but also for ensuring the VM and JDK agree on the
78 * values of these constants (see {@link #verifyConstants()}).
79 */
80 static class Constants {
81 Constants() { } // static only
82
83 static final int
84 MN_IS_METHOD = 0x00010000, // method (not constructor)
85 MN_IS_CONSTRUCTOR = 0x00020000, // constructor
218 return linkCallSiteImpl(caller, bootstrapMethod, name, type,
219 staticArguments, appendixResult);
220 return linkCallSiteTracing(caller, bootstrapMethod, name, type,
221 staticArguments, appendixResult);
222 }
223 static MemberName linkCallSiteImpl(Class<?> caller,
224 MethodHandle bootstrapMethod,
225 String name, MethodType type,
226 Object staticArguments,
227 Object[] appendixResult) {
228 CallSite callSite = CallSite.makeSite(bootstrapMethod,
229 name,
230 type,
231 staticArguments,
232 caller);
233 if (callSite instanceof ConstantCallSite) {
234 appendixResult[0] = callSite.dynamicInvoker();
235 return Invokers.linkToTargetMethod(type);
236 } else {
237 appendixResult[0] = callSite;
238 callSite.initContext(caller);
239 return Invokers.linkToCallSiteMethod(type);
240 }
241 }
242 // Tracing logic:
243 static MemberName linkCallSiteTracing(Class<?> caller,
244 MethodHandle bootstrapMethod,
245 String name, MethodType type,
246 Object staticArguments,
247 Object[] appendixResult) {
248 Object bsmReference = bootstrapMethod.internalMemberName();
249 if (bsmReference == null) bsmReference = bootstrapMethod;
250 Object staticArglist = (staticArguments instanceof Object[] ?
251 java.util.Arrays.asList((Object[]) staticArguments) :
252 staticArguments);
253 System.out.println("linkCallSite "+caller.getName()+" "+
254 bsmReference+" "+
255 name+type+"/"+staticArglist);
256 try {
257 MemberName res = linkCallSiteImpl(caller, bootstrapMethod, name, type,
258 staticArguments, appendixResult);
|
45
46 static native void init(MemberName self, Object ref);
47 static native void expand(MemberName self);
48 static native MemberName resolve(MemberName self, Class<?> caller) throws LinkageError;
49 static native int getMembers(Class<?> defc, String matchName, String matchSig,
50 int matchFlags, Class<?> caller, int skip, MemberName[] results);
51
52 /// Field layout queries parallel to sun.misc.Unsafe:
53 static native long objectFieldOffset(MemberName self); // e.g., returns vmindex
54 static native long staticFieldOffset(MemberName self); // e.g., returns vmindex
55 static native Object staticFieldBase(MemberName self); // e.g., returns clazz
56 static native Object getMemberVMInfo(MemberName self); // returns {vmindex,vmtarget}
57
58 /// CallSite support
59
60 /** Tell the JVM that we need to change the target of a CallSite. */
61 static native void setCallSiteTargetNormal(CallSite site, MethodHandle target);
62 static native void setCallSiteTargetVolatile(CallSite site, MethodHandle target);
63
64 /** Invalidate CallSite context: clean up dependent nmethods and reset call site context to initial state (null). */
65 static native void clearCallSiteContext(CallSite.Context context);
66
67 private static native void registerNatives();
68 static {
69 registerNatives();
70
71 // The JVM calls MethodHandleNatives.<clinit>. Cascade the <clinit> calls as needed:
72 MethodHandleImpl.initStatics();
73 }
74
75 /**
76 * Compile-time constants go here. This collection exists not only for
77 * reference from clients, but also for ensuring the VM and JDK agree on the
78 * values of these constants (see {@link #verifyConstants()}).
79 */
80 static class Constants {
81 Constants() { } // static only
82
83 static final int
84 MN_IS_METHOD = 0x00010000, // method (not constructor)
85 MN_IS_CONSTRUCTOR = 0x00020000, // constructor
218 return linkCallSiteImpl(caller, bootstrapMethod, name, type,
219 staticArguments, appendixResult);
220 return linkCallSiteTracing(caller, bootstrapMethod, name, type,
221 staticArguments, appendixResult);
222 }
223 static MemberName linkCallSiteImpl(Class<?> caller,
224 MethodHandle bootstrapMethod,
225 String name, MethodType type,
226 Object staticArguments,
227 Object[] appendixResult) {
228 CallSite callSite = CallSite.makeSite(bootstrapMethod,
229 name,
230 type,
231 staticArguments,
232 caller);
233 if (callSite instanceof ConstantCallSite) {
234 appendixResult[0] = callSite.dynamicInvoker();
235 return Invokers.linkToTargetMethod(type);
236 } else {
237 appendixResult[0] = callSite;
238 return Invokers.linkToCallSiteMethod(type);
239 }
240 }
241 // Tracing logic:
242 static MemberName linkCallSiteTracing(Class<?> caller,
243 MethodHandle bootstrapMethod,
244 String name, MethodType type,
245 Object staticArguments,
246 Object[] appendixResult) {
247 Object bsmReference = bootstrapMethod.internalMemberName();
248 if (bsmReference == null) bsmReference = bootstrapMethod;
249 Object staticArglist = (staticArguments instanceof Object[] ?
250 java.util.Arrays.asList((Object[]) staticArguments) :
251 staticArguments);
252 System.out.println("linkCallSite "+caller.getName()+" "+
253 bsmReference+" "+
254 name+type+"/"+staticArglist);
255 try {
256 MemberName res = linkCallSiteImpl(caller, bootstrapMethod, name, type,
257 staticArguments, appendixResult);
|