Mercurial > hg > truffle
diff graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java @ 21083:71af9afd7ff6
Test the GraphDecoder by encoding and decoding every graph after parsing; fix bugs found by that testing
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Wed, 22 Apr 2015 13:05:36 -0700 |
parents | 59e8737c06fd |
children | 0457430979a5 |
line wrap: on
line diff
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java Wed Apr 22 11:38:25 2015 -0700 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotSuitesProvider.java Wed Apr 22 13:05:36 2015 -0700 @@ -31,6 +31,8 @@ import com.oracle.graal.hotspot.phases.*; import com.oracle.graal.java.*; import com.oracle.graal.lir.phases.*; +import com.oracle.graal.nodes.*; +import com.oracle.graal.nodes.StructuredGraph.*; import com.oracle.graal.options.*; import com.oracle.graal.options.DerivedOptionValue.OptionSupplier; import com.oracle.graal.phases.*; @@ -104,10 +106,34 @@ PhaseSuite<HighTierContext> suite = new PhaseSuite<>(); GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins); suite.appendPhase(new GraphBuilderPhase(config)); + assert appendGraphEncoderTest(suite); return suite; } /** + * When assertions are enabled, we encode and decode every parsed graph, to ensure that the + * encoding and decoding process work correctly. The decoding performs canonicalization during + * decoding, so the decoded graph can be different than the encoded graph - we cannot check them + * for equality here. However, the encoder {@link GraphEncoder#verifyEncoding verifies the + * encoding itself}, i.e., performs a decoding without canoncialization and checks the graphs + * for equality. + */ + private boolean appendGraphEncoderTest(PhaseSuite<HighTierContext> suite) { + suite.appendPhase(new BasePhase<HighTierContext>() { + @Override + protected void run(StructuredGraph graph, HighTierContext context) { + EncodedGraph encodedGraph = GraphEncoder.encodeSingleGraph(graph, runtime.getTarget().arch); + + SimplifyingGraphDecoder graphDecoder = new SimplifyingGraphDecoder(context.getMetaAccess(), context.getConstantReflection(), context.getStampProvider(), !ImmutableCode.getValue(), + runtime.getTarget().arch); + StructuredGraph targetGraph = new StructuredGraph(graph.method(), AllowAssumptions.YES); + graphDecoder.decode(targetGraph, encodedGraph); + } + }); + return true; + } + + /** * Modifies the {@link GraphBuilderConfiguration} to build extra * {@linkplain DebugInfoMode#Simple debug info} if the VM * {@linkplain CompilerToVM#shouldDebugNonSafepoints() requests} it.