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 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 } | 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.Call; 26 import jdk.vm.ci.code.CompilationResult.DataPatch; 27 import jdk.vm.ci.code.CompilationResult.Mark; 28 import jdk.vm.ci.code.DataSection.Data; 29 import jdk.vm.ci.meta.Constant; 30 import jdk.vm.ci.meta.JavaConstant; 31 import jdk.vm.ci.meta.ResolvedJavaMethod; 32 import jdk.vm.ci.meta.SpeculationLog; 33 34 /** 35 * Access to code cache related details and requirements. 36 */ 37 public interface CodeCacheProvider { 38 39 /** 40 * Installs code for a given method based on a given compilation result without making it the 41 * default implementation of the method. 42 * 43 * @param method a method implemented by the installed code 44 * @param compResult the compilation result to be added 45 * @param log the speculation log to be used 46 * @param installedCode a predefined {@link InstalledCode} object to use as a reference to the 47 * installed code. If {@code null}, a new {@link InstalledCode} object will be 48 * created. 49 * @return a reference to the ready-to-run code 50 * @throws BailoutException if the code installation failed 51 */ 52 default InstalledCode addCode(ResolvedJavaMethod method, CompilationResult compResult, SpeculationLog log, InstalledCode installedCode) { 53 return installCode(new CompilationRequest(method), compResult, installedCode, log, false); 54 } 55 56 /** 57 * Installs code for a given method based on a given compilation result and makes it the default 58 * implementation of the method. 59 * 60 * @param method a method implemented by the installed code and for which the installed code 61 * becomes the default implementation 62 * @param compResult the compilation result to be added 63 * @return a reference to the ready-to-run code 64 * @throws BailoutException if the code installation failed 65 */ 66 default InstalledCode setDefaultCode(ResolvedJavaMethod method, CompilationResult compResult) { 67 return installCode(new CompilationRequest(method), compResult, null, null, true); 68 } 69 70 /** 71 * Installs code based on a given compilation result. 72 * 73 * @param compRequest details of the method compiled to produce {@code compResult} or 74 * {@code null} if the input to {@code compResult} was not a 75 * {@link ResolvedJavaMethod} 76 * @param compResult the compilation result to be added 77 * @param installedCode a pre-allocated {@link InstalledCode} object to use as a reference to 78 * the installed code. If {@code null}, a new {@link InstalledCode} object will be 79 * created. 80 * @param log the speculation log to be used 81 * @param isDefault specifies if the installed code should be made the default implementation of 82 * {@code compRequest.getMethod()}. The default implementation for a method is the 83 * code executed for standard calls to the method. This argument is ignored if 84 * {@code compRequest == null}. 85 * @return a reference to the compiled and ready-to-run installed code 86 * @throws BailoutException if the code installation failed 87 */ 88 InstalledCode installCode(CompilationRequest compRequest, CompilationResult compResult, InstalledCode installedCode, SpeculationLog log, boolean isDefault); 89 90 /** 91 * Invalidates {@code installedCode} such that {@link InvalidInstalledCodeException} will be 92 * raised the next time {@code installedCode} is 93 * {@linkplain InstalledCode#executeVarargs(Object...) executed}. 94 */ 95 void invalidateInstalledCode(InstalledCode installedCode); 96 97 /** 98 * Gets a name for a {@link Mark} mark. 99 */ 100 default String getMarkName(Mark mark) { 101 return String.valueOf(mark.id); 102 } 103 104 /** 105 * Gets a name for the {@linkplain Call#target target} of a {@link Call}. 106 */ 107 default String getTargetName(Call call) { 108 return String.valueOf(call.target); 109 } 110 111 /** 112 * Gets the register configuration to use when compiling a given method. 113 */ 114 RegisterConfig getRegisterConfig(); 115 126 * part of a {@link CompilationResult}. A data patch is always created for an object constant. 127 */ 128 boolean needsDataPatch(JavaConstant constant); 129 130 /** 131 * Create a {@link Data} item for one or more {@link Constant Constants}, that can be used in a 132 * {@link DataPatch}. If more than one {@link Constant} is given, then they are tightly packed 133 * into a single {@link Data} item. 134 */ 135 Data createDataItem(Constant... constants); 136 137 /** 138 * Gets a description of the target architecture. 139 */ 140 TargetDescription getTarget(); 141 142 /** 143 * Create a new speculation log for the target runtime. 144 */ 145 SpeculationLog createSpeculationLog(); 146 147 /** 148 * Returns the maximum absolute offset of a PC relative call to a given address from any 149 * position in the code cache or -1 when not applicable. Intended for determining the required 150 * size of address/offset fields. 151 */ 152 long getMaxCallTargetOffset(long address); 153 154 /** 155 * Determines if debug info should also be emitted at non-safepoint locations. 156 */ 157 boolean shouldDebugNonSafepoints(); 158 } |