Search in sources :

Example 16 with GraphBuilderContext

use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.

the class CGlobalDataFeature method registerInvocationPlugins.

@Override
public void registerInvocationPlugins(Providers providers, SnippetReflectionProvider snippetReflection, InvocationPlugins invocationPlugins, boolean hosted) {
    Registration r = new Registration(invocationPlugins, CGlobalData.class);
    r.register1("get", Receiver.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            VMError.guarantee(receiver.get().isConstant(), "Accessed CGlobalData is not a compile-time constant: " + b.getMethod().asStackTraceElement(b.bci()));
            CGlobalDataImpl<?> data = (CGlobalDataImpl<?>) SubstrateObjectConstant.asObject(receiver.get().asConstant());
            CGlobalDataInfo info = CGlobalDataFeature.this.map.get(data);
            b.addPush(targetMethod.getSignature().getReturnKind(), new CGlobalDataLoadAddressNode(info));
            return true;
        }
    });
}
Also used : CGlobalDataImpl(com.oracle.svm.core.c.CGlobalDataImpl) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) CGlobalDataInfo(com.oracle.svm.core.graal.code.CGlobalDataInfo) CGlobalDataLoadAddressNode(com.oracle.svm.core.graal.nodes.CGlobalDataLoadAddressNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 17 with GraphBuilderContext

use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.

the class PEGraphDecoder method tryInline.

protected LoopScope tryInline(PEMethodScope methodScope, LoopScope loopScope, InvokeData invokeData, MethodCallTargetNode callTarget) {
    if (!callTarget.invokeKind().isDirect()) {
        return null;
    }
    ResolvedJavaMethod targetMethod = callTarget.targetMethod();
    if (targetMethod.hasNeverInlineDirective()) {
        return null;
    }
    ValueNode[] arguments = callTarget.arguments().toArray(new ValueNode[0]);
    GraphBuilderContext graphBuilderContext = new PENonAppendGraphBuilderContext(methodScope, invokeData.invoke);
    for (InlineInvokePlugin plugin : inlineInvokePlugins) {
        InlineInfo inlineInfo = plugin.shouldInlineInvoke(graphBuilderContext, targetMethod, arguments);
        if (inlineInfo != null) {
            if (inlineInfo.getMethodToInline() == null) {
                return null;
            } else {
                return doInline(methodScope, loopScope, invokeData, inlineInfo, arguments);
            }
        }
    }
    return null;
}
Also used : GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) ValueNode(org.graalvm.compiler.nodes.ValueNode) InlineInfo(org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin.InlineInfo) InlineInvokePlugin(org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 18 with GraphBuilderContext

use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.

the class SPARCGraphBuilderPlugins method registerIntegerLongPlugins.

private static void registerIntegerLongPlugins(InvocationPlugins plugins, Class<?> substituteDeclaringClass, JavaKind kind, BytecodeProvider bytecodeProvider) {
    Class<?> declaringClass = kind.toBoxedJavaClass();
    Class<?> type = kind.toJavaClass();
    Registration r = new Registration(plugins, declaringClass, bytecodeProvider);
    r.registerMethodSubstitution(substituteDeclaringClass, "numberOfLeadingZeros", type);
    r.registerMethodSubstitution(substituteDeclaringClass, "numberOfTrailingZeros", type);
    r.register1("bitCount", type, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
            b.push(JavaKind.Int, b.append(new BitCountNode(value).canonical(null)));
            return true;
        }
    });
}
Also used : GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) BitCountNode(org.graalvm.compiler.replacements.nodes.BitCountNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 19 with GraphBuilderContext

use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.

the class SPARCGraphBuilderPlugins method registerMathPlugins.

private static void registerMathPlugins(InvocationPlugins plugins) {
    Registration r = new Registration(plugins, Math.class);
    registerUnaryMath(r, "sin", SIN);
    registerUnaryMath(r, "cos", COS);
    registerUnaryMath(r, "tan", TAN);
    registerUnaryMath(r, "exp", EXP);
    registerUnaryMath(r, "log", LOG);
    registerUnaryMath(r, "log10", LOG10);
    r.register2("pow", Double.TYPE, Double.TYPE, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode x, ValueNode y) {
            b.push(JavaKind.Double, b.append(BinaryMathIntrinsicNode.create(x, y, BinaryMathIntrinsicNode.BinaryOperation.POW)));
            return true;
        }
    });
}
Also used : 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 20 with GraphBuilderContext

use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext in project graal by oracle.

the class ArrayStoreBytecodeExceptionTest method registerInvocationPlugins.

@Override
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
    invocationPlugins.register(new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode obj) {
            return throwBytecodeException(b, ArrayStoreException.class, obj);
        }
    }, Exceptions.class, "throwArrayStore", Object.class);
    super.registerInvocationPlugins(invocationPlugins);
}
Also used : GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)88 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)86 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)83 ValueNode (org.graalvm.compiler.nodes.ValueNode)76 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)66 Receiver (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver)57 ConvertUnknownValueNode (com.oracle.graal.pointsto.nodes.ConvertUnknownValueNode)13 StackValueNode (com.oracle.svm.core.graal.stackvalue.StackValueNode)13 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)10 LogicNode (org.graalvm.compiler.nodes.LogicNode)10 JavaKind (jdk.vm.ci.meta.JavaKind)9 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)8 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)7 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)7 JavaConstant (jdk.vm.ci.meta.JavaConstant)6 ConditionalNode (org.graalvm.compiler.nodes.calc.ConditionalNode)6 ResolvedJavaSymbol (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol)6 Stamp (org.graalvm.compiler.core.common.type.Stamp)4 GetClassNode (org.graalvm.compiler.nodes.extended.GetClassNode)4 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)4