src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/replacements/AssertionSnippets.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/replacements

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/replacements/AssertionSnippets.java

Print this page




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package org.graalvm.compiler.hotspot.replacements;
  24 
  25 import static org.graalvm.compiler.replacements.SnippetTemplate.DEFAULT_REPLACER;
  26 import static org.graalvm.compiler.replacements.nodes.CStringConstant.cstring;
  27 
  28 import org.graalvm.compiler.api.replacements.Snippet;
  29 import org.graalvm.compiler.api.replacements.Snippet.ConstantParameter;
  30 import org.graalvm.compiler.core.common.spi.ForeignCallDescriptor;

  31 import org.graalvm.compiler.graph.Node.ConstantNodeParameter;
  32 import org.graalvm.compiler.graph.Node.NodeIntrinsic;
  33 import org.graalvm.compiler.hotspot.meta.HotSpotProviders;
  34 import org.graalvm.compiler.hotspot.nodes.StubStartNode;
  35 import org.graalvm.compiler.nodes.StructuredGraph;
  36 import org.graalvm.compiler.nodes.extended.ForeignCallNode;
  37 import org.graalvm.compiler.nodes.spi.LoweringTool;
  38 import org.graalvm.compiler.options.OptionValues;
  39 import org.graalvm.compiler.replacements.SnippetTemplate.AbstractTemplates;
  40 import org.graalvm.compiler.replacements.SnippetTemplate.Arguments;
  41 import org.graalvm.compiler.replacements.SnippetTemplate.SnippetInfo;
  42 import org.graalvm.compiler.replacements.Snippets;
  43 import org.graalvm.compiler.replacements.nodes.AssertionNode;
  44 import org.graalvm.compiler.word.Word;
  45 
  46 import jdk.vm.ci.code.TargetDescription;
  47 
  48 public class AssertionSnippets implements Snippets {
  49 
  50     /**


  58         if (!condition) {
  59             vmMessageC(ASSERTION_VM_MESSAGE_C, true, cstring(message), 0L, 0L, 0L);
  60         }
  61     }
  62 
  63     @Snippet
  64     public static void stubAssertion(boolean condition, @ConstantParameter String message) {
  65         if (!condition) {
  66             vmMessageC(ASSERTION_VM_MESSAGE_C, true, cstring(message), 0L, 0L, 0L);
  67         }
  68     }
  69 
  70     @NodeIntrinsic(ForeignCallNode.class)
  71     static native void vmMessageC(@ConstantNodeParameter ForeignCallDescriptor stubPrintfC, boolean vmError, Word format, long v1, long v2, long v3);
  72 
  73     public static class Templates extends AbstractTemplates {
  74 
  75         private final SnippetInfo assertion = snippet(AssertionSnippets.class, "assertion");
  76         private final SnippetInfo stubAssertion = snippet(AssertionSnippets.class, "stubAssertion");
  77 
  78         public Templates(OptionValues options, HotSpotProviders providers, TargetDescription target) {
  79             super(options, providers, providers.getSnippetReflection(), target);
  80         }
  81 
  82         public void lower(AssertionNode assertionNode, LoweringTool tool) {
  83             StructuredGraph graph = assertionNode.graph();
  84             Arguments args = new Arguments(graph.start() instanceof StubStartNode ? stubAssertion : assertion, graph.getGuardsStage(), tool.getLoweringStage());
  85             args.add("condition", assertionNode.condition());
  86             args.addConst("message", "failed runtime assertion in snippet/stub: " + assertionNode.message() + " (" + graph.method() + ")");
  87 
  88             template(args).instantiate(providers.getMetaAccess(), assertionNode, DEFAULT_REPLACER, args);
  89         }
  90     }
  91 }


  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 package org.graalvm.compiler.hotspot.replacements;
  24 
  25 import static org.graalvm.compiler.replacements.SnippetTemplate.DEFAULT_REPLACER;
  26 import static org.graalvm.compiler.replacements.nodes.CStringConstant.cstring;
  27 
  28 import org.graalvm.compiler.api.replacements.Snippet;
  29 import org.graalvm.compiler.api.replacements.Snippet.ConstantParameter;
  30 import org.graalvm.compiler.core.common.spi.ForeignCallDescriptor;
  31 import org.graalvm.compiler.debug.DebugHandlersFactory;
  32 import org.graalvm.compiler.graph.Node.ConstantNodeParameter;
  33 import org.graalvm.compiler.graph.Node.NodeIntrinsic;
  34 import org.graalvm.compiler.hotspot.meta.HotSpotProviders;
  35 import org.graalvm.compiler.hotspot.nodes.StubStartNode;
  36 import org.graalvm.compiler.nodes.StructuredGraph;
  37 import org.graalvm.compiler.nodes.extended.ForeignCallNode;
  38 import org.graalvm.compiler.nodes.spi.LoweringTool;
  39 import org.graalvm.compiler.options.OptionValues;
  40 import org.graalvm.compiler.replacements.SnippetTemplate.AbstractTemplates;
  41 import org.graalvm.compiler.replacements.SnippetTemplate.Arguments;
  42 import org.graalvm.compiler.replacements.SnippetTemplate.SnippetInfo;
  43 import org.graalvm.compiler.replacements.Snippets;
  44 import org.graalvm.compiler.replacements.nodes.AssertionNode;
  45 import org.graalvm.compiler.word.Word;
  46 
  47 import jdk.vm.ci.code.TargetDescription;
  48 
  49 public class AssertionSnippets implements Snippets {
  50 
  51     /**


  59         if (!condition) {
  60             vmMessageC(ASSERTION_VM_MESSAGE_C, true, cstring(message), 0L, 0L, 0L);
  61         }
  62     }
  63 
  64     @Snippet
  65     public static void stubAssertion(boolean condition, @ConstantParameter String message) {
  66         if (!condition) {
  67             vmMessageC(ASSERTION_VM_MESSAGE_C, true, cstring(message), 0L, 0L, 0L);
  68         }
  69     }
  70 
  71     @NodeIntrinsic(ForeignCallNode.class)
  72     static native void vmMessageC(@ConstantNodeParameter ForeignCallDescriptor stubPrintfC, boolean vmError, Word format, long v1, long v2, long v3);
  73 
  74     public static class Templates extends AbstractTemplates {
  75 
  76         private final SnippetInfo assertion = snippet(AssertionSnippets.class, "assertion");
  77         private final SnippetInfo stubAssertion = snippet(AssertionSnippets.class, "stubAssertion");
  78 
  79         public Templates(OptionValues options, Iterable<DebugHandlersFactory> factories, HotSpotProviders providers, TargetDescription target) {
  80             super(options, factories, providers, providers.getSnippetReflection(), target);
  81         }
  82 
  83         public void lower(AssertionNode assertionNode, LoweringTool tool) {
  84             StructuredGraph graph = assertionNode.graph();
  85             Arguments args = new Arguments(graph.start() instanceof StubStartNode ? stubAssertion : assertion, graph.getGuardsStage(), tool.getLoweringStage());
  86             args.add("condition", assertionNode.condition());
  87             args.addConst("message", "failed runtime assertion in snippet/stub: " + assertionNode.message() + " (" + graph.method() + ")");
  88 
  89             template(assertionNode.getDebug(), args).instantiate(providers.getMetaAccess(), assertionNode, DEFAULT_REPLACER, args);
  90         }
  91     }
  92 }
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.hotspot/src/org/graalvm/compiler/hotspot/replacements/AssertionSnippets.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File