1 /* 2 * Copyright (c) 2009, 2014, 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 package jdk.vm.ci.code; 24 25 import jdk.vm.ci.code.CompilationResult.*; 26 import jdk.vm.ci.code.DataSection.*; 27 import jdk.vm.ci.meta.*; 28 29 /** 30 * Access to code cache related details and requirements. 31 */ 32 public interface CodeCacheProvider { 33 34 /** 35 * Adds the given compilation result as an implementation of the given method without making it 36 * the default implementation. 37 * 38 * @param method a method to which the executable code is begin added 39 * @param compResult the compilation result to be added 40 * @param speculationLog the speculation log to be used 41 * @return a reference to the compiled and ready-to-run code or throws a 42 * {@link BailoutException} if the code installation failed 43 */ 44 InstalledCode addMethod(ResolvedJavaMethod method, CompilationResult compResult, SpeculationLog speculationLog, InstalledCode predefinedInstalledCode); 45 46 /** 47 * Sets the given compilation result as the default implementation of the given method. 48 * 49 * @param method a method to which the executable code is begin added 50 * @param compResult the compilation result to be added 51 * @return a reference to the compiled and ready-to-run code or null if the code installation 52 * failed 53 */ 54 InstalledCode setDefaultMethod(ResolvedJavaMethod method, CompilationResult compResult); 55 56 /** 57 * Gets a name for a {@link Mark} mark. 58 */ 59 default String getMarkName(Mark mark) { 60 return String.valueOf(mark.id); 61 } 62 63 /** 64 * Gets a name for the {@linkplain Call#target target} of a {@link Call}. 65 */ 66 default String getTargetName(Call call) { 67 return String.valueOf(call.target); 68 } 69 70 /** 71 * Gets the register configuration to use when compiling a given method. 72 */ 73 RegisterConfig getRegisterConfig(); 74 75 /** 76 * Minimum size of the stack area reserved for outgoing parameters. This area is reserved in all 77 * cases, even when the compiled method has no regular call instructions. 78 * 79 * @return the minimum size of the outgoing parameter area in bytes 80 */ 81 int getMinimumOutgoingSize(); 82 83 /** 84 * Determines if a {@link DataPatch} should be created for a given primitive constant that is 85 * part of a {@link CompilationResult}. A data patch is always created for an object constant. 86 */ 87 boolean needsDataPatch(JavaConstant constant); 88 89 /** 90 * Create a {@link Data} item for one or more {@link Constant Constants}, that can be used in a 91 * {@link DataPatch}. If more than one {@link Constant} is given, then they are tightly packed 92 * into a single {@link Data} item. 93 */ 94 Data createDataItem(Constant... constants); 95 96 /** 97 * Gets a description of the target architecture. 98 */ 99 TargetDescription getTarget(); 100 101 /** 102 * Create a new speculation log for the target runtime. 103 */ 104 SpeculationLog createSpeculationLog(); 105 }