225 THROW_UCS = IMPL_LOOKUP.
226 findStatic(CallSite.class, "uninitializedCallSite", MethodType.methodType(Object.class, Object[].class));
227 } catch (ReflectiveOperationException e) {
228 throw newInternalError(e);
229 }
230 }
231
232 /** This guy is rolled into the default target if a MethodType is supplied to the constructor. */
233 private static Object uninitializedCallSite(Object... ignore) {
234 throw new IllegalStateException("uninitialized call site");
235 }
236
237 private MethodHandle makeUninitializedCallSite(MethodType targetType) {
238 MethodType basicType = targetType.basicType();
239 MethodHandle invoker = basicType.form().cachedMethodHandle(MethodTypeForm.MH_UNINIT_CS);
240 if (invoker == null) {
241 invoker = THROW_UCS.asType(basicType);
242 invoker = basicType.form().setCachedMethodHandle(MethodTypeForm.MH_UNINIT_CS, invoker);
243 }
244 // unchecked view is OK since no values will be received or returned
245 return invoker.viewAsType(targetType);
246 }
247
248 // unsafe stuff:
249 private static final long TARGET_OFFSET;
250 static {
251 try {
252 TARGET_OFFSET = UNSAFE.objectFieldOffset(CallSite.class.getDeclaredField("target"));
253 } catch (Exception ex) { throw new Error(ex); }
254 }
255
256 /*package-private*/
257 void setTargetNormal(MethodHandle newTarget) {
258 MethodHandleNatives.setCallSiteTargetNormal(this, newTarget);
259 }
260 /*package-private*/
261 MethodHandle getTargetVolatile() {
262 return (MethodHandle) UNSAFE.getObjectVolatile(this, TARGET_OFFSET);
263 }
264 /*package-private*/
265 void setTargetVolatile(MethodHandle newTarget) {
|
225 THROW_UCS = IMPL_LOOKUP.
226 findStatic(CallSite.class, "uninitializedCallSite", MethodType.methodType(Object.class, Object[].class));
227 } catch (ReflectiveOperationException e) {
228 throw newInternalError(e);
229 }
230 }
231
232 /** This guy is rolled into the default target if a MethodType is supplied to the constructor. */
233 private static Object uninitializedCallSite(Object... ignore) {
234 throw new IllegalStateException("uninitialized call site");
235 }
236
237 private MethodHandle makeUninitializedCallSite(MethodType targetType) {
238 MethodType basicType = targetType.basicType();
239 MethodHandle invoker = basicType.form().cachedMethodHandle(MethodTypeForm.MH_UNINIT_CS);
240 if (invoker == null) {
241 invoker = THROW_UCS.asType(basicType);
242 invoker = basicType.form().setCachedMethodHandle(MethodTypeForm.MH_UNINIT_CS, invoker);
243 }
244 // unchecked view is OK since no values will be received or returned
245 return invoker.viewAsType(targetType, false);
246 }
247
248 // unsafe stuff:
249 private static final long TARGET_OFFSET;
250 static {
251 try {
252 TARGET_OFFSET = UNSAFE.objectFieldOffset(CallSite.class.getDeclaredField("target"));
253 } catch (Exception ex) { throw new Error(ex); }
254 }
255
256 /*package-private*/
257 void setTargetNormal(MethodHandle newTarget) {
258 MethodHandleNatives.setCallSiteTargetNormal(this, newTarget);
259 }
260 /*package-private*/
261 MethodHandle getTargetVolatile() {
262 return (MethodHandle) UNSAFE.getObjectVolatile(this, TARGET_OFFSET);
263 }
264 /*package-private*/
265 void setTargetVolatile(MethodHandle newTarget) {
|