Mercurial > hg > graal-compiler
changeset 16618:0b0726730fbd
add some comments to BitOpNodesTest.java
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Tue, 29 Jul 2014 17:57:29 -0700 |
parents | c164a505fc23 |
children | 2acc00d0322a |
files | graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/BitOpNodesTest.java |
diffstat | 1 files changed, 14 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/BitOpNodesTest.java Tue Jul 29 17:40:22 2014 -0700 +++ b/graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/BitOpNodesTest.java Tue Jul 29 17:57:29 2014 -0700 @@ -187,6 +187,7 @@ @Test public void testScanReverseInt() { + /* This test isn't valid unless the BitScanReverseNode intrinsic is used. */ ValueNode result = parseAndInline("scanReverseIntSnippet", BitScanReverseNode.class); if (result != null) { Assert.assertEquals(StampFactory.forInteger(Kind.Int, 16, 20), result.stamp()); @@ -211,6 +212,7 @@ @Test public void testScanReverseLong() { + /* This test isn't valid unless the BitScanReverseNode intrinsic is used. */ ValueNode result = parseAndInline("scanReverseLongSnippet", BitScanReverseNode.class); if (result != null) { Assert.assertEquals(StampFactory.forInteger(Kind.Int, 48, 64), result.stamp()); @@ -225,6 +227,7 @@ @Test public void testScanReverseLongEmpty() { + /* This test isn't valid unless the BitScanReverseNode intrinsic is used. */ ValueNode result = parseAndInline("scanReverseLongEmptySnippet", BitScanReverseNode.class); if (result != null) { Assert.assertEquals(StampFactory.forInteger(Kind.Int, 24, 64), result.stamp()); @@ -235,7 +238,15 @@ return parseAndInline(name, null); } - private ValueNode parseAndInline(String name, Class<? extends ValueNode> requiredClass) { + /** + * Parse and optimize {@code name}. If {@code expectedClass} is non-null and a node of that type + * isn't found simply return null. Otherwise return the node returned by the graph. + * + * @param name + * @param expectedClass + * @return the returned value or null if {@code expectedClass} is not found in the graph. + */ + private ValueNode parseAndInline(String name, Class<? extends ValueNode> expectedClass) { StructuredGraph graph = parse(name); HighTierContext context = new HighTierContext(getProviders(), new Assumptions(false), null, getDefaultGraphBuilderSuite(), OptimisticOptimizations.NONE); CanonicalizerPhase canonicalizer = new CanonicalizerPhase(true); @@ -243,8 +254,8 @@ new InliningPhase(canonicalizer).apply(graph, context); canonicalizer.apply(graph, context); Assert.assertEquals(1, graph.getNodes(ReturnNode.class).count()); - if (requiredClass != null) { - if (graph.getNodes().filter(requiredClass).count() == 0) { + if (expectedClass != null) { + if (graph.getNodes().filter(expectedClass).count() == 0) { return null; } }