< prev index next >

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

Print this page




 176         }
 177 
 178         public NodeSourcePosition getCallerBytecodePosition() {
 179             if (caller == null) {
 180                 return null;
 181             }
 182             if (callerBytecodePosition == null) {
 183                 JavaConstant constantReceiver = caller.invokeData == null ? null : caller.invokeData.constantReceiver;
 184                 NodeSourcePosition callerPosition = caller.getCallerBytecodePosition();
 185                 NodeSourcePosition invokePosition = invokeData.invoke.asNode().getNodeSourcePosition();
 186                 callerBytecodePosition = invokePosition != null ? invokePosition.addCaller(constantReceiver, callerPosition) : callerPosition;
 187             }
 188             return callerBytecodePosition;
 189         }
 190     }
 191 
 192     protected class PENonAppendGraphBuilderContext implements GraphBuilderContext {
 193         protected final PEMethodScope methodScope;
 194         protected final Invoke invoke;
 195 


















 196         public PENonAppendGraphBuilderContext(PEMethodScope methodScope, Invoke invoke) {
 197             this.methodScope = methodScope;
 198             this.invoke = invoke;
 199         }
 200 
 201         @Override
 202         public BailoutException bailout(String string) {
 203             BailoutException bailout = new PermanentBailoutException(string);
 204             throw GraphUtil.createBailoutException(string, bailout, GraphUtil.approxSourceStackTraceElement(methodScope.getCallerBytecodePosition()));
 205         }
 206 
 207         @Override
 208         public StampProvider getStampProvider() {
 209             return stampProvider;
 210         }
 211 
 212         @Override
 213         public MetaAccessProvider getMetaAccess() {
 214             return metaAccess;
 215         }


 403             return invokeKind.hashCode() ^ targetMethod.hashCode() ^ contextType.hashCode() ^ receiverStamp.hashCode();
 404         }
 405 
 406         @Override
 407         public boolean equals(Object obj) {
 408             if (obj instanceof SpecialCallTargetCacheKey) {
 409                 SpecialCallTargetCacheKey key = (SpecialCallTargetCacheKey) obj;
 410                 return key.invokeKind.equals(this.invokeKind) && key.targetMethod.equals(this.targetMethod) && key.contextType.equals(this.contextType) && key.receiverStamp.equals(this.receiverStamp);
 411             }
 412             return false;
 413         }
 414     }
 415 
 416     private final LoopExplosionPlugin loopExplosionPlugin;
 417     private final InvocationPlugins invocationPlugins;
 418     private final InlineInvokePlugin[] inlineInvokePlugins;
 419     private final ParameterPlugin parameterPlugin;
 420     private final NodePlugin[] nodePlugins;
 421     private final EconomicMap<SpecialCallTargetCacheKey, Object> specialCallTargetCache;
 422     private final EconomicMap<ResolvedJavaMethod, Object> invocationPluginCache;

 423 
 424     public PEGraphDecoder(Architecture architecture, StructuredGraph graph, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, ConstantFieldProvider constantFieldProvider,
 425                     StampProvider stampProvider, LoopExplosionPlugin loopExplosionPlugin, InvocationPlugins invocationPlugins, InlineInvokePlugin[] inlineInvokePlugins,
 426                     ParameterPlugin parameterPlugin,
 427                     NodePlugin[] nodePlugins) {
 428         super(architecture, graph, metaAccess, constantReflection, constantFieldProvider, stampProvider, true);
 429         this.loopExplosionPlugin = loopExplosionPlugin;
 430         this.invocationPlugins = invocationPlugins;
 431         this.inlineInvokePlugins = inlineInvokePlugins;
 432         this.parameterPlugin = parameterPlugin;
 433         this.nodePlugins = nodePlugins;
 434         this.specialCallTargetCache = EconomicMap.create(Equivalence.DEFAULT);
 435         this.invocationPluginCache = EconomicMap.create(Equivalence.DEFAULT);

 436     }
 437 
 438     protected static LoopExplosionKind loopExplosionKind(ResolvedJavaMethod method, LoopExplosionPlugin loopExplosionPlugin) {
 439         if (loopExplosionPlugin == null) {
 440             return LoopExplosionKind.NONE;
 441         } else {
 442             return loopExplosionPlugin.loopExplosionKind(method);
 443         }
 444     }
 445 
 446     public void decode(ResolvedJavaMethod method) {
 447         PEMethodScope methodScope = new PEMethodScope(graph, null, null, lookupEncodedGraph(method, null), method, null, 0, loopExplosionPlugin, null);
 448         decode(createInitialLoopScope(methodScope, null));
 449         cleanupGraph(methodScope);
 450 
 451         debug.dump(DebugContext.VERBOSE_LEVEL, graph, "After graph cleanup");
 452         assert graph.verify();
 453 
 454         try {
 455             /* Check that the control flow graph can be computed, to catch problems early. */




 176         }
 177 
 178         public NodeSourcePosition getCallerBytecodePosition() {
 179             if (caller == null) {
 180                 return null;
 181             }
 182             if (callerBytecodePosition == null) {
 183                 JavaConstant constantReceiver = caller.invokeData == null ? null : caller.invokeData.constantReceiver;
 184                 NodeSourcePosition callerPosition = caller.getCallerBytecodePosition();
 185                 NodeSourcePosition invokePosition = invokeData.invoke.asNode().getNodeSourcePosition();
 186                 callerBytecodePosition = invokePosition != null ? invokePosition.addCaller(constantReceiver, callerPosition) : callerPosition;
 187             }
 188             return callerBytecodePosition;
 189         }
 190     }
 191 
 192     protected class PENonAppendGraphBuilderContext implements GraphBuilderContext {
 193         protected final PEMethodScope methodScope;
 194         protected final Invoke invoke;
 195 
 196         @Override
 197         public ExternalInliningContext getExternalInliningContext() {
 198             return new ExternalInliningContext() {
 199                 @Override
 200                 public int getInlinedDepth() {
 201                     int count = 0;
 202                     PEGraphDecoder.PEMethodScope scope = methodScope;
 203                     while (scope != null) {
 204                         if (scope.method.equals(callInlinedMethod)) {
 205                             count++;
 206                         }
 207                         scope = scope.caller;
 208                     }
 209                     return count;
 210                 }
 211             };
 212         }
 213 
 214         public PENonAppendGraphBuilderContext(PEMethodScope methodScope, Invoke invoke) {
 215             this.methodScope = methodScope;
 216             this.invoke = invoke;
 217         }
 218 
 219         @Override
 220         public BailoutException bailout(String string) {
 221             BailoutException bailout = new PermanentBailoutException(string);
 222             throw GraphUtil.createBailoutException(string, bailout, GraphUtil.approxSourceStackTraceElement(methodScope.getCallerBytecodePosition()));
 223         }
 224 
 225         @Override
 226         public StampProvider getStampProvider() {
 227             return stampProvider;
 228         }
 229 
 230         @Override
 231         public MetaAccessProvider getMetaAccess() {
 232             return metaAccess;
 233         }


 421             return invokeKind.hashCode() ^ targetMethod.hashCode() ^ contextType.hashCode() ^ receiverStamp.hashCode();
 422         }
 423 
 424         @Override
 425         public boolean equals(Object obj) {
 426             if (obj instanceof SpecialCallTargetCacheKey) {
 427                 SpecialCallTargetCacheKey key = (SpecialCallTargetCacheKey) obj;
 428                 return key.invokeKind.equals(this.invokeKind) && key.targetMethod.equals(this.targetMethod) && key.contextType.equals(this.contextType) && key.receiverStamp.equals(this.receiverStamp);
 429             }
 430             return false;
 431         }
 432     }
 433 
 434     private final LoopExplosionPlugin loopExplosionPlugin;
 435     private final InvocationPlugins invocationPlugins;
 436     private final InlineInvokePlugin[] inlineInvokePlugins;
 437     private final ParameterPlugin parameterPlugin;
 438     private final NodePlugin[] nodePlugins;
 439     private final EconomicMap<SpecialCallTargetCacheKey, Object> specialCallTargetCache;
 440     private final EconomicMap<ResolvedJavaMethod, Object> invocationPluginCache;
 441     private final ResolvedJavaMethod callInlinedMethod;
 442 
 443     public PEGraphDecoder(Architecture architecture, StructuredGraph graph, MetaAccessProvider metaAccess, ConstantReflectionProvider constantReflection, ConstantFieldProvider constantFieldProvider,
 444                     StampProvider stampProvider, LoopExplosionPlugin loopExplosionPlugin, InvocationPlugins invocationPlugins, InlineInvokePlugin[] inlineInvokePlugins,
 445                     ParameterPlugin parameterPlugin,
 446                     NodePlugin[] nodePlugins, ResolvedJavaMethod callInlinedMethod) {
 447         super(architecture, graph, metaAccess, constantReflection, constantFieldProvider, stampProvider, true);
 448         this.loopExplosionPlugin = loopExplosionPlugin;
 449         this.invocationPlugins = invocationPlugins;
 450         this.inlineInvokePlugins = inlineInvokePlugins;
 451         this.parameterPlugin = parameterPlugin;
 452         this.nodePlugins = nodePlugins;
 453         this.specialCallTargetCache = EconomicMap.create(Equivalence.DEFAULT);
 454         this.invocationPluginCache = EconomicMap.create(Equivalence.DEFAULT);
 455         this.callInlinedMethod = callInlinedMethod;
 456     }
 457 
 458     protected static LoopExplosionKind loopExplosionKind(ResolvedJavaMethod method, LoopExplosionPlugin loopExplosionPlugin) {
 459         if (loopExplosionPlugin == null) {
 460             return LoopExplosionKind.NONE;
 461         } else {
 462             return loopExplosionPlugin.loopExplosionKind(method);
 463         }
 464     }
 465 
 466     public void decode(ResolvedJavaMethod method) {
 467         PEMethodScope methodScope = new PEMethodScope(graph, null, null, lookupEncodedGraph(method, null), method, null, 0, loopExplosionPlugin, null);
 468         decode(createInitialLoopScope(methodScope, null));
 469         cleanupGraph(methodScope);
 470 
 471         debug.dump(DebugContext.VERBOSE_LEVEL, graph, "After graph cleanup");
 472         assert graph.verify();
 473 
 474         try {
 475             /* Check that the control flow graph can be computed, to catch problems early. */


< prev index next >