< prev index next >

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

Print this page




  89 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext;
  90 import org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin;
  91 import org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin.InlineInfo;
  92 import org.graalvm.compiler.nodes.graphbuilderconf.IntrinsicContext;
  93 import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin;
  94 import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;
  95 import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.InvocationPluginReceiver;
  96 import org.graalvm.compiler.nodes.graphbuilderconf.LoopExplosionPlugin;
  97 import org.graalvm.compiler.nodes.graphbuilderconf.LoopExplosionPlugin.LoopExplosionKind;
  98 import org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin;
  99 import org.graalvm.compiler.nodes.graphbuilderconf.ParameterPlugin;
 100 import org.graalvm.compiler.nodes.java.LoadFieldNode;
 101 import org.graalvm.compiler.nodes.java.LoadIndexedNode;
 102 import org.graalvm.compiler.nodes.java.MethodCallTargetNode;
 103 import org.graalvm.compiler.nodes.java.MonitorIdNode;
 104 import org.graalvm.compiler.nodes.java.NewArrayNode;
 105 import org.graalvm.compiler.nodes.java.NewInstanceNode;
 106 import org.graalvm.compiler.nodes.java.NewMultiArrayNode;
 107 import org.graalvm.compiler.nodes.java.StoreFieldNode;
 108 import org.graalvm.compiler.nodes.java.StoreIndexedNode;


 109 import org.graalvm.compiler.nodes.spi.StampProvider;
 110 import org.graalvm.compiler.nodes.type.StampTool;
 111 import org.graalvm.compiler.nodes.util.GraphUtil;
 112 import org.graalvm.compiler.options.Option;
 113 import org.graalvm.compiler.options.OptionKey;
 114 import org.graalvm.compiler.options.OptionType;
 115 import org.graalvm.compiler.options.OptionValues;
 116 import org.graalvm.compiler.phases.common.inlining.InliningUtil;
 117 
 118 import jdk.vm.ci.code.Architecture;
 119 import jdk.vm.ci.code.BailoutException;
 120 import jdk.vm.ci.code.BytecodeFrame;
 121 import jdk.vm.ci.meta.Assumptions;
 122 import jdk.vm.ci.meta.ConstantReflectionProvider;
 123 import jdk.vm.ci.meta.DeoptimizationAction;
 124 import jdk.vm.ci.meta.DeoptimizationReason;
 125 import jdk.vm.ci.meta.JavaConstant;
 126 import jdk.vm.ci.meta.JavaKind;
 127 import jdk.vm.ci.meta.JavaType;
 128 import jdk.vm.ci.meta.MetaAccessProvider;


 292          * have been processed.
 293          *
 294          * This is how SVM handles snippets. They are parsed with plugins disabled and then encoded
 295          * and stored in the image. When the snippet is needed at runtime the graph is decoded and
 296          * the plugins are run during the decoding process. If they aren't handled at this point
 297          * then they will never be handled.
 298          */
 299         @Override
 300         public boolean canDeferPlugin(GeneratedInvocationPlugin plugin) {
 301             return plugin.getSource().equals(Fold.class) || plugin.getSource().equals(Node.NodeIntrinsic.class);
 302         }
 303 
 304         @Override
 305         public BailoutException bailout(String string) {
 306             BailoutException bailout = new PermanentBailoutException(string);
 307             throw GraphUtil.createBailoutException(string, bailout, GraphUtil.approxSourceStackTraceElement(methodScope.getCallerBytecodePosition()));
 308         }
 309 
 310         @Override
 311         public StampProvider getStampProvider() {
 312             return stampProvider;
 313         }
 314 
 315         @Override
 316         public MetaAccessProvider getMetaAccess() {
 317             return metaAccess;
 318         }
 319 
 320         @Override
 321         public ConstantReflectionProvider getConstantReflection() {
 322             return constantReflection;
 323         }
 324 
 325         @Override
 326         public ConstantFieldProvider getConstantFieldProvider() {
 327             return constantFieldProvider;





 328         }
 329 
 330         @Override
 331         public StructuredGraph getGraph() {
 332             return graph;
 333         }
 334 
 335         @Override
 336         public int getDepth() {
 337             return methodScope.inliningDepth;
 338         }
 339 
 340         @Override
 341         public IntrinsicContext getIntrinsic() {
 342             return null;
 343         }
 344 
 345         @Override
 346         public <T extends ValueNode> T append(T value) {
 347             throw unimplemented();


 548         @Override
 549         public boolean equals(Object obj) {
 550             if (obj instanceof SpecialCallTargetCacheKey) {
 551                 SpecialCallTargetCacheKey key = (SpecialCallTargetCacheKey) obj;
 552                 return key.invokeKind.equals(this.invokeKind) && key.targetMethod.equals(this.targetMethod) && key.contextType.equals(this.contextType) && key.receiverStamp.equals(this.receiverStamp);
 553             }
 554             return false;
 555         }
 556     }
 557 
 558     private final LoopExplosionPlugin loopExplosionPlugin;
 559     private final InvocationPlugins invocationPlugins;
 560     private final InlineInvokePlugin[] inlineInvokePlugins;
 561     private final ParameterPlugin parameterPlugin;
 562     private final NodePlugin[] nodePlugins;
 563     private final EconomicMap<SpecialCallTargetCacheKey, Object> specialCallTargetCache;
 564     private final EconomicMap<ResolvedJavaMethod, Object> invocationPluginCache;
 565     private final ResolvedJavaMethod callInlinedMethod;
 566     protected final SourceLanguagePositionProvider sourceLanguagePositionProvider;
 567 
 568     public PEGraphDecoder(Architecture architecture, StructuredGraph graph, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, ConstantFieldProvider constantFieldProvider,
 569                     StampProvider stampProvider, LoopExplosionPlugin loopExplosionPlugin, InvocationPlugins invocationPlugins, InlineInvokePlugin[] inlineInvokePlugins,
 570                     ParameterPlugin parameterPlugin,
 571                     NodePlugin[] nodePlugins, ResolvedJavaMethod callInlinedMethod, SourceLanguagePositionProvider sourceLanguagePositionProvider) {
 572         super(architecture, graph, metaAccess, constantReflection, constantFieldProvider, stampProvider, true);
 573         this.loopExplosionPlugin = loopExplosionPlugin;
 574         this.invocationPlugins = invocationPlugins;
 575         this.inlineInvokePlugins = inlineInvokePlugins;
 576         this.parameterPlugin = parameterPlugin;
 577         this.nodePlugins = nodePlugins;
 578         this.specialCallTargetCache = EconomicMap.create(Equivalence.DEFAULT);
 579         this.invocationPluginCache = EconomicMap.create(Equivalence.DEFAULT);
 580         this.callInlinedMethod = callInlinedMethod;
 581         this.sourceLanguagePositionProvider = sourceLanguagePositionProvider;
 582     }
 583 
 584     protected static LoopExplosionKind loopExplosionKind(ResolvedJavaMethod method, LoopExplosionPlugin loopExplosionPlugin) {
 585         if (loopExplosionPlugin == null) {
 586             return LoopExplosionKind.NONE;
 587         } else {
 588             return loopExplosionPlugin.loopExplosionKind(method);
 589         }
 590     }
 591 
 592     @SuppressWarnings("try")




  89 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext;
  90 import org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin;
  91 import org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin.InlineInfo;
  92 import org.graalvm.compiler.nodes.graphbuilderconf.IntrinsicContext;
  93 import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin;
  94 import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins;
  95 import org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.InvocationPluginReceiver;
  96 import org.graalvm.compiler.nodes.graphbuilderconf.LoopExplosionPlugin;
  97 import org.graalvm.compiler.nodes.graphbuilderconf.LoopExplosionPlugin.LoopExplosionKind;
  98 import org.graalvm.compiler.nodes.graphbuilderconf.NodePlugin;
  99 import org.graalvm.compiler.nodes.graphbuilderconf.ParameterPlugin;
 100 import org.graalvm.compiler.nodes.java.LoadFieldNode;
 101 import org.graalvm.compiler.nodes.java.LoadIndexedNode;
 102 import org.graalvm.compiler.nodes.java.MethodCallTargetNode;
 103 import org.graalvm.compiler.nodes.java.MonitorIdNode;
 104 import org.graalvm.compiler.nodes.java.NewArrayNode;
 105 import org.graalvm.compiler.nodes.java.NewInstanceNode;
 106 import org.graalvm.compiler.nodes.java.NewMultiArrayNode;
 107 import org.graalvm.compiler.nodes.java.StoreFieldNode;
 108 import org.graalvm.compiler.nodes.java.StoreIndexedNode;
 109 import org.graalvm.compiler.nodes.spi.CoreProviders;
 110 import org.graalvm.compiler.nodes.spi.Replacements;
 111 import org.graalvm.compiler.nodes.spi.StampProvider;
 112 import org.graalvm.compiler.nodes.type.StampTool;
 113 import org.graalvm.compiler.nodes.util.GraphUtil;
 114 import org.graalvm.compiler.options.Option;
 115 import org.graalvm.compiler.options.OptionKey;
 116 import org.graalvm.compiler.options.OptionType;
 117 import org.graalvm.compiler.options.OptionValues;
 118 import org.graalvm.compiler.phases.common.inlining.InliningUtil;
 119 
 120 import jdk.vm.ci.code.Architecture;
 121 import jdk.vm.ci.code.BailoutException;
 122 import jdk.vm.ci.code.BytecodeFrame;
 123 import jdk.vm.ci.meta.Assumptions;
 124 import jdk.vm.ci.meta.ConstantReflectionProvider;
 125 import jdk.vm.ci.meta.DeoptimizationAction;
 126 import jdk.vm.ci.meta.DeoptimizationReason;
 127 import jdk.vm.ci.meta.JavaConstant;
 128 import jdk.vm.ci.meta.JavaKind;
 129 import jdk.vm.ci.meta.JavaType;
 130 import jdk.vm.ci.meta.MetaAccessProvider;


 294          * have been processed.
 295          *
 296          * This is how SVM handles snippets. They are parsed with plugins disabled and then encoded
 297          * and stored in the image. When the snippet is needed at runtime the graph is decoded and
 298          * the plugins are run during the decoding process. If they aren't handled at this point
 299          * then they will never be handled.
 300          */
 301         @Override
 302         public boolean canDeferPlugin(GeneratedInvocationPlugin plugin) {
 303             return plugin.getSource().equals(Fold.class) || plugin.getSource().equals(Node.NodeIntrinsic.class);
 304         }
 305 
 306         @Override
 307         public BailoutException bailout(String string) {
 308             BailoutException bailout = new PermanentBailoutException(string);
 309             throw GraphUtil.createBailoutException(string, bailout, GraphUtil.approxSourceStackTraceElement(methodScope.getCallerBytecodePosition()));
 310         }
 311 
 312         @Override
 313         public StampProvider getStampProvider() {
 314             return providers.getStampProvider();
 315         }
 316 
 317         @Override
 318         public MetaAccessProvider getMetaAccess() {
 319             return providers.getMetaAccess();
 320         }
 321 
 322         @Override
 323         public ConstantReflectionProvider getConstantReflection() {
 324             return providers.getConstantReflection();
 325         }
 326 
 327         @Override
 328         public ConstantFieldProvider getConstantFieldProvider() {
 329             return providers.getConstantFieldProvider();
 330         }
 331 
 332         @Override
 333         public Replacements getReplacements() {
 334             return providers.getReplacements();
 335         }
 336 
 337         @Override
 338         public StructuredGraph getGraph() {
 339             return graph;
 340         }
 341 
 342         @Override
 343         public int getDepth() {
 344             return methodScope.inliningDepth;
 345         }
 346 
 347         @Override
 348         public IntrinsicContext getIntrinsic() {
 349             return null;
 350         }
 351 
 352         @Override
 353         public <T extends ValueNode> T append(T value) {
 354             throw unimplemented();


 555         @Override
 556         public boolean equals(Object obj) {
 557             if (obj instanceof SpecialCallTargetCacheKey) {
 558                 SpecialCallTargetCacheKey key = (SpecialCallTargetCacheKey) obj;
 559                 return key.invokeKind.equals(this.invokeKind) && key.targetMethod.equals(this.targetMethod) && key.contextType.equals(this.contextType) && key.receiverStamp.equals(this.receiverStamp);
 560             }
 561             return false;
 562         }
 563     }
 564 
 565     private final LoopExplosionPlugin loopExplosionPlugin;
 566     private final InvocationPlugins invocationPlugins;
 567     private final InlineInvokePlugin[] inlineInvokePlugins;
 568     private final ParameterPlugin parameterPlugin;
 569     private final NodePlugin[] nodePlugins;
 570     private final EconomicMap<SpecialCallTargetCacheKey, Object> specialCallTargetCache;
 571     private final EconomicMap<ResolvedJavaMethod, Object> invocationPluginCache;
 572     private final ResolvedJavaMethod callInlinedMethod;
 573     protected final SourceLanguagePositionProvider sourceLanguagePositionProvider;
 574 
 575     public PEGraphDecoder(Architecture architecture, StructuredGraph graph, CoreProviders providers, LoopExplosionPlugin loopExplosionPlugin, InvocationPlugins invocationPlugins,
 576                     InlineInvokePlugin[] inlineInvokePlugins,
 577                     ParameterPlugin parameterPlugin,
 578                     NodePlugin[] nodePlugins, ResolvedJavaMethod callInlinedMethod, SourceLanguagePositionProvider sourceLanguagePositionProvider) {
 579         super(architecture, graph, providers, true);
 580         this.loopExplosionPlugin = loopExplosionPlugin;
 581         this.invocationPlugins = invocationPlugins;
 582         this.inlineInvokePlugins = inlineInvokePlugins;
 583         this.parameterPlugin = parameterPlugin;
 584         this.nodePlugins = nodePlugins;
 585         this.specialCallTargetCache = EconomicMap.create(Equivalence.DEFAULT);
 586         this.invocationPluginCache = EconomicMap.create(Equivalence.DEFAULT);
 587         this.callInlinedMethod = callInlinedMethod;
 588         this.sourceLanguagePositionProvider = sourceLanguagePositionProvider;
 589     }
 590 
 591     protected static LoopExplosionKind loopExplosionKind(ResolvedJavaMethod method, LoopExplosionPlugin loopExplosionPlugin) {
 592         if (loopExplosionPlugin == null) {
 593             return LoopExplosionKind.NONE;
 594         } else {
 595             return loopExplosionPlugin.loopExplosionKind(method);
 596         }
 597     }
 598 
 599     @SuppressWarnings("try")


< prev index next >