@SuppressWarnings("try") @Override public StructuredGraph getIntrinsicGraph(ResolvedJavaMethod method, CompilationIdentifier compilationId, DebugContext debug) { Bytecode subst = getSubstitutionBytecode(method); if (subst != null) { ResolvedJavaMethod substMethod = subst.getMethod(); assert !substMethod.equals(method); BytecodeProvider bytecodeProvider = subst.getOrigin(); // @formatter:off StructuredGraph graph = new StructuredGraph.Builder(options, debug, StructuredGraph.AllowAssumptions.YES). method(substMethod). compilationId(compilationId). recordInlinedMethods(bytecodeProvider.shouldRecordMethodDependencies()). setIsSubstitution(true). build(); // @formatter:on try (DebugContext.Scope scope = debug.scope("GetIntrinsicGraph", graph)) { Plugins plugins = new Plugins(getGraphBuilderPlugins()); GraphBuilderConfiguration config = GraphBuilderConfiguration.getSnippetDefault(plugins); IntrinsicContext initialReplacementContext = new IntrinsicContext(method, substMethod, bytecodeProvider, ROOT_COMPILATION); new GraphBuilderPhase.Instance(providers.getMetaAccess(), providers.getStampProvider(), providers.getConstantReflection(), providers.getConstantFieldProvider(), config, OptimisticOptimizations.NONE, initialReplacementContext).apply(graph); assert !graph.isFrozen(); return graph; } catch (Throwable e) { debug.handle(e); } } return null; }
/** * Inlines a given invocation to a method. The graph of the inlined method is processed in the * same manner as for snippets and method substitutions. */ public void inline(InvokeNode invoke, String reason, String phase) { ResolvedJavaMethod method = ((MethodCallTargetNode) invoke.callTarget()).targetMethod(); MetaAccessProvider metaAccess = providers.getMetaAccess(); Plugins plugins = new Plugins(graphBuilderPlugins); GraphBuilderConfiguration config = GraphBuilderConfiguration.getSnippetDefault(plugins); StructuredGraph calleeGraph = new StructuredGraph.Builder(invoke.getOptions(), invoke.getDebug()).method(method).trackNodeSourcePosition( invoke.graph().trackNodeSourcePosition()).setIsSubstitution(true).build(); IntrinsicContext initialReplacementContext = new IntrinsicContext(method, method, providers.getReplacements().getDefaultReplacementBytecodeProvider(), INLINE_AFTER_PARSING); GraphBuilderPhase.Instance instance = createGraphBuilderInstance(metaAccess, providers.getStampProvider(), providers.getConstantReflection(), providers.getConstantFieldProvider(), config, OptimisticOptimizations.NONE, initialReplacementContext); instance.apply(calleeGraph); // Remove all frame states from inlinee calleeGraph.clearAllStateAfter(); new DeadCodeEliminationPhase(Optionality.Required).apply(calleeGraph); InliningUtil.inline(invoke, calleeGraph, false, method, reason, phase); }
GraphBuilderConfiguration config = GraphBuilderConfiguration.getSnippetDefault(plugins); if (args != null) { plugins.prependParameterPlugin(new ConstantBindingParameterPlugin(args, metaAccess, replacements.snippetReflection));
graphBuilderPlugins.setClassInitializationPlugin(new NoClassInitializationPlugin()); GraphBuilderConfiguration graphBuilderConfig = GraphBuilderConfiguration.getSnippetDefault(graphBuilderPlugins); GraphBuilderPhase.Instance graphBuilder = new GraphBuilderPhase.Instance(originalProviders.getMetaAccess(), originalProviders.getStampProvider(), originalProviders.getConstantReflection(), originalProviders.getConstantFieldProvider(), graphBuilderConfig, OptimisticOptimizations.NONE, null);