return site;
}
public static IRubyObject getGlobalFallback(GlobalSite site, ThreadContext context) throws Throwable {
Ruby runtime = context.runtime;
GlobalVariable variable = runtime.getGlobalVariables().getVariable(site.name());
if (site.failures() > Options.INVOKEDYNAMIC_GLOBAL_MAXFAIL.load() ||
variable.getScope() != GlobalVariable.Scope.GLOBAL) {
// use uncached logic forever
if (Options.INVOKEDYNAMIC_LOG_GLOBALS.load()) LOG.info("global " + site.name() + " (" + site.file() + ":" + site.line() + ") rebound > " + Options.INVOKEDYNAMIC_GLOBAL_MAXFAIL.load() + " times, reverting to simple lookup");
MethodHandle uncached = lookup().findStatic(InvokeDynamicSupport.class, "getGlobalUncached", methodType(IRubyObject.class, GlobalVariable.class));
uncached = uncached.bindTo(variable);
uncached = dropArguments(uncached, 0, ThreadContext.class);
site.setTarget(uncached);
return (IRubyObject)uncached.invokeWithArguments(context);
}
Invalidator invalidator = variable.getInvalidator();
IRubyObject value = variable.getAccessor().getValue();
MethodHandle target = constant(IRubyObject.class, value);
target = dropArguments(target, 0, ThreadContext.class);
MethodHandle fallback = lookup().findStatic(InvokeDynamicSupport.class, "getGlobalFallback", methodType(IRubyObject.class, GlobalSite.class, ThreadContext.class));
fallback = fallback.bindTo(site);