1 /*
   2  * Copyright (c) 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  */
  23 
  24 
  25 package org.graalvm.compiler.nodes.spi;
  26 
  27 import org.graalvm.compiler.api.replacements.SnippetTemplateCache;
  28 import org.graalvm.compiler.bytecode.Bytecode;
  29 import org.graalvm.compiler.bytecode.BytecodeProvider;
  30 import org.graalvm.compiler.core.common.CompilationIdentifier;
  31 import org.graalvm.compiler.debug.DebugContext;
  32 import org.graalvm.compiler.graph.NodeSourcePosition;
  33 import org.graalvm.compiler.nodes.StructuredGraph;
  34 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration;
  35 import org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderPlugin;
  36 import org.graalvm.compiler.options.OptionValues;
  37 
  38 import jdk.vm.ci.meta.ResolvedJavaMethod;
  39 
  40 /**
  41  * A convenience class when want to subclass and override just a portion of the Replacements API.
  42  */
  43 public class DelegatingReplacements implements Replacements {
  44     protected final Replacements delegate;
  45 
  46     public DelegatingReplacements(Replacements delegate) {
  47         this.delegate = delegate;
  48     }
  49 
  50     @Override
  51     public OptionValues getOptions() {
  52         return delegate.getOptions();
  53     }
  54 
  55     @Override
  56     public GraphBuilderConfiguration.Plugins getGraphBuilderPlugins() {
  57         return delegate.getGraphBuilderPlugins();
  58     }
  59 
  60     @Override
  61     public Class<? extends GraphBuilderPlugin> getIntrinsifyingPlugin(ResolvedJavaMethod method) {
  62         return delegate.getIntrinsifyingPlugin(method);
  63     }
  64 
  65     @Override
  66     public StructuredGraph getSnippet(ResolvedJavaMethod method, Object[] args, boolean trackNodeSourcePosition, NodeSourcePosition replaceePosition) {
  67         return delegate.getSnippet(method, args, trackNodeSourcePosition, replaceePosition);
  68     }
  69 
  70     @Override
  71     public StructuredGraph getSnippet(ResolvedJavaMethod method, ResolvedJavaMethod recursiveEntry, Object[] args, boolean trackNodeSourcePosition, NodeSourcePosition replaceePosition) {
  72         return delegate.getSnippet(method, recursiveEntry, args, trackNodeSourcePosition, replaceePosition);
  73     }
  74 
  75     @Override
  76     public void registerSnippet(ResolvedJavaMethod method, ResolvedJavaMethod original, Object receiver, boolean trackNodeSourcePosition) {
  77         delegate.registerSnippet(method, original, receiver, trackNodeSourcePosition);
  78     }
  79 
  80     @Override
  81     public StructuredGraph getSubstitution(ResolvedJavaMethod method, int invokeBci, boolean trackNodeSourcePosition, NodeSourcePosition replaceePosition) {
  82         return delegate.getSubstitution(method, invokeBci, trackNodeSourcePosition, replaceePosition);
  83     }
  84 
  85     @Override
  86     public Bytecode getSubstitutionBytecode(ResolvedJavaMethod method) {
  87         return delegate.getSubstitutionBytecode(method);
  88     }
  89 
  90     @Override
  91     public StructuredGraph getIntrinsicGraph(ResolvedJavaMethod method, CompilationIdentifier compilationId, DebugContext debug) {
  92         return delegate.getIntrinsicGraph(method, compilationId, debug);
  93     }
  94 
  95     @Override
  96     public boolean hasSubstitution(ResolvedJavaMethod method, int invokeBci) {
  97         return delegate.hasSubstitution(method, invokeBci);
  98     }
  99 
 100     @Override
 101     public BytecodeProvider getDefaultReplacementBytecodeProvider() {
 102         return delegate.getDefaultReplacementBytecodeProvider();
 103     }
 104 
 105     @Override
 106     public void registerSnippetTemplateCache(SnippetTemplateCache snippetTemplates) {
 107         delegate.registerSnippetTemplateCache(snippetTemplates);
 108     }
 109 
 110     @Override
 111     public <T extends SnippetTemplateCache> T getSnippetTemplateCache(Class<T> templatesClass) {
 112         return delegate.getSnippetTemplateCache(templatesClass);
 113     }
 114 }