Search in sources :

Example 46 with Snippet

use of org.graalvm.compiler.api.replacements.Snippet in project graal by oracle.

the class AllocationSnippets method formatObjectSnippet.

@Snippet
public static Object formatObjectSnippet(Word memory, DynamicHub hub, boolean rememberedSet) {
    DynamicHub hubNonNull = (DynamicHub) PiNode.piCastNonNull(hub, SnippetAnchorNode.anchor());
    UnsignedWord size = LayoutEncoding.getInstanceSize(hubNonNull.getLayoutEncoding());
    return formatObjectImpl(memory, hubNonNull, size, false, true, rememberedSet);
}
Also used : UnsignedWord(org.graalvm.word.UnsignedWord) DynamicHub(com.oracle.svm.core.hub.DynamicHub) Snippet(org.graalvm.compiler.api.replacements.Snippet)

Example 47 with Snippet

use of org.graalvm.compiler.api.replacements.Snippet in project graal by oracle.

the class DefaultJavaLoweringProvider method lowerUnaryMath.

private void lowerUnaryMath(UnaryMathIntrinsicNode math, LoweringTool tool) {
    if (tool.getLoweringStage() == LoweringTool.StandardLoweringStage.HIGH_TIER) {
        return;
    }
    ResolvedJavaMethod method = math.graph().method();
    if (method != null) {
        if (method.getAnnotation(Snippet.class) != null) {
            /*
                 * In the context of the snippet use the LIR lowering instead of the Node lowering.
                 */
            return;
        }
        if (method.getName().equalsIgnoreCase(math.getOperation().name()) && tool.getMetaAccess().lookupJavaType(Math.class).equals(method.getDeclaringClass())) {
            /*
                 * A root compilation of the intrinsic method should emit the full assembly
                 * implementation.
                 */
            return;
        }
    }
    ForeignCallDescriptor foreignCall = toForeignCall(math.getOperation());
    if (foreignCall != null) {
        StructuredGraph graph = math.graph();
        ForeignCallNode call = math.graph().add(new ForeignCallNode(foreignCalls, foreignCall, math.getValue()));
        graph.addAfterFixed(tool.lastFixedNode(), call);
        math.replaceAtUsages(call);
    }
}
Also used : ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) ForeignCallDescriptor(org.graalvm.compiler.core.common.spi.ForeignCallDescriptor) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) Snippet(org.graalvm.compiler.api.replacements.Snippet) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

Snippet (org.graalvm.compiler.api.replacements.Snippet)47 Word (org.graalvm.compiler.word.Word)22 HotSpotReplacementsUtil.registerAsWord (org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord)17 Pointer (org.graalvm.word.Pointer)14 UnsignedWord (org.graalvm.word.UnsignedWord)12 KlassPointer (org.graalvm.compiler.hotspot.word.KlassPointer)9 GuardingNode (org.graalvm.compiler.nodes.extended.GuardingNode)6 DynamicHub (com.oracle.svm.core.hub.DynamicHub)4 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)4 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)3 Safepoint (com.oracle.svm.core.thread.Safepoint)2 ForeignCallDescriptor (org.graalvm.compiler.core.common.spi.ForeignCallDescriptor)2 DebugContext (org.graalvm.compiler.debug.DebugContext)2 ForeignCallNode (org.graalvm.compiler.nodes.extended.ForeignCallNode)2 WordBase (org.graalvm.word.WordBase)2 KnownIntrinsics.readCallerStackPointer (com.oracle.svm.core.snippets.KnownIntrinsics.readCallerStackPointer)1 JavaFrameAnchor (com.oracle.svm.core.stack.JavaFrameAnchor)1 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)1 HotSpotReplacementsUtil.arrayPrototypeMarkWord (org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.arrayPrototypeMarkWord)1 HotSpotReplacementsUtil.tlabIntArrayMarkWord (org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.tlabIntArrayMarkWord)1