Search in sources :

Example 1 with TruffleAssumption

use of org.graalvm.compiler.truffle.compiler.nodes.TruffleAssumption in project graal by oracle.

the class TruffleCompilationResultBuilderFactory method processAssumption.

static void processAssumption(Set<Assumption> newAssumptions, Assumption assumption, List<TruffleAssumption> manual) {
    if (assumption != null) {
        if (assumption instanceof TruffleAssumption) {
            TruffleAssumption assumptionValidAssumption = (TruffleAssumption) assumption;
            manual.add(assumptionValidAssumption);
        } else {
            newAssumptions.add(assumption);
        }
    }
}
Also used : TruffleAssumption(org.graalvm.compiler.truffle.compiler.nodes.TruffleAssumption)

Example 2 with TruffleAssumption

use of org.graalvm.compiler.truffle.compiler.nodes.TruffleAssumption in project graal by oracle.

the class TruffleGraphBuilderPlugins method registerOptimizedAssumptionPlugins.

public static void registerOptimizedAssumptionPlugins(InvocationPlugins plugins, MetaAccessProvider metaAccess, KnownTruffleTypes types) {
    ResolvedJavaType optimizedAssumptionType = getRuntime().resolveType(metaAccess, "org.graalvm.compiler.truffle.runtime.OptimizedAssumption");
    Registration r = new Registration(plugins, new ResolvedJavaSymbol(optimizedAssumptionType), null);
    InvocationPlugin plugin = new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            if (receiver.isConstant() && b.getAssumptions() != null) {
                JavaConstant assumption = (JavaConstant) receiver.get().asConstant();
                if (b.getConstantReflection().readFieldValue(types.fieldOptimizedAssumptionIsValid, assumption).asBoolean()) {
                    if (targetMethod.getName().equals("isValid")) {
                        b.addPush(JavaKind.Boolean, ConstantNode.forBoolean(true));
                    } else {
                        assert targetMethod.getName().equals("check") : targetMethod;
                    }
                    b.getAssumptions().record(new TruffleAssumption(assumption));
                } else {
                    if (targetMethod.getName().equals("isValid")) {
                        b.addPush(JavaKind.Boolean, ConstantNode.forBoolean(false));
                    } else {
                        assert targetMethod.getName().equals("check") : targetMethod;
                        b.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.None));
                    }
                }
                return true;
            } else {
                return false;
            }
        }
    };
    r.register1("isValid", Receiver.class, plugin);
    r.register1("check", Receiver.class, plugin);
}
Also used : GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) TruffleAssumption(org.graalvm.compiler.truffle.compiler.nodes.TruffleAssumption) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) JavaConstant(jdk.vm.ci.meta.JavaConstant) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) ResolvedJavaSymbol(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

TruffleAssumption (org.graalvm.compiler.truffle.compiler.nodes.TruffleAssumption)2 JavaConstant (jdk.vm.ci.meta.JavaConstant)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)1 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)1 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)1 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)1 Receiver (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver)1 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)1 ResolvedJavaSymbol (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol)1