Package org.jruby.runtime.opto

Examples of org.jruby.runtime.opto.Invalidator


    }
   
    public static IRubyObject getGlobalFallback(GlobalSite site, ThreadContext context) throws Throwable {
        Ruby runtime = context.runtime;
        GlobalVariable variable = runtime.getGlobalVariables().getVariable(site.name);
        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);
       
        target = ((SwitchPoint)invalidator.getData()).guardWithTest(target, fallback);
       
        site.setTarget(target);
       
        return value;
    }
View Full Code Here


    }
   
    public static boolean getGlobalBooleanFallback(GlobalSite site, ThreadContext context) throws Throwable {
        Ruby runtime = context.runtime;
        GlobalVariable variable = runtime.getGlobalVariables().getVariable(site.name);
        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);
       
        target = ((SwitchPoint)invalidator.getData()).guardWithTest(target, fallback);
       
        site.setTarget(target);
       
        return value;
    }
View Full Code Here

        return site;
    }
   
    public static void checkpointFallback(MutableCallSite site, ThreadContext context) throws Throwable {
        Ruby runtime = context.runtime;
        Invalidator invalidator = runtime.getCheckpointInvalidator();
       
        MethodHandle target = Binder
                .from(void.class, ThreadContext.class)
                .nop();
        MethodHandle fallback = lookup().findStatic(InvokeDynamicSupport.class, "checkpointFallback", methodType(void.class, MutableCallSite.class, ThreadContext.class));
        fallback = fallback.bindTo(site);
       
        target = ((SwitchPoint)invalidator.getData()).guardWithTest(target, fallback);
       
        site.setTarget(target);
    }
View Full Code Here

    public int getConstantGeneration() {
        return -1;
    }

    public Invalidator getConstantInvalidator(String constantName) {
        Invalidator invalidator = constantNameInvalidators.get(constantName);
        if (invalidator != null) {
            return invalidator;
        } else {
            return addConstantInvalidator(constantName);
        }
View Full Code Here

            return addConstantInvalidator(constantName);
        }
    }

    private Invalidator addConstantInvalidator(String constantName) {
        Invalidator invalidator = OptoFactory.newConstantInvalidator();
        constantNameInvalidators.putIfAbsent(constantName, invalidator);

        // fetch the invalidator back from the ConcurrentHashMap to ensure that
        // only one invalidator for a given constant name is ever used:
        return constantNameInvalidators.get(constantName);
View Full Code Here

        ConstantCache cache = constants[index];
        return ConstantCache.isCached(cache) ? cache.value : reCache(context, scope, name, index);
    }

    public IRubyObject reCache(ThreadContext context, StaticScope scope, String name, int index) {
        Invalidator invalidator = context.runtime.getConstantInvalidator(name);
        Object newGeneration = invalidator.getData();
        IRubyObject value = scope.getConstant(name);
        if (value != null) {
            constants[index] = new ConstantCache(value, newGeneration, invalidator);
        } else {
            constants[index] = null;
View Full Code Here

        ConstantCache cache = constants[index];
        return ConstantCache.isCachedFrom(target, cache) ? cache.value : reCacheFrom(target, context, name, index);
    }

    public IRubyObject reCacheFrom(RubyModule target, ThreadContext context, String name, int index) {
        Invalidator invalidator = context.runtime.getConstantInvalidator(name);
        Object newGeneration = invalidator.getData();
        IRubyObject value = target.getConstantFromNoConstMissing(name, false);
        if (value != null) {
            constants[index] = new ConstantCache(value, newGeneration, invalidator, target.hashCode());
        } else {
            constants[index] = null;
View Full Code Here

            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);
       
        target = ((SwitchPoint)invalidator.getData()).guardWithTest(target, fallback);
       
        site.setTarget(target);
       
        if (Options.INVOKEDYNAMIC_LOG_GLOBALS.load()) LOG.info("global " + site.name() + " (" + site.file() + ":" + site.line() + ") cached");
       
View Full Code Here

            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);
       
        target = ((SwitchPoint)invalidator.getData()).guardWithTest(target, fallback);
       
        site.setTarget(target);
       
        if (Options.INVOKEDYNAMIC_LOG_GLOBALS.load()) LOG.info("global " + site.name() + " (" + site.file() + ":" + site.line() + ") cached as boolean");
       
View Full Code Here

        return site;
    }
   
    public static void checkpointFallback(MutableCallSite site, ThreadContext context) throws Throwable {
        Ruby runtime = context.runtime;
        Invalidator invalidator = runtime.getCheckpointInvalidator();
       
        MethodHandle target = Binder
                .from(void.class, ThreadContext.class)
                .nop();
        MethodHandle fallback = lookup().findStatic(InvokeDynamicSupport.class, "checkpointFallback", methodType(void.class, MutableCallSite.class, ThreadContext.class));
        fallback = fallback.bindTo(site);
       
        target = ((SwitchPoint)invalidator.getData()).guardWithTest(target, fallback);
       
        site.setTarget(target);
    }
View Full Code Here

TOP

Related Classes of org.jruby.runtime.opto.Invalidator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.