< prev index next >

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

Print this page
rev 56282 : [mq]: graal
   1 /*
   2  * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  54 
  55 import jdk.vm.ci.code.Architecture;
  56 import jdk.vm.ci.meta.ResolvedJavaMethod;
  57 
  58 /**
  59  * A graph decoder that provides all necessary encoded graphs on-the-fly (by parsing the methods and
  60  * encoding the graphs).
  61  */
  62 public class CachingPEGraphDecoder extends PEGraphDecoder {
  63 
  64     protected final Providers providers;
  65     protected final GraphBuilderConfiguration graphBuilderConfig;
  66     protected final OptimisticOptimizations optimisticOpts;
  67     private final AllowAssumptions allowAssumptions;
  68     private final EconomicMap<ResolvedJavaMethod, EncodedGraph> graphCache;
  69     private final BasePhase<? super CoreProviders> postParsingPhase;
  70 
  71     public CachingPEGraphDecoder(Architecture architecture, StructuredGraph graph, Providers providers, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts,
  72                     AllowAssumptions allowAssumptions, LoopExplosionPlugin loopExplosionPlugin, InvocationPlugins invocationPlugins, InlineInvokePlugin[] inlineInvokePlugins,
  73                     ParameterPlugin parameterPlugin,
  74                     NodePlugin[] nodePlugins, ResolvedJavaMethod callInlinedMethod, SourceLanguagePositionProvider sourceLanguagePositionProvider,
  75                     BasePhase<? super CoreProviders> postParsingPhase) {
  76         super(architecture, graph, providers, loopExplosionPlugin,
  77                         invocationPlugins, inlineInvokePlugins, parameterPlugin, nodePlugins, callInlinedMethod, sourceLanguagePositionProvider);
  78 
  79         this.providers = providers;
  80         this.graphBuilderConfig = graphBuilderConfig;
  81         this.optimisticOpts = optimisticOpts;
  82         this.allowAssumptions = allowAssumptions;

  83         this.postParsingPhase = postParsingPhase;
  84         this.graphCache = EconomicMap.create();
  85     }
  86 
  87     protected GraphBuilderPhase.Instance createGraphBuilderPhaseInstance(IntrinsicContext initialIntrinsicContext) {
  88         return new GraphBuilderPhase.Instance(providers, graphBuilderConfig, optimisticOpts, initialIntrinsicContext);
  89     }
  90 
  91     @SuppressWarnings("try")
  92     private EncodedGraph createGraph(ResolvedJavaMethod method, MethodSubstitutionPlugin plugin, BytecodeProvider intrinsicBytecodeProvider, boolean isSubstitution) {
  93         StructuredGraph graphToEncode;
  94         if (isSubstitution && (UseEncodedGraphs.getValue(options) || IS_IN_NATIVE_IMAGE)) {
  95             // These must go through Replacements to find the graph to use.
  96             graphToEncode = providers.getReplacements().getMethodSubstitution(plugin, method, INLINE_AFTER_PARSING, allowAssumptions,
  97                             null, options);
  98         } else {
  99             graphToEncode = buildGraph(method, plugin, intrinsicBytecodeProvider, isSubstitution);
 100         }
 101 
 102         /*
 103          * ConvertDeoptimizeToGuardPhase reduces the number of merges in the graph, so that fewer
 104          * frame states will be created. This significantly reduces the number of nodes in the


   1 /*
   2  * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */


  54 
  55 import jdk.vm.ci.code.Architecture;
  56 import jdk.vm.ci.meta.ResolvedJavaMethod;
  57 
  58 /**
  59  * A graph decoder that provides all necessary encoded graphs on-the-fly (by parsing the methods and
  60  * encoding the graphs).
  61  */
  62 public class CachingPEGraphDecoder extends PEGraphDecoder {
  63 
  64     protected final Providers providers;
  65     protected final GraphBuilderConfiguration graphBuilderConfig;
  66     protected final OptimisticOptimizations optimisticOpts;
  67     private final AllowAssumptions allowAssumptions;
  68     private final EconomicMap<ResolvedJavaMethod, EncodedGraph> graphCache;
  69     private final BasePhase<? super CoreProviders> postParsingPhase;
  70 
  71     public CachingPEGraphDecoder(Architecture architecture, StructuredGraph graph, Providers providers, GraphBuilderConfiguration graphBuilderConfig, OptimisticOptimizations optimisticOpts,
  72                     AllowAssumptions allowAssumptions, LoopExplosionPlugin loopExplosionPlugin, InvocationPlugins invocationPlugins, InlineInvokePlugin[] inlineInvokePlugins,
  73                     ParameterPlugin parameterPlugin,
  74                     NodePlugin[] nodePlugins, ResolvedJavaMethod callInlinedMethod, ResolvedJavaMethod callInlinedAgnosticMethod, SourceLanguagePositionProvider sourceLanguagePositionProvider,
  75                     BasePhase<? super CoreProviders> postParsingPhase, EconomicMap<ResolvedJavaMethod, EncodedGraph> graphCache) {
  76         super(architecture, graph, providers, loopExplosionPlugin,
  77                         invocationPlugins, inlineInvokePlugins, parameterPlugin, nodePlugins, callInlinedMethod, callInlinedAgnosticMethod, sourceLanguagePositionProvider);
  78 
  79         this.providers = providers;
  80         this.graphBuilderConfig = graphBuilderConfig;
  81         this.optimisticOpts = optimisticOpts;
  82         this.allowAssumptions = allowAssumptions;
  83         this.graphCache = graphCache;
  84         this.postParsingPhase = postParsingPhase;

  85     }
  86 
  87     protected GraphBuilderPhase.Instance createGraphBuilderPhaseInstance(IntrinsicContext initialIntrinsicContext) {
  88         return new GraphBuilderPhase.Instance(providers, graphBuilderConfig, optimisticOpts, initialIntrinsicContext);
  89     }
  90 
  91     @SuppressWarnings("try")
  92     private EncodedGraph createGraph(ResolvedJavaMethod method, MethodSubstitutionPlugin plugin, BytecodeProvider intrinsicBytecodeProvider, boolean isSubstitution) {
  93         StructuredGraph graphToEncode;
  94         if (isSubstitution && (UseEncodedGraphs.getValue(options) || IS_IN_NATIVE_IMAGE)) {
  95             // These must go through Replacements to find the graph to use.
  96             graphToEncode = providers.getReplacements().getMethodSubstitution(plugin, method, INLINE_AFTER_PARSING, allowAssumptions,
  97                             null, options);
  98         } else {
  99             graphToEncode = buildGraph(method, plugin, intrinsicBytecodeProvider, isSubstitution);
 100         }
 101 
 102         /*
 103          * ConvertDeoptimizeToGuardPhase reduces the number of merges in the graph, so that fewer
 104          * frame states will be created. This significantly reduces the number of nodes in the


< prev index next >