comparison 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
comparison
equal deleted inserted replaced
21082:266eef1c29e0 21083:71af9afd7ff6
29 import com.oracle.graal.hotspot.*; 29 import com.oracle.graal.hotspot.*;
30 import com.oracle.graal.hotspot.bridge.*; 30 import com.oracle.graal.hotspot.bridge.*;
31 import com.oracle.graal.hotspot.phases.*; 31 import com.oracle.graal.hotspot.phases.*;
32 import com.oracle.graal.java.*; 32 import com.oracle.graal.java.*;
33 import com.oracle.graal.lir.phases.*; 33 import com.oracle.graal.lir.phases.*;
34 import com.oracle.graal.nodes.*;
35 import com.oracle.graal.nodes.StructuredGraph.*;
34 import com.oracle.graal.options.*; 36 import com.oracle.graal.options.*;
35 import com.oracle.graal.options.DerivedOptionValue.OptionSupplier; 37 import com.oracle.graal.options.DerivedOptionValue.OptionSupplier;
36 import com.oracle.graal.phases.*; 38 import com.oracle.graal.phases.*;
37 import com.oracle.graal.phases.tiers.*; 39 import com.oracle.graal.phases.tiers.*;
38 40
102 104
103 protected PhaseSuite<HighTierContext> createGraphBuilderSuite(Plugins plugins) { 105 protected PhaseSuite<HighTierContext> createGraphBuilderSuite(Plugins plugins) {
104 PhaseSuite<HighTierContext> suite = new PhaseSuite<>(); 106 PhaseSuite<HighTierContext> suite = new PhaseSuite<>();
105 GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins); 107 GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins);
106 suite.appendPhase(new GraphBuilderPhase(config)); 108 suite.appendPhase(new GraphBuilderPhase(config));
109 assert appendGraphEncoderTest(suite);
107 return suite; 110 return suite;
111 }
112
113 /**
114 * When assertions are enabled, we encode and decode every parsed graph, to ensure that the
115 * encoding and decoding process work correctly. The decoding performs canonicalization during
116 * decoding, so the decoded graph can be different than the encoded graph - we cannot check them
117 * for equality here. However, the encoder {@link GraphEncoder#verifyEncoding verifies the
118 * encoding itself}, i.e., performs a decoding without canoncialization and checks the graphs
119 * for equality.
120 */
121 private boolean appendGraphEncoderTest(PhaseSuite<HighTierContext> suite) {
122 suite.appendPhase(new BasePhase<HighTierContext>() {
123 @Override
124 protected void run(StructuredGraph graph, HighTierContext context) {
125 EncodedGraph encodedGraph = GraphEncoder.encodeSingleGraph(graph, runtime.getTarget().arch);
126
127 SimplifyingGraphDecoder graphDecoder = new SimplifyingGraphDecoder(context.getMetaAccess(), context.getConstantReflection(), context.getStampProvider(), !ImmutableCode.getValue(),
128 runtime.getTarget().arch);
129 StructuredGraph targetGraph = new StructuredGraph(graph.method(), AllowAssumptions.YES);
130 graphDecoder.decode(targetGraph, encodedGraph);
131 }
132 });
133 return true;
108 } 134 }
109 135
110 /** 136 /**
111 * Modifies the {@link GraphBuilderConfiguration} to build extra 137 * Modifies the {@link GraphBuilderConfiguration} to build extra
112 * {@linkplain DebugInfoMode#Simple debug info} if the VM 138 * {@linkplain DebugInfoMode#Simple debug info} if the VM