< 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




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




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


< prev index next >