46 import org.graalvm.util.EconomicMap; 47 48 import jdk.vm.ci.code.Architecture; 49 import jdk.vm.ci.meta.ResolvedJavaMethod; 50 51 /** 52 * A graph decoder that provides all necessary encoded graphs on-the-fly (by parsing the methods and 53 * encoding the graphs). 54 */ 55 public class CachingPEGraphDecoder extends PEGraphDecoder { 56 57 protected final Providers providers; 58 protected final GraphBuilderConfiguration graphBuilderConfig; 59 protected final OptimisticOptimizations optimisticOpts; 60 private final AllowAssumptions allowAssumptions; 61 private final EconomicMap<ResolvedJavaMethod, EncodedGraph> graphCache; 62 63 public CachingPEGraphDecoder(Architecture architecture, StructuredGraph graph, Providers providers, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts, 64 AllowAssumptions allowAssumptions, LoopExplosionPlugin loopExplosionPlugin, InvocationPlugins invocationPlugins, InlineInvokePlugin[] inlineInvokePlugins, 65 ParameterPlugin parameterPlugin, 66 NodePlugin[] nodePlugins) { 67 super(architecture, graph, providers.getMetaAccess(), providers.getConstantReflection(), providers.getConstantFieldProvider(), providers.getStampProvider(), loopExplosionPlugin, 68 invocationPlugins, inlineInvokePlugins, parameterPlugin, nodePlugins); 69 70 this.providers = providers; 71 this.graphBuilderConfig = graphBuilderConfig; 72 this.optimisticOpts = optimisticOpts; 73 this.allowAssumptions = allowAssumptions; 74 this.graphCache = EconomicMap.create(); 75 } 76 77 protected GraphBuilderPhase.Instance createGraphBuilderPhaseInstance(IntrinsicContext initialIntrinsicContext) { 78 return new GraphBuilderPhase.Instance(providers.getMetaAccess(), providers.getStampProvider(), providers.getConstantReflection(), providers.getConstantFieldProvider(), graphBuilderConfig, 79 optimisticOpts, initialIntrinsicContext); 80 } 81 82 @SuppressWarnings("try") 83 private EncodedGraph createGraph(ResolvedJavaMethod method, BytecodeProvider intrinsicBytecodeProvider) { 84 StructuredGraph graphToEncode = new StructuredGraph.Builder(options, debug, allowAssumptions).useProfilingInfo(false).method(method).build(); 85 try (DebugContext.Scope scope = debug.scope("createGraph", graphToEncode)) { 86 IntrinsicContext initialIntrinsicContext = intrinsicBytecodeProvider != null ? new IntrinsicContext(method, method, intrinsicBytecodeProvider, INLINE_AFTER_PARSING) : null; 87 GraphBuilderPhase.Instance graphBuilderPhaseInstance = createGraphBuilderPhaseInstance(initialIntrinsicContext); 88 graphBuilderPhaseInstance.apply(graphToEncode); | 46 import org.graalvm.util.EconomicMap; 47 48 import jdk.vm.ci.code.Architecture; 49 import jdk.vm.ci.meta.ResolvedJavaMethod; 50 51 /** 52 * A graph decoder that provides all necessary encoded graphs on-the-fly (by parsing the methods and 53 * encoding the graphs). 54 */ 55 public class CachingPEGraphDecoder extends PEGraphDecoder { 56 57 protected final Providers providers; 58 protected final GraphBuilderConfiguration graphBuilderConfig; 59 protected final OptimisticOptimizations optimisticOpts; 60 private final AllowAssumptions allowAssumptions; 61 private final EconomicMap<ResolvedJavaMethod, EncodedGraph> graphCache; 62 63 public CachingPEGraphDecoder(Architecture architecture, StructuredGraph graph, Providers providers, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts, 64 AllowAssumptions allowAssumptions, LoopExplosionPlugin loopExplosionPlugin, InvocationPlugins invocationPlugins, InlineInvokePlugin[] inlineInvokePlugins, 65 ParameterPlugin parameterPlugin, 66 NodePlugin[] nodePlugins, ResolvedJavaMethod callInlinedMethod) { 67 super(architecture, graph, providers.getMetaAccess(), providers.getConstantReflection(), providers.getConstantFieldProvider(), providers.getStampProvider(), loopExplosionPlugin, 68 invocationPlugins, inlineInvokePlugins, parameterPlugin, nodePlugins, callInlinedMethod); 69 70 this.providers = providers; 71 this.graphBuilderConfig = graphBuilderConfig; 72 this.optimisticOpts = optimisticOpts; 73 this.allowAssumptions = allowAssumptions; 74 this.graphCache = EconomicMap.create(); 75 } 76 77 protected GraphBuilderPhase.Instance createGraphBuilderPhaseInstance(IntrinsicContext initialIntrinsicContext) { 78 return new GraphBuilderPhase.Instance(providers.getMetaAccess(), providers.getStampProvider(), providers.getConstantReflection(), providers.getConstantFieldProvider(), graphBuilderConfig, 79 optimisticOpts, initialIntrinsicContext); 80 } 81 82 @SuppressWarnings("try") 83 private EncodedGraph createGraph(ResolvedJavaMethod method, BytecodeProvider intrinsicBytecodeProvider) { 84 StructuredGraph graphToEncode = new StructuredGraph.Builder(options, debug, allowAssumptions).useProfilingInfo(false).method(method).build(); 85 try (DebugContext.Scope scope = debug.scope("createGraph", graphToEncode)) { 86 IntrinsicContext initialIntrinsicContext = intrinsicBytecodeProvider != null ? new IntrinsicContext(method, method, intrinsicBytecodeProvider, INLINE_AFTER_PARSING) : null; 87 GraphBuilderPhase.Instance graphBuilderPhaseInstance = createGraphBuilderPhaseInstance(initialIntrinsicContext); 88 graphBuilderPhaseInstance.apply(graphToEncode); |