Examples of SwitchPoint


Examples of java.lang.invoke.SwitchPoint

    ///////////////////////////////////////////////////////////////////////////
    // constant lookup

    public static IRubyObject searchConst(MutableCallSite site, String constName, ThreadContext context, StaticScope staticScope) throws Throwable {
        Ruby runtime = context.runtime;
        SwitchPoint switchPoint = (SwitchPoint)runtime.getConstantInvalidator().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;
    }
View Full Code Here

Examples of java.lang.invoke.SwitchPoint

   
    public synchronized void invalidate() {
        if (switchPoint == DUMMY) return;

        SwitchPoint.invalidateAll(new SwitchPoint[]{switchPoint});
        switchPoint = new SwitchPoint();
    }
View Full Code Here

Examples of java.lang.invoke.SwitchPoint

       
        SwitchPoint.invalidateAll(switchPoints);
    }
   
    public synchronized Object getData() {
        return switchPoint == DUMMY ? switchPoint = new SwitchPoint() : switchPoint;
    }
View Full Code Here

Examples of java.lang.invoke.SwitchPoint

    }
   
    public synchronized SwitchPoint replaceSwitchPoint() {
        if (switchPoint == DUMMY) return switchPoint;

        SwitchPoint oldSwitchPoint = switchPoint;
        switchPoint = new SwitchPoint();
        return oldSwitchPoint;
    }
View Full Code Here

Examples of java.lang.invoke.SwitchPoint

    // INITIAL AND FALLBACK METHODS FOR POST BOOTSTRAP
    ////////////////////////////////////////////////////////////////////////////
   
    public static IRubyObject constantFallback(RubyConstantCallSite site,
            AbstractScript script, ThreadContext context, int scopeIndex) {
        SwitchPoint switchPoint = (SwitchPoint)context.runtime.getConstantInvalidator(site.name()).getData();
        StaticScope scope = script.getScope(scopeIndex);
        IRubyObject value = scope.getConstant(site.name());
       
        if (value != null) {
            if (Options.INVOKEDYNAMIC_LOG_CONSTANTS.load()) LOG.info("constant " + site.name() + " bound directly");
           
            MethodHandle valueHandle = constant(IRubyObject.class, value);
            valueHandle = dropArguments(valueHandle, 0, AbstractScript.class, ThreadContext.class);

            MethodHandle fallback = insertArguments(
                    findStatic(InvokeDynamicSupport.class, "constantFallback",
                    methodType(IRubyObject.class, RubyConstantCallSite.class, AbstractScript.class, ThreadContext.class, int.class)),
                    0,
                    site);
            fallback = insertArguments(fallback, 2, scopeIndex);

            MethodHandle gwt = switchPoint.guardWithTest(valueHandle, fallback);
            site.setTarget(gwt);
        } else {
            value = scope.getModule()
                    .callMethod(context, "const_missing", context.runtime.newSymbol(site.name()));
        }
View Full Code Here

Examples of java.lang.invoke.SwitchPoint

        return value;
    }

    public static boolean constantBooleanFallback(RubyConstantCallSite site,
            AbstractScript script, ThreadContext context, int scopeIndex) {
        SwitchPoint switchPoint = (SwitchPoint)context.runtime.getConstantInvalidator(site.name()).getData();
        StaticScope scope = script.getScope(scopeIndex);
        IRubyObject value = scope.getConstant(site.name());
       
        if (value != null) {
            if (Options.INVOKEDYNAMIC_LOG_CONSTANTS.load()) LOG.info("constant " + site.name() + " bound directly");
           
            MethodHandle valueHandle = constant(boolean.class, value.isTrue());
            valueHandle = dropArguments(valueHandle, 0, AbstractScript.class, ThreadContext.class);

            MethodHandle fallback = insertArguments(
                    findStatic(InvokeDynamicSupport.class, "constantBooleanFallback",
                    methodType(boolean.class, RubyConstantCallSite.class, AbstractScript.class, ThreadContext.class, int.class)),
                    0,
                    site);
            fallback = insertArguments(fallback, 2, scopeIndex);

            MethodHandle gwt = switchPoint.guardWithTest(valueHandle, fallback);
            site.setTarget(gwt);
        } else {
            value = scope.getModule()
                    .callMethod(context, "const_missing", context.runtime.newSymbol(site.name()));
        }
View Full Code Here

Examples of java.lang.invoke.SwitchPoint

            switchPoint = DUMMY;
            return;
        }
       
        SwitchPoint.invalidateAll(new SwitchPoint[]{switchPoint});
        switchPoint = new SwitchPoint();
    }
View Full Code Here

Examples of java.lang.invoke.SwitchPoint

       
        SwitchPoint.invalidateAll(switchPoints);
    }
   
    public synchronized Object getData() {
        return switchPoint == DUMMY && failures <= maxFailures ? switchPoint = new SwitchPoint() : switchPoint;
    }
View Full Code Here

Examples of java.lang.invoke.SwitchPoint

    }
   
    public synchronized SwitchPoint replaceSwitchPoint() {
        if (switchPoint == DUMMY || failures > maxFailures) return DUMMY;

        SwitchPoint oldSwitchPoint = switchPoint;
        switchPoint = new SwitchPoint();
        return oldSwitchPoint;
    }
View Full Code Here

Examples of java.lang.invoke.SwitchPoint

   
    public synchronized void invalidate() {
        if (switchPoint == DUMMY) return;

        SwitchPoint.invalidateAll(new SwitchPoint[]{switchPoint});
        switchPoint = new SwitchPoint();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.