return variable.getAccessor().getValue();
}
public static boolean getGlobalBooleanFallback(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, "getGlobalBooleanUncached", methodType(boolean.class, GlobalVariable.class));
uncached = uncached.bindTo(variable);
uncached = dropArguments(uncached, 0, ThreadContext.class);
site.setTarget(uncached);
return (Boolean)uncached.invokeWithArguments(context);
}
Invalidator invalidator = variable.getInvalidator();
boolean value = variable.getAccessor().getValue().isTrue();
MethodHandle target = constant(boolean.class, value);
target = dropArguments(target, 0, ThreadContext.class);
MethodHandle fallback = lookup().findStatic(InvokeDynamicSupport.class, "getGlobalBooleanFallback", methodType(boolean.class, GlobalSite.class, ThreadContext.class));
fallback = fallback.bindTo(site);