/** * backing bootstrap method with all parameters */ private static CallSite realBootstrap(Lookup caller, String name, int callID, MethodType type, boolean safe, boolean thisCall, boolean spreadCall) { // since indy does not give us the runtime types // we produce first a dummy call site, which then changes the target to one, // that does the method selection including the the direct call to the // real method. MutableCallSite mc = new MutableCallSite(type); MethodHandle mh = makeFallBack(mc,caller.lookupClass(),name,callID,type,safe,thisCall,spreadCall); mc.setTarget(mh); return mc; }
/** * do the actual call site target set, if the call is supposed to be cached */ public void doCallSiteTargetSet() { if (!cache) { if (LOG_ENABLED) LOG.info("call site stays uncached"); } else { callSite.setTarget(handle); if (LOG_ENABLED) LOG.info("call site target set, preparing outside invocation"); } }
@SuppressWarnings("unused") private static MethodHandle nativeCallSetup(MutableCallSite callsite, String name, ExecutionContext cx) { RuntimeContext context = cx.getRuntimeContext(); MethodHandle target; try { MethodHandle mh = context.getNativeCallResolver().apply(name, callsite.type()); if (mh == null) { throw new IllegalArgumentException(); } target = adaptNativeMethodHandle(mh); target = adaptMethodHandle(name, callsite.type(), target); } catch (IllegalArgumentException e) { target = invalidCallHandle(name, callsite.type()); } callsite.setTarget(target); return target; }
public CallSite bootstrap(Lookup lookup, String name, MethodType type) throws Throwable { MutableCallSite callSite = new MutableCallSite(type); LinkPlan plan = new LinkPlan(this, callSite, lookup, name, type, null); return plan.callSite(); }
public synchronized static void resetAll() { for (BaseCallSite callsite : callsites) { callsite.reset(); } MutableCallSite.syncAll(callsites.toArray(new MutableCallSite[callsites.size()])); }
@Override public void setTarget(MethodHandle target) { super.setTarget(target); boundOnce = true; }
private static MethodHandle setCallSiteTarget(MutableCallSite callsite, MethodHandle target, MethodHandle test, MethodHandle generic) { MethodHandle callSiteTarget; if (target != null) { target = target.asType(callsite.type()); if (test != null) { MethodHandle fallback = createFallback(callsite, generic); callSiteTarget = MethodHandles.guardWithTest(test, target, fallback); } else { callSiteTarget = target; } } else { callSiteTarget = target = generic; } callsite.setTarget(callSiteTarget); return target; }
public CallSite bootstrap(Lookup lookup, String name, MethodType type, String file, int line, int column) throws Throwable { MutableCallSite callSite = new MutableCallSite(type); LinkPlan plan = new LinkPlan(this, callSite, lookup, name, type, new Location(file, line, column)); return plan.callSite(); }
MutableCallSite.syncAll(new MutableCallSite[] { (MutableCallSite)callSite });
public static CallSite checkpointBootstrap(Lookup lookup, String name, MethodType type) throws Throwable { MutableCallSite site = new MutableCallSite(type); MethodHandle handle = lookup.findStatic(Bootstrap.class, "checkpointFallback", methodType(void.class, MutableCallSite.class, ThreadContext.class)); handle = handle.bindTo(site); site.setTarget(handle); return site; }
@Override public void setTarget(MethodHandle target) { super.setTarget(target); boundOnce = true; }
public static IRubyObject inheritanceSearchConst(MutableCallSite site, String constName, ThreadContext context, IRubyObject cmVal) throws Throwable { Ruby runtime = context.runtime; RubyModule module; if (cmVal instanceof RubyModule) { module = (RubyModule) cmVal; } else { throw runtime.newTypeError(cmVal + " is not a type/class"); } SwitchPoint switchPoint = (SwitchPoint)runtime.getConstantInvalidator(constName).getData(); IRubyObject value = module.getConstantFromNoConstMissing(constName, false); if (value == null) { return (IRubyObject)UndefinedValue.UNDEFINED; } // bind constant until invalidated MethodHandle target = Binder.from(site.type()) .drop(0, 2) .constant(value); MethodHandle fallback = Binder.from(site.type()) .insert(0, site, constName) .invokeStatic(MethodHandles.lookup(), Bootstrap.class, "inheritanceSearchConst"); site.setTarget(switchPoint.guardWithTest(target, fallback)); return value; }
public MethodSelector(MutableCallSite callSite, Class sender, String methodName, CALL_TYPES callType, Boolean safeNavigation, Boolean thisCall, Boolean spreadCall, Object[] arguments) { this.callType = callType; this.targetType = callSite.type(); this.name = methodName; this.originalArguments = arguments;
MutableCallSite.syncAll(new MutableCallSite[] { (MutableCallSite)callSite });
public static CallSite checkpointBootstrap(Lookup lookup, String name, MethodType type) throws Throwable { MutableCallSite site = new MutableCallSite(type); MethodHandle handle = lookup.findStatic(InvokeDynamicSupport.class, "checkpointFallback", methodType(void.class, MutableCallSite.class, ThreadContext.class)); handle = handle.bindTo(site); site.setTarget(handle); return site; }
@Override public void setTarget(MethodHandle target) { super.setTarget(target); boundOnce = true; }
public static IRubyObject searchConst(MutableCallSite site, String constName, ThreadContext context, StaticScope staticScope) throws Throwable { Ruby runtime = context.runtime; SwitchPoint switchPoint = (SwitchPoint)runtime.getConstantInvalidator(constName).getData(); IRubyObject value = staticScope.getConstant(constName); if (value == null) { return staticScope.getModule().callMethod(context, "const_missing", runtime.fastNewSymbol(constName)); } // bind constant until invalidated MethodHandle target = Binder.from(site.type()) .drop(0, 2) .constant(value); MethodHandle fallback = Binder.from(site.type()) .insert(0, site, constName) .invokeStatic(MethodHandles.lookup(), Bootstrap.class, "searchConst"); site.setTarget(switchPoint.guardWithTest(target, fallback)); return value; }
@Override public void setCallSiteTarget() { // targetTypes String, Enum and Class are handled // by the compiler already // Boolean / boolean handleBoolean(); handleNullWithoutBoolean(); // !! from here on args[0] is always not null !! handleInstanceCase(); // targetType is abstract Collection fitting for HashSet or ArrayList // and object is Collection or array handleCollections(); handleSAM(); // will handle : // * collection case where argument is an array // * array transformation (staticTargetType.isArray()) // * constructor invocation // * final GroovyCastException castToTypeFallBack(); if (!handle.type().equals(callSite.type())) castAndSetGuards(); }
public static CallSite checkpointBootstrap(Lookup lookup, String name, MethodType type) throws Throwable { MutableCallSite site = new MutableCallSite(type); MethodHandle handle = lookup.findStatic(Bootstrap.class, "checkpointFallback", methodType(void.class, MutableCallSite.class, ThreadContext.class)); handle = handle.bindTo(site); site.setTarget(handle); return site; }