Search in sources :

Example 1 with NeverPartOfCompilationNode

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

the class TruffleGraphBuilderPlugins method registerCompilerDirectivesPlugins.

public static void registerCompilerDirectivesPlugins(InvocationPlugins plugins, MetaAccessProvider metaAccess, boolean canDelayIntrinsification) {
    final ResolvedJavaType compilerDirectivesType = getRuntime().resolveType(metaAccess, "com.oracle.truffle.api.CompilerDirectives");
    Registration r = new Registration(plugins, new ResolvedJavaSymbol(compilerDirectivesType));
    r.register0("inInterpreter", new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            b.addPush(JavaKind.Boolean, ConstantNode.forBoolean(false));
            return true;
        }
    });
    r.register0("inCompiledCode", new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            b.addPush(JavaKind.Boolean, ConstantNode.forBoolean(true));
            return true;
        }
    });
    r.register0("inCompilationRoot", new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            GraphBuilderContext.ExternalInliningContext inliningContext = b.getExternalInliningContext();
            if (inliningContext != null) {
                b.addPush(JavaKind.Boolean, ConstantNode.forBoolean(inliningContext.getInlinedDepth() == 0));
                return true;
            }
            return false;
        }
    });
    r.register0("transferToInterpreter", new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            b.add(new DeoptimizeNode(DeoptimizationAction.None, DeoptimizationReason.TransferToInterpreter));
            return true;
        }
    });
    r.register0("transferToInterpreterAndInvalidate", new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            b.add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.TransferToInterpreter));
            return true;
        }
    });
    r.register1("interpreterOnly", Runnable.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg) {
            return true;
        }
    });
    r.register1("interpreterOnly", Callable.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg) {
            return true;
        }
    });
    r.register2("injectBranchProbability", double.class, boolean.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode probability, ValueNode condition) {
            b.addPush(JavaKind.Boolean, new BranchProbabilityNode(probability, condition));
            return true;
        }
    });
    r.register1("bailout", String.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode message) {
            if (canDelayIntrinsification) {
                /*
                     * We do not want to bailout yet, since we are still parsing individual methods
                     * and constant folding could still eliminate the call to bailout(). However, we
                     * also want to stop parsing, since we are sure that we will never need the
                     * graph beyond the bailout point.
                     *
                     * Therefore, we manually emit the call to bailout, which will be intrinsified
                     * later when intrinsifications can no longer be delayed. The call is followed
                     * by a NeverPartOfCompilationNode, which is a control sink and therefore stops
                     * any further parsing.
                     */
                StampPair returnStamp = b.getInvokeReturnStamp(b.getAssumptions());
                CallTargetNode callTarget = b.add(new MethodCallTargetNode(InvokeKind.Static, targetMethod, new ValueNode[] { message }, returnStamp, null));
                b.add(new InvokeNode(callTarget, b.bci()));
                b.add(new NeverPartOfCompilationNode("intrinsification of call to bailout() will abort entire compilation"));
                return true;
            }
            if (message.isConstant()) {
                throw b.bailout(message.asConstant().toValueString());
            }
            throw b.bailout("bailout (message is not compile-time constant, so no additional information is available)");
        }
    });
    r.register1("isCompilationConstant", Object.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
            if ((value instanceof BoxNode ? ((BoxNode) value).getValue() : value).isConstant()) {
                b.addPush(JavaKind.Boolean, ConstantNode.forBoolean(true));
            } else {
                b.addPush(JavaKind.Boolean, new IsCompilationConstantNode(value));
            }
            return true;
        }
    });
    r.register1("isPartialEvaluationConstant", Object.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
            if ((value instanceof BoxNode ? ((BoxNode) value).getValue() : value).isConstant()) {
                b.addPush(JavaKind.Boolean, ConstantNode.forBoolean(true));
            } else if (canDelayIntrinsification) {
                return false;
            } else {
                b.addPush(JavaKind.Boolean, ConstantNode.forBoolean(false));
            }
            return true;
        }
    });
    r.register1("materialize", Object.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
            AllowMaterializeNode materializedValue = b.append(new AllowMaterializeNode(value));
            b.add(new ForceMaterializeNode(materializedValue));
            return true;
        }
    });
    r.register1("ensureVirtualized", Object.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object) {
            b.add(new EnsureVirtualizedNode(object, false));
            return true;
        }
    });
    r.register1("ensureVirtualizedHere", Object.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object) {
            b.add(new EnsureVirtualizedNode(object, true));
            return true;
        }
    });
    r.register2("castExact", Object.class, Class.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object, ValueNode javaClass) {
            ValueNode nullCheckedClass = b.addNonNullCast(javaClass);
            LogicNode condition = b.append(InstanceOfDynamicNode.create(b.getAssumptions(), b.getConstantReflection(), nullCheckedClass, object, true, true));
            if (condition.isTautology()) {
                b.addPush(JavaKind.Object, object);
            } else {
                FixedGuardNode fixedGuard = b.add(new FixedGuardNode(condition, DeoptimizationReason.ClassCastException, DeoptimizationAction.InvalidateReprofile, false));
                b.addPush(JavaKind.Object, DynamicPiNode.create(b.getAssumptions(), b.getConstantReflection(), object, fixedGuard, nullCheckedClass, true));
            }
            return true;
        }
    });
}
Also used : EnsureVirtualizedNode(org.graalvm.compiler.nodes.virtual.EnsureVirtualizedNode) BoxNode(org.graalvm.compiler.nodes.extended.BoxNode) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) BranchProbabilityNode(org.graalvm.compiler.nodes.extended.BranchProbabilityNode) AllowMaterializeNode(org.graalvm.compiler.truffle.compiler.nodes.frame.AllowMaterializeNode) ResolvedJavaSymbol(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol) NeverPartOfCompilationNode(org.graalvm.compiler.truffle.compiler.nodes.asserts.NeverPartOfCompilationNode) ForceMaterializeNode(org.graalvm.compiler.truffle.compiler.nodes.frame.ForceMaterializeNode) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) FixedGuardNode(org.graalvm.compiler.nodes.FixedGuardNode) IsCompilationConstantNode(org.graalvm.compiler.truffle.compiler.nodes.IsCompilationConstantNode) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) ValueNode(org.graalvm.compiler.nodes.ValueNode) StampPair(org.graalvm.compiler.core.common.type.StampPair) InvokeNode(org.graalvm.compiler.nodes.InvokeNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) CallTargetNode(org.graalvm.compiler.nodes.CallTargetNode)

Example 2 with NeverPartOfCompilationNode

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

the class Target_com_oracle_truffle_api_interop_java_ObjectProxyHandler method handleNeverPartOfCompilation.

private boolean handleNeverPartOfCompilation(GraphBuilderContext b, ResolvedJavaMethod targetMethod, ValueNode messageNode) {
    String message = "CompilerAsserts.neverPartOfCompilation()";
    if (messageNode != null && messageNode.isConstant()) {
        message = messageNode.asConstant().toValueString();
    }
    NeverPartOfCompilationNode neverPartOfCompilation = b.add(new NeverPartOfCompilationNode(message));
    if (Options.TruffleCheckNeverPartOfCompilation.getValue()) {
        if (neverPartOfCompilation.stateAfter().getMethod().getDeclaringClass().equals(targetMethod.getDeclaringClass())) {
        /* Ignore internal use from another method in CompilerAsserts class. */
        } else {
            CallTreeNode callerNode = ((RuntimeBytecodeParser) b).getCallTreeNode();
            CallTreeNode calleeNode = new CallTreeNode(targetMethod, targetMethod, callerNode, callerNode.getLevel() + 1, GraalFeature.buildSourceReference(neverPartOfCompilation.stateAfter()));
            neverPartOfCompilationViolations.add(calleeNode);
        }
    }
    return true;
}
Also used : CallTreeNode(com.oracle.svm.graal.hosted.GraalFeature.CallTreeNode) NeverPartOfCompilationNode(org.graalvm.compiler.truffle.compiler.nodes.asserts.NeverPartOfCompilationNode) RuntimeBytecodeParser(com.oracle.svm.graal.hosted.GraalFeature.RuntimeBytecodeParser)

Example 3 with NeverPartOfCompilationNode

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

the class Target_com_oracle_truffle_api_interop_java_ObjectProxyHandler method beforeCompilation.

@Override
public void beforeCompilation(BeforeCompilationAccess config) {
    BeforeCompilationAccessImpl access = (BeforeCompilationAccessImpl) config;
    if (GraalFeature.Options.PrintRuntimeCompileMethods.getValue() && blacklistViolations.size() > 0) {
        System.out.println();
        System.out.println("=== Found " + blacklistViolations.size() + " compilation blacklist violations ===");
        System.out.println();
        for (GraalFeature.CallTreeNode node : blacklistViolations) {
            System.out.println("Blacklisted method");
            System.out.println(node.getImplementationMethod().format("  %H.%n(%p)"));
            System.out.println("called from");
            for (GraalFeature.CallTreeNode cur = node; cur != null; cur = cur.getParent()) {
                System.out.println("  " + cur.getSourceReference());
            }
        }
    }
    if (warnViolations.size() > 0) {
        /*
             * It is enough to print one warning message with one stack trace. Take the shortest
             * stack trace.
             */
        GraalFeature.CallTreeNode printNode = null;
        int printLength = Integer.MAX_VALUE;
        for (GraalFeature.CallTreeNode warnNode : warnViolations) {
            int warnLength = 0;
            for (GraalFeature.CallTreeNode cur = warnNode; cur != null; cur = cur.getParent()) {
                warnLength++;
            }
            if (warnLength < printLength) {
                printNode = warnNode;
                printLength = warnLength;
            }
        }
        System.out.println("WARNING: suspicious method reachable for runtime compilation: " + printNode.getImplementationMethod().format("%H.%n(%p)"));
        System.out.println("Check the complete tree of reachable methods using the option " + GraalFeature.Options.PrintRuntimeCompileMethods.getDescriptor().getFieldName());
        System.out.println("Suspicious method is called from");
        for (GraalFeature.CallTreeNode cur = printNode; cur != null; cur = cur.getParent()) {
            System.out.println("  " + cur.getSourceReference());
        }
    }
    if (neverPartOfCompilationViolations.size() > 0) {
        System.out.println("ERROR: CompilerAsserts.neverPartOfCompilation reachable for runtime compilation from " + neverPartOfCompilationViolations.size() + " places:");
        for (GraalFeature.CallTreeNode neverPartOfCompilationNode : neverPartOfCompilationViolations) {
            System.out.println("called from");
            for (GraalFeature.CallTreeNode cur = neverPartOfCompilationNode; cur != null; cur = cur.getParent()) {
                System.out.println("  " + cur.getSourceReference());
            }
        }
        throw VMError.shouldNotReachHere("CompilerAsserts.neverPartOfCompilation reachable for runtime compilation");
    }
    if (Options.TruffleCheckFrameImplementation.getValue() && useTruffleCompiler()) {
        /*
             * Check that only one Frame implementation is seen as instantiated by the static
             * analysis. That allows de-virtualization of all calls to Frame methods in the
             * interpreter.
             *
             * The DefaultTruffleRuntime uses multiple Frame implementations (DefaultVirtualFrame,
             * DefaultMaterializedFrame, ReadOnlyFrame) to detect wrong usages of the Frame API, so
             * we can only check when running with compilation enabled.
             */
        Optional<? extends ResolvedJavaType> optionalFrameType = access.getMetaAccess().optionalLookupJavaType(Frame.class);
        if (optionalFrameType.isPresent()) {
            HostedType frameType = (HostedType) optionalFrameType.get();
            Set<HostedType> implementations = new HashSet<>();
            collectImplementations(frameType, implementations);
            if (implementations.size() > 1) {
                throw UserError.abort("More than one implementation of " + Frame.class.getTypeName() + " found. For performance reasons, Truffle languages must not provide new implementations, and instead only use the single implementation provided by the Truffle runtime. " + "To disable this check, add " + SubstrateOptionsParser.commandArgument(Options.TruffleCheckFrameImplementation, "-") + " to the native-image command line. " + "Found classes: " + implementations.stream().map(m -> m.toJavaName(true)).collect(Collectors.joining(", ")));
            } else {
                assert implementations.size() == 0 || implementations.iterator().next() == frameType.getSingleImplementor();
            }
        }
    }
}
Also used : BeforeAnalysisAccessImpl(com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl) HostedProviders(com.oracle.graal.pointsto.meta.HostedProviders) Arrays(java.util.Arrays) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) KnownTruffleTypes(org.graalvm.compiler.truffle.compiler.substitutions.KnownTruffleTypes) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField) BooleanSupplier(java.util.function.BooleanSupplier) InlineInfo.createStandardInlineInfo(org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin.InlineInfo.createStandardInlineInfo) BigDecimal(java.math.BigDecimal) Vector(java.util.Vector) CompilerDirectives(com.oracle.truffle.api.CompilerDirectives) SubstrateTruffleCompiler(com.oracle.svm.truffle.api.SubstrateTruffleCompiler) Deoptimizer(com.oracle.svm.core.deopt.Deoptimizer) Map(java.util.Map) RootNode(com.oracle.truffle.api.nodes.RootNode) Executable(java.lang.reflect.Executable) BigInteger(java.math.BigInteger) TruffleCallBoundary(org.graalvm.compiler.truffle.runtime.TruffleCallBoundary) Alias(com.oracle.svm.core.annotate.Alias) JavaStackWalker(com.oracle.svm.core.stack.JavaStackWalker) FilesFeature(com.oracle.svm.core.jdk.FilesFeature) Set(java.util.Set) FilesSupport(com.oracle.svm.core.jdk.FilesSupport) AnalysisField(com.oracle.graal.pointsto.meta.AnalysisField) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) HostedOptionValues(com.oracle.svm.core.option.HostedOptionValues) MetaAccessProvider(jdk.vm.ci.meta.MetaAccessProvider) GraphBuilderConfiguration(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration) GraalFeature(com.oracle.svm.graal.hosted.GraalFeature) InlineDuringParsingMaxDepth(org.graalvm.compiler.java.BytecodeParserOptions.InlineDuringParsingMaxDepth) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) TreeSet(java.util.TreeSet) HostedOptionKey(com.oracle.svm.core.option.HostedOptionKey) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) AnalysisMethod(com.oracle.graal.pointsto.meta.AnalysisMethod) NeverPartOfCompilationNode(org.graalvm.compiler.truffle.compiler.nodes.asserts.NeverPartOfCompilationNode) TruffleInstrument(com.oracle.truffle.api.instrumentation.TruffleInstrument) SubstratePartialEvaluator(com.oracle.svm.truffle.api.SubstratePartialEvaluator) Field(java.lang.reflect.Field) Replacements(org.graalvm.compiler.nodes.spi.Replacements) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) TreeMap(java.util.TreeMap) RuntimeBytecodeParser(com.oracle.svm.graal.hosted.GraalFeature.RuntimeBytecodeParser) RecomputeFieldValue(com.oracle.svm.core.annotate.RecomputeFieldValue) SubstrateOptimizedCallTarget(com.oracle.svm.truffle.api.SubstrateOptimizedCallTarget) Providers(org.graalvm.compiler.phases.util.Providers) DefaultTruffleRuntime(com.oracle.truffle.api.impl.DefaultTruffleRuntime) ListIterator(java.util.ListIterator) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) TruffleRuntime(com.oracle.truffle.api.TruffleRuntime) SubstrateTruffleRuntime(com.oracle.svm.truffle.api.SubstrateTruffleRuntime) JavaKind(jdk.vm.ci.meta.JavaKind) Option(org.graalvm.compiler.options.Option) UserError(com.oracle.svm.core.util.UserError) Method(java.lang.reflect.Method) IdentityHashMap(java.util.IdentityHashMap) Predicate(java.util.function.Predicate) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) InstrumentPhase(org.graalvm.compiler.truffle.compiler.phases.InstrumentPhase) OptimizedCallTarget(org.graalvm.compiler.truffle.runtime.OptimizedCallTarget) Collectors(java.util.stream.Collectors) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) FileTypeDetector(java.nio.file.spi.FileTypeDetector) TargetClass(com.oracle.svm.core.annotate.TargetClass) VMError(com.oracle.svm.core.util.VMError) ValueNode(org.graalvm.compiler.nodes.ValueNode) CallTreeNode(com.oracle.svm.graal.hosted.GraalFeature.CallTreeNode) List(java.util.List) Modifier(java.lang.reflect.Modifier) SnippetReflectionProvider(org.graalvm.compiler.api.replacements.SnippetReflectionProvider) Optional(java.util.Optional) NeverInline(com.oracle.svm.core.annotate.NeverInline) SubstrateOptionsParser(com.oracle.svm.core.option.SubstrateOptionsParser) InliningUtilities(com.oracle.svm.hosted.code.InliningUtilities) Architecture(jdk.vm.ci.code.Architecture) HashMap(java.util.HashMap) Profile(com.oracle.truffle.api.profiles.Profile) InlineInvokePlugin(org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin) HashSet(java.util.HashSet) Hashtable(java.util.Hashtable) WeakHashMap(java.util.WeakHashMap) HostedType(com.oracle.svm.hosted.meta.HostedType) CompilerAsserts(com.oracle.truffle.api.CompilerAsserts) ImageSingletons(org.graalvm.nativeimage.ImageSingletons) Iterator(java.util.Iterator) ReentrantLock(java.util.concurrent.locks.ReentrantLock) Feature(org.graalvm.nativeimage.Feature) Heap(com.oracle.svm.core.heap.Heap) Delete(com.oracle.svm.core.annotate.Delete) BeforeCompilationAccessImpl(com.oracle.svm.hosted.FeatureImpl.BeforeCompilationAccessImpl) ExplodeLoop(com.oracle.truffle.api.nodes.ExplodeLoop) Frame(com.oracle.truffle.api.frame.Frame) AfterRegistrationAccessImpl(com.oracle.svm.hosted.FeatureImpl.AfterRegistrationAccessImpl) PartialEvaluator(org.graalvm.compiler.truffle.compiler.PartialEvaluator) Truffle(com.oracle.truffle.api.Truffle) Kind(com.oracle.svm.core.annotate.RecomputeFieldValue.Kind) Comparator(java.util.Comparator) Collections(java.util.Collections) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) HostedType(com.oracle.svm.hosted.meta.HostedType) CallTreeNode(com.oracle.svm.graal.hosted.GraalFeature.CallTreeNode) GraalFeature(com.oracle.svm.graal.hosted.GraalFeature) BeforeCompilationAccessImpl(com.oracle.svm.hosted.FeatureImpl.BeforeCompilationAccessImpl) HashSet(java.util.HashSet)

Example 4 with NeverPartOfCompilationNode

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

the class TruffleGraphBuilderPlugins method registerCompilerAssertsPlugins.

public static void registerCompilerAssertsPlugins(InvocationPlugins plugins, MetaAccessProvider metaAccess, boolean canDelayIntrinsification) {
    final ResolvedJavaType compilerAssertsType = getRuntime().resolveType(metaAccess, "com.oracle.truffle.api.CompilerAsserts");
    Registration r = new Registration(plugins, new ResolvedJavaSymbol(compilerAssertsType));
    r.register1("partialEvaluationConstant", Object.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
            ValueNode curValue = value;
            if (curValue instanceof BoxNode) {
                BoxNode boxNode = (BoxNode) curValue;
                curValue = boxNode.getValue();
            }
            if (curValue.isConstant()) {
                return true;
            } else if (canDelayIntrinsification) {
                return false;
            } else {
                StringBuilder sb = new StringBuilder();
                sb.append(curValue);
                if (curValue instanceof ValuePhiNode) {
                    ValuePhiNode valuePhi = (ValuePhiNode) curValue;
                    sb.append(" (");
                    for (Node n : valuePhi.inputs()) {
                        sb.append(n);
                        sb.append("; ");
                    }
                    sb.append(")");
                }
                value.getDebug().dump(DebugContext.VERBOSE_LEVEL, value.graph(), "Graph before bailout at node %s", sb);
                throw b.bailout("Partial evaluation did not reduce value to a constant, is a regular compiler node: " + sb);
            }
        }
    });
    r.register0("neverPartOfCompilation", new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            b.add(new NeverPartOfCompilationNode("CompilerAsserts.neverPartOfCompilation()"));
            return true;
        }
    });
    r.register1("neverPartOfCompilation", String.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode message) {
            if (message.isConstant()) {
                String messageString = message.asConstant().toValueString();
                b.add(new NeverPartOfCompilationNode(messageString));
                return true;
            } else {
                throw b.bailout("message for never part of compilation is non-constant");
            }
        }
    });
}
Also used : ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) RawLoadNode(org.graalvm.compiler.nodes.extended.RawLoadNode) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) ForceMaterializeNode(org.graalvm.compiler.truffle.compiler.nodes.frame.ForceMaterializeNode) DynamicPiNode(org.graalvm.compiler.nodes.DynamicPiNode) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) BoxNode(org.graalvm.compiler.nodes.extended.BoxNode) CallTargetNode(org.graalvm.compiler.nodes.CallTargetNode) EnsureVirtualizedNode(org.graalvm.compiler.nodes.virtual.EnsureVirtualizedNode) VirtualFrameIsNode(org.graalvm.compiler.truffle.compiler.nodes.frame.VirtualFrameIsNode) RawStoreNode(org.graalvm.compiler.nodes.extended.RawStoreNode) FixedGuardNode(org.graalvm.compiler.nodes.FixedGuardNode) PiNode(org.graalvm.compiler.nodes.PiNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) NewFrameNode(org.graalvm.compiler.truffle.compiler.nodes.frame.NewFrameNode) CompareNode(org.graalvm.compiler.nodes.calc.CompareNode) UnsafeAccessNode(org.graalvm.compiler.nodes.extended.UnsafeAccessNode) AllowMaterializeNode(org.graalvm.compiler.truffle.compiler.nodes.frame.AllowMaterializeNode) LogicConstantNode(org.graalvm.compiler.nodes.LogicConstantNode) BranchProbabilityNode(org.graalvm.compiler.nodes.extended.BranchProbabilityNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) ConditionAnchorNode(org.graalvm.compiler.nodes.ConditionAnchorNode) InstanceOfDynamicNode(org.graalvm.compiler.nodes.java.InstanceOfDynamicNode) UnsignedMulHighNode(org.graalvm.compiler.replacements.nodes.arithmetic.UnsignedMulHighNode) VirtualFrameGetNode(org.graalvm.compiler.truffle.compiler.nodes.frame.VirtualFrameGetNode) InvokeNode(org.graalvm.compiler.nodes.InvokeNode) GuardedUnsafeLoadNode(org.graalvm.compiler.nodes.extended.GuardedUnsafeLoadNode) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) NeverPartOfCompilationNode(org.graalvm.compiler.truffle.compiler.nodes.asserts.NeverPartOfCompilationNode) PiArrayNode(org.graalvm.compiler.nodes.PiArrayNode) VirtualFrameSetNode(org.graalvm.compiler.truffle.compiler.nodes.frame.VirtualFrameSetNode) IntegerMulHighNode(org.graalvm.compiler.replacements.nodes.arithmetic.IntegerMulHighNode) Node(org.graalvm.compiler.graph.Node) IsCompilationConstantNode(org.graalvm.compiler.truffle.compiler.nodes.IsCompilationConstantNode) BoxNode(org.graalvm.compiler.nodes.extended.BoxNode) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) ResolvedJavaSymbol(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol) NeverPartOfCompilationNode(org.graalvm.compiler.truffle.compiler.nodes.asserts.NeverPartOfCompilationNode) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

NeverPartOfCompilationNode (org.graalvm.compiler.truffle.compiler.nodes.asserts.NeverPartOfCompilationNode)4 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)3 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)3 ValueNode (org.graalvm.compiler.nodes.ValueNode)3 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)3 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)3 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)3 CallTreeNode (com.oracle.svm.graal.hosted.GraalFeature.CallTreeNode)2 RuntimeBytecodeParser (com.oracle.svm.graal.hosted.GraalFeature.RuntimeBytecodeParser)2 AnalysisField (com.oracle.graal.pointsto.meta.AnalysisField)1 AnalysisMethod (com.oracle.graal.pointsto.meta.AnalysisMethod)1 HostedProviders (com.oracle.graal.pointsto.meta.HostedProviders)1 Alias (com.oracle.svm.core.annotate.Alias)1 Delete (com.oracle.svm.core.annotate.Delete)1 NeverInline (com.oracle.svm.core.annotate.NeverInline)1 RecomputeFieldValue (com.oracle.svm.core.annotate.RecomputeFieldValue)1 Kind (com.oracle.svm.core.annotate.RecomputeFieldValue.Kind)1 TargetClass (com.oracle.svm.core.annotate.TargetClass)1 Deoptimizer (com.oracle.svm.core.deopt.Deoptimizer)1 Heap (com.oracle.svm.core.heap.Heap)1