Search in sources :

Example 91 with ResolvedJavaType

use of jdk.vm.ci.meta.ResolvedJavaType 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)

Example 92 with ResolvedJavaType

use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.

the class TruffleGraphBuilderPlugins method registerFrameWithBoxingPlugins.

public static void registerFrameWithBoxingPlugins(InvocationPlugins plugins, MetaAccessProvider metaAccess, boolean canDelayIntrinsification) {
    ResolvedJavaType frameWithBoxingType = getRuntime().resolveType(metaAccess, "org.graalvm.compiler.truffle.runtime.FrameWithBoxing");
    Registration r = new Registration(plugins, new ResolvedJavaSymbol(frameWithBoxingType));
    registerFrameMethods(r);
    registerUnsafeCast(r, canDelayIntrinsification);
}
Also used : Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) ResolvedJavaSymbol(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 93 with ResolvedJavaType

use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.

the class TruffleGraphBuilderPlugins method registerFrameWithoutBoxingPlugins.

public static void registerFrameWithoutBoxingPlugins(InvocationPlugins plugins, MetaAccessProvider metaAccess, boolean canDelayIntrinsification, ConstantReflectionProvider constantReflection, KnownTruffleTypes types) {
    ResolvedJavaType frameWithoutBoxingType = getRuntime().resolveType(metaAccess, "org.graalvm.compiler.truffle.runtime.FrameWithoutBoxing");
    Registration r = new Registration(plugins, new ResolvedJavaSymbol(frameWithoutBoxingType));
    registerFrameMethods(r);
    registerUnsafeCast(r, canDelayIntrinsification);
    registerUnsafeLoadStorePlugins(r, canDelayIntrinsification, null, JavaKind.Int, JavaKind.Long, JavaKind.Float, JavaKind.Double, JavaKind.Object);
    if (TruffleCompilerOptions.getValue(Options.TruffleIntrinsifyFrameAccess)) {
        registerFrameAccessors(r, JavaKind.Object, constantReflection, types);
        registerFrameAccessors(r, JavaKind.Long, constantReflection, types);
        registerFrameAccessors(r, JavaKind.Int, constantReflection, types);
        registerFrameAccessors(r, JavaKind.Double, constantReflection, types);
        registerFrameAccessors(r, JavaKind.Float, constantReflection, types);
        registerFrameAccessors(r, JavaKind.Boolean, constantReflection, types);
        registerFrameAccessors(r, JavaKind.Byte, constantReflection, types);
    }
}
Also used : Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) ResolvedJavaSymbol(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 94 with ResolvedJavaType

use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.

the class HotSpotTruffleRuntime method getTruffleCallBoundaryMethods.

@Override
public synchronized Iterable<ResolvedJavaMethod> getTruffleCallBoundaryMethods() {
    if (truffleCallBoundaryMethods == null) {
        truffleCallBoundaryMethods = new ArrayList<>();
        MetaAccessProvider metaAccess = getMetaAccess();
        ResolvedJavaType type = metaAccess.lookupJavaType(OptimizedCallTarget.class);
        for (ResolvedJavaMethod method : type.getDeclaredMethods()) {
            if (method.getAnnotation(TruffleCallBoundary.class) != null) {
                truffleCallBoundaryMethods.add(method);
            }
        }
    }
    return truffleCallBoundaryMethods;
}
Also used : TruffleCallBoundary(org.graalvm.compiler.truffle.runtime.TruffleCallBoundary) MetaAccessProvider(jdk.vm.ci.meta.MetaAccessProvider) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) HotSpotResolvedJavaMethod(jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 95 with ResolvedJavaType

use of jdk.vm.ci.meta.ResolvedJavaType in project graal by oracle.

the class TruffleCallBoundaryInstrumentation method recordMark.

@Override
public Mark recordMark(Object id) {
    Mark mark = super.recordMark(id);
    if ((int) id == config.MARKID_VERIFIED_ENTRY) {
        ResolvedJavaType optimizedCallTargetType = getRuntime().resolveType(metaAccess, "org.graalvm.compiler.truffle.runtime.hotspot.HotSpotOptimizedCallTarget");
        int installedCodeOffset = getFieldOffset("installedCode", optimizedCallTargetType);
        int entryPointOffset = getFieldOffset("entryPoint", metaAccess.lookupJavaType(InstalledCode.class));
        injectTailCallCode(installedCodeOffset, entryPointOffset);
    }
    return mark;
}
Also used : Mark(jdk.vm.ci.code.site.Mark) InstalledCode(jdk.vm.ci.code.InstalledCode) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Aggregations

ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)161 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)63 ValueNode (org.graalvm.compiler.nodes.ValueNode)60 JavaKind (jdk.vm.ci.meta.JavaKind)25 JavaType (jdk.vm.ci.meta.JavaType)25 MethodCallTargetNode (org.graalvm.compiler.nodes.java.MethodCallTargetNode)19 Stamp (org.graalvm.compiler.core.common.type.Stamp)17 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)17 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)16 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)13 TypeReference (org.graalvm.compiler.core.common.type.TypeReference)13 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)13 Signature (jdk.vm.ci.meta.Signature)11 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)11 LogicNode (org.graalvm.compiler.nodes.LogicNode)11 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)11 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)11 ArrayList (java.util.ArrayList)10 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)10 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)9