< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/tutorial/StaticAnalysis.java

Print this page




 236             if (!processed) {
 237                 /* We want to process a method only once. */
 238                 processed = true;
 239 
 240                 /*
 241                  * Build the Graal graph for the method using the bytecode parser provided by Graal.
 242                  */
 243 
 244                 StructuredGraph graph = new StructuredGraph(method, AllowAssumptions.NO, INVALID_COMPILATION_ID);
 245                 /*
 246                  * Support for graph dumping, IGV uses this information to show the method name of a
 247                  * graph.
 248                  */
 249                 try (Scope scope = Debug.scope("graph building", graph)) {
 250                     /*
 251                      * We want all types to be resolved by the graph builder, i.e., we want classes
 252                      * referenced by the bytecodes to be loaded and initialized. Since we do not run
 253                      * the code before static analysis, the classes would otherwise be not loaded
 254                      * yet and the bytecode parser would only create a graph.
 255                      */
 256                     Plugins plugins = new Plugins(new InvocationPlugins(metaAccess));
 257                     GraphBuilderConfiguration graphBuilderConfig = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true);
 258                     /*
 259                      * For simplicity, we ignore all exception handling during the static analysis.
 260                      * This is a constraint of this example code, a real static analysis needs to
 261                      * handle the Graal nodes for throwing and handling exceptions.
 262                      */
 263                     graphBuilderConfig = graphBuilderConfig.withBytecodeExceptionMode(BytecodeExceptionMode.OmitAll);
 264                     /*
 265                      * We do not want Graal to perform any speculative optimistic optimizations,
 266                      * i.e., we do not want to use profiling information. Since we do not run the
 267                      * code before static analysis, the profiling information is empty and therefore
 268                      * wrong.
 269                      */
 270                     OptimisticOptimizations optimisticOpts = OptimisticOptimizations.NONE;
 271 
 272                     GraphBuilderPhase.Instance graphBuilder = new GraphBuilderPhase.Instance(metaAccess, stampProvider, null, null, graphBuilderConfig, optimisticOpts, null);
 273                     graphBuilder.apply(graph);
 274                 } catch (Throwable ex) {
 275                     Debug.handle(ex);
 276                 }




 236             if (!processed) {
 237                 /* We want to process a method only once. */
 238                 processed = true;
 239 
 240                 /*
 241                  * Build the Graal graph for the method using the bytecode parser provided by Graal.
 242                  */
 243 
 244                 StructuredGraph graph = new StructuredGraph(method, AllowAssumptions.NO, INVALID_COMPILATION_ID);
 245                 /*
 246                  * Support for graph dumping, IGV uses this information to show the method name of a
 247                  * graph.
 248                  */
 249                 try (Scope scope = Debug.scope("graph building", graph)) {
 250                     /*
 251                      * We want all types to be resolved by the graph builder, i.e., we want classes
 252                      * referenced by the bytecodes to be loaded and initialized. Since we do not run
 253                      * the code before static analysis, the classes would otherwise be not loaded
 254                      * yet and the bytecode parser would only create a graph.
 255                      */
 256                     Plugins plugins = new Plugins(new InvocationPlugins());
 257                     GraphBuilderConfiguration graphBuilderConfig = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true);
 258                     /*
 259                      * For simplicity, we ignore all exception handling during the static analysis.
 260                      * This is a constraint of this example code, a real static analysis needs to
 261                      * handle the Graal nodes for throwing and handling exceptions.
 262                      */
 263                     graphBuilderConfig = graphBuilderConfig.withBytecodeExceptionMode(BytecodeExceptionMode.OmitAll);
 264                     /*
 265                      * We do not want Graal to perform any speculative optimistic optimizations,
 266                      * i.e., we do not want to use profiling information. Since we do not run the
 267                      * code before static analysis, the profiling information is empty and therefore
 268                      * wrong.
 269                      */
 270                     OptimisticOptimizations optimisticOpts = OptimisticOptimizations.NONE;
 271 
 272                     GraphBuilderPhase.Instance graphBuilder = new GraphBuilderPhase.Instance(metaAccess, stampProvider, null, null, graphBuilderConfig, optimisticOpts, null);
 273                     graphBuilder.apply(graph);
 274                 } catch (Throwable ex) {
 275                     Debug.handle(ex);
 276                 }


< prev index next >