Package org.jruby.runtime.opto

Examples of org.jruby.runtime.opto.ConstantCache


        IRubyObject value = getValue(context, scope, name, index);
        return value == null ? null : context.runtime.getDefinedMessage(DefinedMessage.CONSTANT);
    }

    public IRubyObject getValue(ThreadContext context, StaticScope scope, String name, int index) {
        ConstantCache cache = constants[index];
        return ConstantCache.isCached(cache) ? cache.value : reCache(context, scope, name, index);
    }
View Full Code Here


    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;
        }
        return value;
    }
View Full Code Here

        // We can callsite cache const_missing if we want
        return value != null ? value : target.getConstantFromConstMissing(name);
    }

    public IRubyObject getValueFrom(RubyModule target, ThreadContext context, String name, int index) {
        ConstantCache cache = constants[index];
        return ConstantCache.isCachedFrom(target, cache) ? cache.value : reCacheFrom(target, context, name, index);
    }
View Full Code Here

    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;
        }
        return value;
    }
View Full Code Here

        if (constant == null) {
            constant = module.callMethod(context, "const_missing", runtime.fastNewSymbol(constName));
        } else {
            // recache
            Invalidator invalidator = runtime.getConstantInvalidator(constName);
            cache = new ConstantCache((IRubyObject)constant, invalidator.getData(), invalidator);
        }

        return constant;
    }
View Full Code Here

        return constant;
    }

    public Object getCachedConst() {
        ConstantCache cache = this.cache;
        return cache == null ? null : cache.value;
    }
View Full Code Here

        return cache == null ? null : cache.value;
    }

    @Override
    public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
        ConstantCache cache = this.cache;
        if (!ConstantCache.isCached(cache)) return cache(context, currScope, currDynScope, self, temp);

        return cache.value;
    }
View Full Code Here

        if (constant == null) {
            constant = UndefinedValue.UNDEFINED;
        } else {
            // recache
            Invalidator invalidator = context.runtime.getConstantInvalidator(constName);
            cache = new ConstantCache(constant, invalidator.getData(), invalidator);
        }

        return constant;
    }
View Full Code Here

        return constant;
    }

    @Override
    public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
        ConstantCache cache = this.cache; // Store to temp so it does null out on us mid-stream
        if (!ConstantCache.isCached(cache)) return cache(context, currScope, currDynScope, self, temp);

        return cache.value;
    }
View Full Code Here

        if (constant == null) {
            constant = UndefinedValue.UNDEFINED;
        } else {
            // recache
            Invalidator invalidator = runtime.getConstantInvalidator(constName);
            cache = new ConstantCache((IRubyObject)constant, invalidator.getData(), invalidator, module.hashCode());
        }
        return constant;
    }
View Full Code Here

TOP

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

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.