Skip to content

Commit

Permalink
VM_MESSAGE_C should be LEAF
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrodriguez committed Aug 8, 2023
1 parent bc0153a commit 9a486f7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
import static org.graalvm.compiler.hotspot.meta.HotSpotForeignCallDescriptor.Transition.LEAF;
import static org.graalvm.compiler.hotspot.meta.HotSpotForeignCallDescriptor.Transition.LEAF_NO_VZERO;
import static org.graalvm.compiler.hotspot.meta.HotSpotForeignCallDescriptor.Transition.SAFEPOINT;
import static org.graalvm.compiler.hotspot.replacements.AssertionSnippets.ASSERTION_VM_MESSAGE_C;
import static org.graalvm.compiler.hotspot.replacements.HotSpotAllocationSnippets.DYNAMIC_NEW_INSTANCE;
import static org.graalvm.compiler.hotspot.replacements.HotSpotAllocationSnippets.DYNAMIC_NEW_INSTANCE_OR_NULL;
import static org.graalvm.compiler.hotspot.replacements.HotSpotG1WriteBarrierSnippets.G1WBPOSTCALL;
Expand Down Expand Up @@ -463,12 +462,7 @@ public void initialize(HotSpotProviders providers, OptionValues options) {

CreateExceptionStub.registerForeignCalls(c, this);

/*
* This message call is registered twice, where the second one must only be used for calls
* that do not return, i.e., that exit the VM.
*/
registerForeignCall(VM_MESSAGE_C, c.vmMessageAddress, NativeCall);
registerForeignCall(ASSERTION_VM_MESSAGE_C, c.vmMessageAddress, NativeCall);

linkForeignCall(options, providers, NEW_INSTANCE, c.newInstanceAddress, PREPEND_THREAD);
linkForeignCall(options, providers, NEW_ARRAY, c.newArrayAddress, PREPEND_THREAD);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@

import static org.graalvm.compiler.api.directives.GraalDirectives.SLOWPATH_PROBABILITY;
import static org.graalvm.compiler.api.directives.GraalDirectives.injectBranchProbability;
import static org.graalvm.compiler.hotspot.meta.HotSpotForeignCallDescriptor.Reexecutability.REEXECUTABLE;
import static org.graalvm.compiler.hotspot.meta.HotSpotForeignCallDescriptor.Transition.LEAF;
import static org.graalvm.compiler.hotspot.meta.HotSpotForeignCallsProviderImpl.NO_LOCATIONS;
import static org.graalvm.compiler.hotspot.stubs.StubUtil.VM_MESSAGE_C;
import static org.graalvm.compiler.replacements.SnippetTemplate.DEFAULT_REPLACER;

import org.graalvm.compiler.api.replacements.Snippet;
Expand All @@ -37,7 +35,6 @@
import org.graalvm.compiler.core.common.type.StampFactory;
import org.graalvm.compiler.graph.Node.ConstantNodeParameter;
import org.graalvm.compiler.graph.Node.NodeIntrinsic;
import org.graalvm.compiler.hotspot.meta.HotSpotForeignCallDescriptor;
import org.graalvm.compiler.hotspot.meta.HotSpotProviders;
import org.graalvm.compiler.hotspot.nodes.StubForeignCallNode;
import org.graalvm.compiler.hotspot.nodes.StubStartNode;
Expand All @@ -56,24 +53,17 @@

public class AssertionSnippets implements Snippets {

/**
* This call can only be used with true for the "vmError" parameter, so that it can be
* configured to be a leaf method.
*/
public static final HotSpotForeignCallDescriptor ASSERTION_VM_MESSAGE_C = new HotSpotForeignCallDescriptor(LEAF, REEXECUTABLE, NO_LOCATIONS, "assertionVmMessageC", void.class, boolean.class,
Word.class, long.class, long.class, long.class);

@Snippet
public static void assertion(boolean condition, @ConstantParameter Word message, long l1, long l2) {
if (injectBranchProbability(SLOWPATH_PROBABILITY, !condition)) {
vmMessageC(ASSERTION_VM_MESSAGE_C, true, message, l1, l2, 0L);
vmMessageC(VM_MESSAGE_C, true, message, l1, l2, 0L);
}
}

@Snippet
public static void stubAssertion(boolean condition, @ConstantParameter Word message, long l1, long l2) {
if (injectBranchProbability(SLOWPATH_PROBABILITY, !condition)) {
vmMessageStub(ASSERTION_VM_MESSAGE_C, true, message, l1, l2, 0L);
vmMessageStub(VM_MESSAGE_C, true, message, l1, l2, 0L);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import static org.graalvm.compiler.hotspot.replacements.HotSpotReplacementsUtil.registerAsWord;
import static org.graalvm.compiler.hotspot.replacements.HotspotSnippetsOptions.ProfileAllocations;
import static org.graalvm.compiler.hotspot.replacements.HotspotSnippetsOptions.ProfileAllocationsContext;
import static org.graalvm.compiler.hotspot.stubs.StubUtil.VM_MESSAGE_C;
import static org.graalvm.compiler.nodes.PiArrayNode.piArrayCastToSnippetReplaceeStamp;
import static org.graalvm.compiler.nodes.PiNode.piCastToSnippetReplaceeStamp;
import static org.graalvm.compiler.nodes.extended.BranchProbabilityNode.DEOPT_PROBABILITY;
Expand Down Expand Up @@ -290,7 +291,7 @@ private void verifyHeap() {
if (!topValue.equal(WordFactory.zero())) {
Word topValueContents = topValue.readWord(0, MARK_WORD_LOCATION);
if (topValueContents.equal(WordFactory.zero())) {
AssertionSnippets.vmMessageC(AssertionSnippets.ASSERTION_VM_MESSAGE_C, true, cstring("overzeroing of TLAB detected"), 0L, 0L, 0L);
AssertionSnippets.vmMessageC(VM_MESSAGE_C, true, cstring("overzeroing of TLAB detected"), 0L, 0L, 0L);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
package org.graalvm.compiler.hotspot.stubs;

import static org.graalvm.compiler.hotspot.meta.HotSpotForeignCallDescriptor.Reexecutability.REEXECUTABLE;
import static org.graalvm.compiler.hotspot.meta.HotSpotForeignCallDescriptor.Transition.SAFEPOINT;
import static org.graalvm.compiler.hotspot.meta.HotSpotForeignCallDescriptor.Transition.LEAF;
import static org.graalvm.compiler.replacements.nodes.CStringConstant.cstring;

import java.lang.reflect.Method;
Expand Down Expand Up @@ -54,7 +54,7 @@
*/
public class StubUtil {

public static final HotSpotForeignCallDescriptor VM_MESSAGE_C = newDescriptor(SAFEPOINT, REEXECUTABLE, null, StubUtil.class, "vmMessageC", void.class, boolean.class, Word.class, long.class,
public static final HotSpotForeignCallDescriptor VM_MESSAGE_C = newDescriptor(LEAF, REEXECUTABLE, null, StubUtil.class, "vmMessageC", void.class, boolean.class, Word.class, long.class,
long.class, long.class);

public static HotSpotForeignCallDescriptor newDescriptor(HotSpotForeignCallDescriptor.Transition safepoint, HotSpotForeignCallDescriptor.Reexecutability reexecutable,
Expand Down

0 comments on commit 9a486f7

Please sign in to comment.