1 /* 2 * Copyright (c) 2015, 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 package jdk.vm.ci.hotspot; 25 26 import jdk.vm.ci.code.InstalledCode; 27 import jdk.vm.ci.code.InvalidInstalledCodeException; 28 import jdk.vm.ci.code.TargetDescription; 29 import jdk.vm.ci.meta.SpeculationLog; 30 31 /* 32 * A simple "proxy" class to get test access to CompilerToVM package-private methods 33 */ 34 public class CompilerToVMHelper { 35 public static final CompilerToVM CTVM = new CompilerToVM(); 36 37 public static byte[] getBytecode(HotSpotResolvedJavaMethodImpl method) { 38 return CTVM.getBytecode(method); 39 } 40 41 public static int getExceptionTableLength(HotSpotResolvedJavaMethodImpl method) { 42 return CTVM.getExceptionTableLength(method); 43 } 44 45 public static long getExceptionTableStart(HotSpotResolvedJavaMethodImpl method) { 46 return CTVM.getExceptionTableStart(method); 47 } 48 49 public static boolean canInlineMethod(HotSpotResolvedJavaMethodImpl method) { 50 return CTVM.canInlineMethod(method); 51 } 52 53 public static boolean shouldInlineMethod(HotSpotResolvedJavaMethodImpl method) { 54 return CTVM.shouldInlineMethod(method); 55 } 56 57 public static HotSpotResolvedJavaMethodImpl findUniqueConcreteMethod( 58 HotSpotResolvedObjectTypeImpl actualHolderType, 59 HotSpotResolvedJavaMethodImpl method) { 60 return CTVM.findUniqueConcreteMethod(actualHolderType, method); 61 } 62 63 public static HotSpotResolvedObjectTypeImpl getImplementor(HotSpotResolvedObjectTypeImpl type) { 64 return CTVM.getImplementor(type); 65 } 66 67 public static boolean methodIsIgnoredBySecurityStackWalk(HotSpotResolvedJavaMethodImpl method) { 68 return CTVM.methodIsIgnoredBySecurityStackWalk(method); 69 } 70 71 public static HotSpotResolvedObjectTypeImpl lookupType(String name, 72 Class<?> accessingClass, boolean resolve) { 73 return CTVM.lookupType(name, accessingClass, resolve); 74 } 75 76 public static Object resolveConstantInPool(HotSpotConstantPool constantPool, int cpi) { 77 return CTVM.resolveConstantInPool(constantPool, cpi); 78 } 79 80 public static Object resolvePossiblyCachedConstantInPool(HotSpotConstantPool constantPool, int cpi) { 81 return CTVM.resolvePossiblyCachedConstantInPool(constantPool, cpi); 82 } 83 84 public static int lookupNameAndTypeRefIndexInPool(HotSpotConstantPool constantPool, int cpi) { 85 return CTVM.lookupNameAndTypeRefIndexInPool(constantPool, cpi); 86 } 87 88 public static String lookupNameInPool(HotSpotConstantPool constantPool, int cpi) { 89 return CTVM.lookupNameInPool(constantPool, cpi); 90 } 91 92 public static String lookupSignatureInPool(HotSpotConstantPool constantPool, int cpi) { 93 return CTVM.lookupSignatureInPool(constantPool, cpi); 94 } 95 96 public static int lookupKlassRefIndexInPool(HotSpotConstantPool constantPool, int cpi) { 97 return CTVM.lookupKlassRefIndexInPool(constantPool, cpi); 98 } 99 100 public static Object lookupKlassInPool(HotSpotConstantPool constantPool, int cpi) { 101 return CTVM.lookupKlassInPool(constantPool, cpi); 102 } 103 104 public static HotSpotResolvedJavaMethodImpl lookupMethodInPool( 105 HotSpotConstantPool constantPool, int cpi, byte opcode) { 106 return CTVM.lookupMethodInPool(constantPool, cpi, opcode); 107 } 108 109 public static void resolveInvokeDynamicInPool(HotSpotConstantPool constantPool, int cpi) { 110 CTVM.resolveInvokeDynamicInPool(constantPool, cpi); 111 } 112 113 public static void resolveInvokeHandleInPool(HotSpotConstantPool constantPool, int cpi) { 114 CTVM.resolveInvokeHandleInPool(constantPool, cpi); 115 } 116 117 public static HotSpotResolvedObjectTypeImpl resolveTypeInPool( 118 HotSpotConstantPool constantPool, int cpi) throws LinkageError { 119 return CTVM.resolveTypeInPool(constantPool, cpi); 120 } 121 122 public static HotSpotResolvedObjectTypeImpl resolveFieldInPool( 123 HotSpotConstantPool constantPool, int cpi, byte opcode, long[] info) { 124 return CTVM.resolveFieldInPool(constantPool, cpi, opcode, info); 125 } 126 127 public static int constantPoolRemapInstructionOperandFromCache( 128 HotSpotConstantPool constantPool, int cpci) { 129 return CTVM.constantPoolRemapInstructionOperandFromCache(constantPool, cpci); 130 } 131 132 public static Object lookupAppendixInPool(HotSpotConstantPool constantPool, int cpi) { 133 return CTVM.lookupAppendixInPool(constantPool, cpi); 134 } 135 136 public static int installCode(TargetDescription target, 137 HotSpotCompiledCode compiledCode, InstalledCode code, SpeculationLog speculationLog) { 138 return CTVM.installCode(target, compiledCode, code, speculationLog); 139 } 140 141 public static int getMetadata(TargetDescription target, 142 HotSpotCompiledCode compiledCode, HotSpotMetaData metaData) { 143 return CTVM.getMetadata(target, compiledCode, metaData); 144 } 145 146 public static void notifyCompilationStatistics(int id, 147 HotSpotResolvedJavaMethodImpl method, boolean osr, 148 int processedBytecodes, long time, long timeUnitsPerSecond, 149 InstalledCode installedCode) { 150 CTVM.notifyCompilationStatistics(id, method, osr, processedBytecodes, 151 time, timeUnitsPerSecond, installedCode); 152 } 153 154 public static void resetCompilationStatistics() { 155 CTVM.resetCompilationStatistics(); 156 } 157 158 public static long initializeConfiguration() { 159 return CTVM.initializeConfiguration(); 160 } 161 162 public static HotSpotResolvedJavaMethodImpl resolveMethod( 163 HotSpotResolvedObjectTypeImpl exactReceiver, 164 HotSpotResolvedJavaMethodImpl method, 165 HotSpotResolvedObjectTypeImpl caller) { 166 return CTVM.resolveMethod(exactReceiver, method, caller); 167 } 168 169 public static HotSpotResolvedJavaMethodImpl getClassInitializer( 170 HotSpotResolvedObjectTypeImpl type) { 171 return CTVM.getClassInitializer(type); 172 } 173 174 public static boolean hasFinalizableSubclass(HotSpotResolvedObjectTypeImpl type) { 175 return CTVM.hasFinalizableSubclass(type); 176 } 177 178 public static HotSpotResolvedJavaMethodImpl getResolvedJavaMethodAtSlot(Class<?> holder, 179 int slot) { 180 return CTVM.getResolvedJavaMethodAtSlot(holder, slot); 181 } 182 183 public static long getMaxCallTargetOffset(long address) { 184 return CTVM.getMaxCallTargetOffset(address); 185 } 186 187 public static String disassembleCodeBlob(long codeBlob) { 188 return CTVM.disassembleCodeBlob(codeBlob); 189 } 190 191 public static StackTraceElement getStackTraceElement( 192 HotSpotResolvedJavaMethodImpl method, int bci) { 193 return CTVM.getStackTraceElement(method, bci); 194 } 195 196 public static Object executeInstalledCode(Object[] args, 197 InstalledCode installedCode) throws InvalidInstalledCodeException { 198 return CTVM.executeInstalledCode(args, installedCode); 199 } 200 201 public static long[] getLineNumberTable(HotSpotResolvedJavaMethodImpl method) { 202 return CTVM.getLineNumberTable(method); 203 } 204 205 public static int getLocalVariableTableLength(HotSpotResolvedJavaMethodImpl method) { 206 return CTVM.getLocalVariableTableLength(method); 207 } 208 209 public static long getLocalVariableTableStart(HotSpotResolvedJavaMethodImpl method) { 210 return CTVM.getLocalVariableTableStart(method); 211 } 212 213 public static Object readUncompressedOop(long address) { 214 return CTVM.readUncompressedOop(address); 215 } 216 217 public static void doNotInlineOrCompile(HotSpotResolvedJavaMethodImpl method) { 218 CTVM.doNotInlineOrCompile(method); 219 } 220 221 public static void reprofile(HotSpotResolvedJavaMethodImpl method) { 222 CTVM.reprofile(method); 223 } 224 225 public static void invalidateInstalledCode(InstalledCode installedCode) { 226 CTVM.invalidateInstalledCode(installedCode); 227 } 228 229 public static long[] collectCounters() { 230 return CTVM.collectCounters(); 231 } 232 233 public static boolean isMature(long metaspaceMethodData) { 234 return CTVM.isMature(metaspaceMethodData); 235 } 236 237 public static int allocateCompileId(HotSpotResolvedJavaMethodImpl method, 238 int entryBCI) { 239 return CTVM.allocateCompileId(method, entryBCI); 240 } 241 242 public static boolean hasCompiledCodeForOSR( 243 HotSpotResolvedJavaMethodImpl method, int entryBCI, int level) { 244 return CTVM.hasCompiledCodeForOSR(method, entryBCI, level); 245 } 246 247 public static String getSymbol(long metaspaceSymbol) { 248 return CTVM.getSymbol(metaspaceSymbol); 249 } 250 251 public static HotSpotStackFrameReference getNextStackFrame( 252 HotSpotStackFrameReference frame, 253 HotSpotResolvedJavaMethodImpl[] methods, int initialSkip) { 254 return CTVM.getNextStackFrame(frame, methods, initialSkip); 255 } 256 257 public static void materializeVirtualObjects( 258 HotSpotStackFrameReference stackFrame, boolean invalidate) { 259 CTVM.materializeVirtualObjects(stackFrame, invalidate); 260 } 261 262 public static int getVtableIndexForInterfaceMethod(HotSpotResolvedObjectTypeImpl type, 263 HotSpotResolvedJavaMethodImpl method) { 264 return CTVM.getVtableIndexForInterfaceMethod(type, method); 265 } 266 267 public static boolean shouldDebugNonSafepoints() { 268 return CTVM.shouldDebugNonSafepoints(); 269 } 270 271 public static void writeDebugOutput(byte[] bytes, int offset, int length) { 272 CTVM.writeDebugOutput(bytes, offset, length); 273 } 274 275 public static void flushDebugOutput() { 276 CTVM.flushDebugOutput(); 277 } 278 279 public static HotSpotResolvedJavaMethodImpl getResolvedJavaMethod(Object base, 280 long displacement) { 281 return CTVM.getResolvedJavaMethod(base, displacement); 282 } 283 284 public static HotSpotConstantPool getConstantPool(Object base, long displacement) { 285 return CTVM.getConstantPool(base, displacement); 286 } 287 288 public static HotSpotResolvedObjectTypeImpl getResolvedJavaType(Object base, 289 long displacement, boolean compressed) { 290 return CTVM.getResolvedJavaType(base, displacement, compressed); 291 } 292 }