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