< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.replacements/src/org/graalvm/compiler/replacements/ReplacementsImpl.java

Print this page




 416         @SuppressWarnings("try")
 417         protected StructuredGraph buildInitialGraph(DebugContext debug, BytecodeProvider bytecodeProvider, final ResolvedJavaMethod methodToParse, Object[] args) {
 418             // Replacements cannot have optimistic assumptions since they have
 419             // to be valid for the entire run of the VM.
 420             final StructuredGraph graph = new StructuredGraph.Builder(replacements.options, debug).method(methodToParse).build();
 421 
 422             // Replacements are not user code so they do not participate in unsafe access
 423             // tracking
 424             graph.disableUnsafeAccessTracking();
 425 
 426             try (DebugContext.Scope s = debug.scope("buildInitialGraph", graph)) {
 427                 MetaAccessProvider metaAccess = replacements.providers.getMetaAccess();
 428 
 429                 Plugins plugins = new Plugins(replacements.graphBuilderPlugins);
 430                 GraphBuilderConfiguration config = GraphBuilderConfiguration.getSnippetDefault(plugins);
 431                 if (args != null) {
 432                     plugins.prependParameterPlugin(new ConstantBindingParameterPlugin(args, metaAccess, replacements.snippetReflection));
 433                 }
 434 
 435                 IntrinsicContext initialIntrinsicContext = null;
 436                 if (method.getAnnotation(Snippet.class) == null) {

 437                     // Post-parse inlined intrinsic
 438                     initialIntrinsicContext = new IntrinsicContext(substitutedMethod, method, bytecodeProvider, INLINE_AFTER_PARSING);
 439                 } else {
 440                     // Snippet
 441                     ResolvedJavaMethod original = substitutedMethod != null ? substitutedMethod : method;
 442                     initialIntrinsicContext = new IntrinsicContext(original, method, bytecodeProvider, INLINE_AFTER_PARSING);
 443                 }
 444 
 445                 createGraphBuilder(metaAccess, replacements.providers.getStampProvider(), replacements.providers.getConstantReflection(), replacements.providers.getConstantFieldProvider(), config,
 446                                 OptimisticOptimizations.NONE, initialIntrinsicContext).apply(graph);
 447 
 448                 new CanonicalizerPhase().apply(graph, new PhaseContext(replacements.providers));
 449             } catch (Throwable e) {
 450                 throw debug.handle(e);
 451             }
 452             return graph;
 453         }
 454 
 455         protected Instance createGraphBuilder(MetaAccessProvider metaAccess, StampProvider stampProvider, ConstantReflectionProvider constantReflection, ConstantFieldProvider constantFieldProvider,
 456                         GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts, IntrinsicContext initialIntrinsicContext) {
 457             return new GraphBuilderPhase.Instance(metaAccess, stampProvider, constantReflection, constantFieldProvider, graphBuilderConfig, optimisticOpts,
 458                             initialIntrinsicContext);
 459         }
 460     }
 461 
 462     @Override


 416         @SuppressWarnings("try")
 417         protected StructuredGraph buildInitialGraph(DebugContext debug, BytecodeProvider bytecodeProvider, final ResolvedJavaMethod methodToParse, Object[] args) {
 418             // Replacements cannot have optimistic assumptions since they have
 419             // to be valid for the entire run of the VM.
 420             final StructuredGraph graph = new StructuredGraph.Builder(replacements.options, debug).method(methodToParse).build();
 421 
 422             // Replacements are not user code so they do not participate in unsafe access
 423             // tracking
 424             graph.disableUnsafeAccessTracking();
 425 
 426             try (DebugContext.Scope s = debug.scope("buildInitialGraph", graph)) {
 427                 MetaAccessProvider metaAccess = replacements.providers.getMetaAccess();
 428 
 429                 Plugins plugins = new Plugins(replacements.graphBuilderPlugins);
 430                 GraphBuilderConfiguration config = GraphBuilderConfiguration.getSnippetDefault(plugins);
 431                 if (args != null) {
 432                     plugins.prependParameterPlugin(new ConstantBindingParameterPlugin(args, metaAccess, replacements.snippetReflection));
 433                 }
 434 
 435                 IntrinsicContext initialIntrinsicContext = null;
 436                 Snippet snippetAnnotation = method.getAnnotation(Snippet.class);
 437                 if (snippetAnnotation == null) {
 438                     // Post-parse inlined intrinsic
 439                     initialIntrinsicContext = new IntrinsicContext(substitutedMethod, method, bytecodeProvider, INLINE_AFTER_PARSING);
 440                 } else {
 441                     // Snippet
 442                     ResolvedJavaMethod original = substitutedMethod != null ? substitutedMethod : method;
 443                     initialIntrinsicContext = new IntrinsicContext(original, method, bytecodeProvider, INLINE_AFTER_PARSING, snippetAnnotation.allowPartialIntrinsicArgumentMismatch());
 444                 }
 445 
 446                 createGraphBuilder(metaAccess, replacements.providers.getStampProvider(), replacements.providers.getConstantReflection(), replacements.providers.getConstantFieldProvider(), config,
 447                                 OptimisticOptimizations.NONE, initialIntrinsicContext).apply(graph);
 448 
 449                 new CanonicalizerPhase().apply(graph, new PhaseContext(replacements.providers));
 450             } catch (Throwable e) {
 451                 throw debug.handle(e);
 452             }
 453             return graph;
 454         }
 455 
 456         protected Instance createGraphBuilder(MetaAccessProvider metaAccess, StampProvider stampProvider, ConstantReflectionProvider constantReflection, ConstantFieldProvider constantFieldProvider,
 457                         GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts, IntrinsicContext initialIntrinsicContext) {
 458             return new GraphBuilderPhase.Instance(metaAccess, stampProvider, constantReflection, constantFieldProvider, graphBuilderConfig, optimisticOpts,
 459                             initialIntrinsicContext);
 460         }
 461     }
 462 
 463     @Override
< prev index next >