1 /*
   2  * Copyright (c) 2011, 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 static jdk.vm.ci.inittimer.InitTimer.timer;
  27 
  28 import java.lang.reflect.Constructor;
  29 import java.lang.reflect.Method;
  30 
  31 import jdk.vm.ci.code.InstalledCode;
  32 import jdk.vm.ci.code.InvalidInstalledCodeException;
  33 import jdk.vm.ci.code.TargetDescription;
  34 import jdk.vm.ci.hotspotvmconfig.HotSpotVMField;
  35 import jdk.vm.ci.inittimer.InitTimer;
  36 import jdk.vm.ci.meta.JavaType;
  37 import jdk.vm.ci.meta.ResolvedJavaMethod;
  38 import jdk.vm.ci.meta.ResolvedJavaType;
  39 import jdk.vm.ci.meta.SpeculationLog;
  40 import sun.misc.Unsafe;
  41 
  42 /**
  43  * Calls from Java into HotSpot. The behavior of all the methods in this class that take a native
  44  * pointer as an argument (e.g., {@link #getSymbol(long)}) is undefined if the argument does not
  45  * denote a valid native object.
  46  */
  47 public final class CompilerToVM {
  48     /**
  49      * Initializes the native part of the JVMCI runtime.
  50      */
  51     private static native void registerNatives();
  52 
  53     static {
  54         initialize();
  55     }
  56 
  57     @SuppressWarnings("try")
  58     private static void initialize() {
  59         try (InitTimer t = timer("CompilerToVM.registerNatives")) {
  60             registerNatives();
  61         }
  62     }
  63 
  64     /**
  65      * Copies the original bytecode of {@code method} into a new byte array and returns it.
  66      *
  67      * @return a new byte array containing the original bytecode of {@code method}
  68      */
  69     native byte[] getBytecode(HotSpotResolvedJavaMethodImpl method);
  70 
  71     /**
  72      * Gets the number of entries in {@code method}'s exception handler table or 0 if it has not
  73      * exception handler table.
  74      */
  75     native int getExceptionTableLength(HotSpotResolvedJavaMethodImpl method);
  76 
  77     /**
  78      * Gets the address of the first entry in {@code method}'s exception handler table.
  79      *
  80      * Each entry is a native object described by these fields:
  81      *
  82      * <ul>
  83      * <li>{@link HotSpotVMConfig#exceptionTableElementSize}</li>
  84      * <li>{@link HotSpotVMConfig#exceptionTableElementStartPcOffset}</li>
  85      * <li>{@link HotSpotVMConfig#exceptionTableElementEndPcOffset}</li>
  86      * <li>{@link HotSpotVMConfig#exceptionTableElementHandlerPcOffset}</li>
  87      * <li>{@link HotSpotVMConfig#exceptionTableElementCatchTypeIndexOffset}
  88      * </ul>
  89      *
  90      * @return 0 if {@code method} has no exception handlers (i.e.
  91      *         {@code getExceptionTableLength(method) == 0})
  92      */
  93     native long getExceptionTableStart(HotSpotResolvedJavaMethodImpl method);
  94 
  95     /**
  96      * Determines if {@code method} can be inlined. A method may not be inlinable for a number of
  97      * reasons such as:
  98      * <ul>
  99      * <li>a CompileOracle directive may prevent inlining or compilation of methods</li>
 100      * <li>the method may have a bytecode breakpoint set</li>
 101      * <li>the method may have other bytecode features that require special handling by the VM</li>
 102      * </ul>
 103      */
 104     native boolean canInlineMethod(HotSpotResolvedJavaMethodImpl method);
 105 
 106     /**
 107      * Determines if {@code method} should be inlined at any cost. This could be because:
 108      * <ul>
 109      * <li>a CompileOracle directive may forces inlining of this methods</li>
 110      * <li>an annotation forces inlining of this method</li>
 111      * </ul>
 112      */
 113     native boolean shouldInlineMethod(HotSpotResolvedJavaMethodImpl method);
 114 
 115     /**
 116      * Used to implement {@link ResolvedJavaType#findUniqueConcreteMethod(ResolvedJavaMethod)}.
 117      *
 118      * @param method the method on which to base the search
 119      * @param actualHolderType the best known type of receiver
 120      * @return the method result or 0 is there is no unique concrete method for {@code method}
 121      */
 122     native HotSpotResolvedJavaMethodImpl findUniqueConcreteMethod(HotSpotResolvedObjectTypeImpl actualHolderType, HotSpotResolvedJavaMethodImpl method);
 123 
 124     /**
 125      * Gets the implementor for the interface class {@code type}.
 126      *
 127      * @return the implementor if there is a single implementor, 0 if there is no implementor, or
 128      *         {@code type} itself if there is more than one implementor
 129      */
 130     native HotSpotResolvedObjectTypeImpl getImplementor(HotSpotResolvedObjectTypeImpl type);
 131 
 132     /**
 133      * Determines if {@code method} is ignored by security stack walks.
 134      */
 135     native boolean methodIsIgnoredBySecurityStackWalk(HotSpotResolvedJavaMethodImpl method);
 136 
 137     /**
 138      * Converts a name to a type.
 139      *
 140      * @param name a well formed Java type in {@linkplain JavaType#getName() internal} format
 141      * @param accessingClass the context of resolution (must not be null)
 142      * @param resolve force resolution to a {@link ResolvedJavaType}. If true, this method will
 143      *            either return a {@link ResolvedJavaType} or throw an exception
 144      * @return the type for {@code name} or 0 if resolution failed and {@code resolve == false}
 145      * @throws LinkageError if {@code resolve == true} and the resolution failed
 146      */
 147     native HotSpotResolvedObjectTypeImpl lookupType(String name, Class<?> accessingClass, boolean resolve);
 148 
 149     /**
 150      * Resolves the entry at index {@code cpi} in {@code constantPool} to an object.
 151      *
 152      * The behavior of this method is undefined if {@code cpi} does not denote one of the following
 153      * entry types: {@code JVM_CONSTANT_MethodHandle}, {@code JVM_CONSTANT_MethodHandleInError},
 154      * {@code JVM_CONSTANT_MethodType} and {@code JVM_CONSTANT_MethodTypeInError}.
 155      */
 156     native Object resolveConstantInPool(HotSpotConstantPool constantPool, int cpi);
 157 
 158     /**
 159      * Resolves the entry at index {@code cpi} in {@code constantPool} to an object, looking in the
 160      * constant pool cache first.
 161      *
 162      * The behavior of this method is undefined if {@code cpi} does not denote a
 163      * {@code JVM_CONSTANT_String} entry.
 164      */
 165     native Object resolvePossiblyCachedConstantInPool(HotSpotConstantPool constantPool, int cpi);
 166 
 167     /**
 168      * Gets the {@code JVM_CONSTANT_NameAndType} index from the entry at index {@code cpi} in
 169      * {@code constantPool}.
 170      *
 171      * The behavior of this method is undefined if {@code cpi} does not denote an entry containing a
 172      * {@code JVM_CONSTANT_NameAndType} index.
 173      */
 174     native int lookupNameAndTypeRefIndexInPool(HotSpotConstantPool constantPool, int cpi);
 175 
 176     /**
 177      * Gets the name of the {@code JVM_CONSTANT_NameAndType} entry referenced by another entry
 178      * denoted by {@code which} in {@code constantPool}.
 179      *
 180      * The behavior of this method is undefined if {@code which} does not denote a entry that
 181      * references a {@code JVM_CONSTANT_NameAndType} entry.
 182      */
 183     native String lookupNameInPool(HotSpotConstantPool constantPool, int which);
 184 
 185     /**
 186      * Gets the signature of the {@code JVM_CONSTANT_NameAndType} entry referenced by another entry
 187      * denoted by {@code which} in {@code constantPool}.
 188      *
 189      * The behavior of this method is undefined if {@code which} does not denote a entry that
 190      * references a {@code JVM_CONSTANT_NameAndType} entry.
 191      */
 192     native String lookupSignatureInPool(HotSpotConstantPool constantPool, int which);
 193 
 194     /**
 195      * Gets the {@code JVM_CONSTANT_Class} index from the entry at index {@code cpi} in
 196      * {@code constantPool}.
 197      *
 198      * The behavior of this method is undefined if {@code cpi} does not denote an entry containing a
 199      * {@code JVM_CONSTANT_Class} index.
 200      */
 201     native int lookupKlassRefIndexInPool(HotSpotConstantPool constantPool, int cpi);
 202 
 203     /**
 204      * Looks up a class denoted by the {@code JVM_CONSTANT_Class} entry at index {@code cpi} in
 205      * {@code constantPool}. This method does not perform any resolution.
 206      *
 207      * The behavior of this method is undefined if {@code cpi} does not denote a
 208      * {@code JVM_CONSTANT_Class} entry.
 209      *
 210      * @return the resolved class entry or a String otherwise
 211      */
 212     native Object lookupKlassInPool(HotSpotConstantPool constantPool, int cpi);
 213 
 214     /**
 215      * Looks up a method denoted by the entry at index {@code cpi} in {@code constantPool}. This
 216      * method does not perform any resolution.
 217      *
 218      * The behavior of this method is undefined if {@code cpi} does not denote an entry representing
 219      * a method.
 220      *
 221      * @param opcode the opcode of the instruction for which the lookup is being performed or
 222      *            {@code -1}. If non-negative, then resolution checks specific to the bytecode it
 223      *            denotes are performed if the method is already resolved. Should any of these
 224      *            checks fail, 0 is returned.
 225      * @return the resolved method entry, 0 otherwise
 226      */
 227     native HotSpotResolvedJavaMethodImpl lookupMethodInPool(HotSpotConstantPool constantPool, int cpi, byte opcode);
 228 
 229     /**
 230      * Ensures that the type referenced by the specified {@code JVM_CONSTANT_InvokeDynamic} entry at
 231      * index {@code cpi} in {@code constantPool} is loaded and initialized.
 232      *
 233      * The behavior of this method is undefined if {@code cpi} does not denote a
 234      * {@code JVM_CONSTANT_InvokeDynamic} entry.
 235      */
 236     native void resolveInvokeDynamicInPool(HotSpotConstantPool constantPool, int cpi);
 237 
 238     /**
 239      * Ensures that the type referenced by the entry for a <a
 240      * href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-2.html#jvms-2.9">signature
 241      * polymorphic</a> method at index {@code cpi} in {@code constantPool} is loaded and
 242      * initialized.
 243      *
 244      * The behavior of this method is undefined if {@code cpi} does not denote an entry representing
 245      * a signature polymorphic method.
 246      */
 247     native void resolveInvokeHandleInPool(HotSpotConstantPool constantPool, int cpi);
 248 
 249     /**
 250      * Gets the resolved type denoted by the entry at index {@code cpi} in {@code constantPool}.
 251      *
 252      * The behavior of this method is undefined if {@code cpi} does not denote an entry representing
 253      * a class.
 254      *
 255      * @throws LinkageError if resolution failed
 256      */
 257     native HotSpotResolvedObjectTypeImpl resolveTypeInPool(HotSpotConstantPool constantPool, int cpi) throws LinkageError;
 258 
 259     /**
 260      * Looks up and attempts to resolve the {@code JVM_CONSTANT_Field} entry at index {@code cpi} in
 261      * {@code constantPool}. The values returned in {@code info} are:
 262      *
 263      * <pre>
 264      *     [(int) flags,   // only valid if field is resolved
 265      *      (int) offset]  // only valid if field is resolved
 266      * </pre>
 267      *
 268      * The behavior of this method is undefined if {@code cpi} does not denote a
 269      * {@code JVM_CONSTANT_Field} entry.
 270      *
 271      * @param info an array in which the details of the field are returned
 272      * @return the type defining the field if resolution is successful, 0 otherwise
 273      */
 274     native HotSpotResolvedObjectTypeImpl resolveFieldInPool(HotSpotConstantPool constantPool, int cpi, byte opcode, long[] info);
 275 
 276     /**
 277      * Converts {@code cpci} from an index into the cache for {@code constantPool} to an index
 278      * directly into {@code constantPool}.
 279      *
 280      * The behavior of this method is undefined if {@code ccpi} is an invalid constant pool cache
 281      * index.
 282      */
 283     native int constantPoolRemapInstructionOperandFromCache(HotSpotConstantPool constantPool, int cpci);
 284 
 285     /**
 286      * Gets the appendix object (if any) associated with the entry at index {@code cpi} in
 287      * {@code constantPool}.
 288      */
 289     native Object lookupAppendixInPool(HotSpotConstantPool constantPool, int cpi);
 290 
 291     /**
 292      * Installs the result of a compilation into the code cache.
 293      *
 294      * @param target the target where this code should be installed
 295      * @param compiledCode the result of a compilation
 296      * @param code the details of the installed CodeBlob are written to this object
 297      * @return the outcome of the installation which will be one of
 298      *         {@link HotSpotVMConfig#codeInstallResultOk},
 299      *         {@link HotSpotVMConfig#codeInstallResultCacheFull},
 300      *         {@link HotSpotVMConfig#codeInstallResultCodeTooLarge},
 301      *         {@link HotSpotVMConfig#codeInstallResultDependenciesFailed} or
 302      *         {@link HotSpotVMConfig#codeInstallResultDependenciesInvalid}.
 303      */
 304     public native int installCode(TargetDescription target, HotSpotCompiledCode compiledCode, InstalledCode code, SpeculationLog speculationLog);
 305 
 306     public native int getMetadata(TargetDescription target, HotSpotCompiledCode compiledCode, HotSpotMetaData metaData);
 307 
 308     /**
 309      * Notifies the VM of statistics for a completed compilation.
 310      *
 311      * @param id the identifier of the compilation
 312      * @param method the method compiled
 313      * @param osr specifies if the compilation was for on-stack-replacement
 314      * @param processedBytecodes the number of bytecodes processed during the compilation, including
 315      *            the bytecodes of all inlined methods
 316      * @param time the amount time spent compiling {@code method}
 317      * @param timeUnitsPerSecond the granularity of the units for the {@code time} value
 318      * @param installedCode the nmethod installed as a result of the compilation
 319      */
 320     public synchronized native void notifyCompilationStatistics(int id, HotSpotResolvedJavaMethodImpl method, boolean osr, int processedBytecodes, long time, long timeUnitsPerSecond,
 321                     InstalledCode installedCode);
 322 
 323     /**
 324      * Resets all compilation statistics.
 325      */
 326     public native void resetCompilationStatistics();
 327 
 328     /**
 329      * Initializes the fields of {@code config}.
 330      */
 331     native long initializeConfiguration();
 332 
 333     /**
 334      * Resolves the implementation of {@code method} for virtual dispatches on objects of dynamic
 335      * type {@code exactReceiver}. This resolution process only searches "up" the class hierarchy of
 336      * {@code exactReceiver}.
 337      *
 338      * @param caller the caller or context type used to perform access checks
 339      * @return the link-time resolved method (might be abstract) or {@code 0} if it can not be
 340      *         linked
 341      */
 342     native HotSpotResolvedJavaMethodImpl resolveMethod(HotSpotResolvedObjectTypeImpl exactReceiver, HotSpotResolvedJavaMethodImpl method, HotSpotResolvedObjectTypeImpl caller);
 343 
 344     /**
 345      * Gets the static initializer of {@code type}.
 346      *
 347      * @return 0 if {@code type} has no static initializer
 348      */
 349     native HotSpotResolvedJavaMethodImpl getClassInitializer(HotSpotResolvedObjectTypeImpl type);
 350 
 351     /**
 352      * Determines if {@code type} or any of its currently loaded subclasses overrides
 353      * {@code Object.finalize()}.
 354      */
 355     native boolean hasFinalizableSubclass(HotSpotResolvedObjectTypeImpl type);
 356 
 357     /**
 358      * Gets the method corresponding to {@code holder} and slot number {@code slot} (i.e.
 359      * {@link Method#slot} or {@link Constructor#slot}).
 360      */
 361     native HotSpotResolvedJavaMethodImpl getResolvedJavaMethodAtSlot(Class<?> holder, int slot);
 362 
 363     /**
 364      * Gets the maximum absolute offset of a PC relative call to {@code address} from any position
 365      * in the code cache.
 366      *
 367      * @param address an address that may be called from any code in the code cache
 368      * @return -1 if {@code address == 0}
 369      */
 370     public native long getMaxCallTargetOffset(long address);
 371 
 372     /**
 373      * Gets a textual disassembly of {@code codeBlob}.
 374      *
 375      * @return a non-zero length string containing a disassembly of {@code codeBlob} or null if
 376      *         {@code codeBlob} could not be disassembled for some reason
 377      */
 378     // The HotSpot disassembler seems not to be thread safe so it's better to synchronize its usage
 379     public synchronized native String disassembleCodeBlob(long codeBlob);
 380 
 381     /**
 382      * Gets a stack trace element for {@code method} at bytecode index {@code bci}.
 383      */
 384     native StackTraceElement getStackTraceElement(HotSpotResolvedJavaMethodImpl method, int bci);
 385 
 386     /**
 387      * Executes some {@code installedCode} with arguments {@code args}.
 388      *
 389      * @return the result of executing {@code installedCode}
 390      * @throws InvalidInstalledCodeException if {@code installedCode} has been invalidated
 391      */
 392     native Object executeInstalledCode(Object[] args, InstalledCode installedCode) throws InvalidInstalledCodeException;
 393 
 394     /**
 395      * Gets the line number table for {@code method}. The line number table is encoded as (bci,
 396      * source line number) pairs.
 397      *
 398      * @return the line number table for {@code method} or null if it doesn't have one
 399      */
 400     native long[] getLineNumberTable(HotSpotResolvedJavaMethodImpl method);
 401 
 402     /**
 403      * Gets the number of entries in the local variable table for {@code method}.
 404      *
 405      * @return the number of entries in the local variable table for {@code method}
 406      */
 407     native int getLocalVariableTableLength(HotSpotResolvedJavaMethodImpl method);
 408 
 409     /**
 410      * Gets the address of the first entry in the local variable table for {@code method}.
 411      *
 412      * Each entry is a native object described by these fields:
 413      *
 414      * <ul>
 415      * <li>{@link HotSpotVMConfig#localVariableTableElementSize}</li>
 416      * <li>{@link HotSpotVMConfig#localVariableTableElementLengthOffset}</li>
 417      * <li>{@link HotSpotVMConfig#localVariableTableElementNameCpIndexOffset}</li>
 418      * <li>{@link HotSpotVMConfig#localVariableTableElementDescriptorCpIndexOffset}</li>
 419      * <li>{@link HotSpotVMConfig#localVariableTableElementSignatureCpIndexOffset}
 420      * <li>{@link HotSpotVMConfig#localVariableTableElementSlotOffset}
 421      * <li>{@link HotSpotVMConfig#localVariableTableElementStartBciOffset}
 422      * </ul>
 423      *
 424      * @return 0 if {@code method} does not have a local variable table
 425      */
 426     native long getLocalVariableTableStart(HotSpotResolvedJavaMethodImpl method);
 427 
 428     /**
 429      * Reads an object pointer within a VM data structure. That is, any {@link HotSpotVMField} whose
 430      * {@link HotSpotVMField#type() type} is {@code "oop"} (e.g.,
 431      * {@code ArrayKlass::_component_mirror}, {@code Klass::_java_mirror},
 432      * {@code JavaThread::_threadObj}).
 433      *
 434      * Note that {@link Unsafe#getObject(Object, long)} cannot be used for this since it does a
 435      * {@code narrowOop} read if the VM is using compressed oops whereas oops within VM data
 436      * structures are (currently) always uncompressed.
 437      *
 438      * @param address address of an oop field within a VM data structure
 439      */
 440     native Object readUncompressedOop(long address);
 441 
 442     /**
 443      * Determines if {@code method} should not be inlined or compiled.
 444      */
 445     native void doNotInlineOrCompile(HotSpotResolvedJavaMethodImpl method);
 446 
 447     /**
 448      * Invalidates the profiling information for {@code method} and (re)initializes it such that
 449      * profiling restarts upon its next invocation.
 450      */
 451     native void reprofile(HotSpotResolvedJavaMethodImpl method);
 452 
 453     /**
 454      * Invalidates {@code installedCode} such that {@link InvalidInstalledCodeException} will be
 455      * raised the next time {@code installedCode} is executed.
 456      */
 457     public native void invalidateInstalledCode(InstalledCode installedCode);
 458 
 459     /**
 460      * Collects the current values of all JVMCI benchmark counters, summed up over all threads.
 461      */
 462     public native long[] collectCounters();
 463 
 464     /**
 465      * Determines if {@code metaspaceMethodData} is mature.
 466      */
 467     native boolean isMature(long metaspaceMethodData);
 468 
 469     /**
 470      * Generate a unique id to identify the result of the compile.
 471      */
 472     native int allocateCompileId(HotSpotResolvedJavaMethodImpl method, int entryBCI);
 473 
 474     /**
 475      * Determines if {@code method} has OSR compiled code identified by {@code entryBCI} for
 476      * compilation level {@code level}.
 477      */
 478     native boolean hasCompiledCodeForOSR(HotSpotResolvedJavaMethodImpl method, int entryBCI, int level);
 479 
 480     /**
 481      * Gets the value of {@code metaspaceSymbol} as a String.
 482      */
 483     native String getSymbol(long metaspaceSymbol);
 484 
 485     /**
 486      * Looks for the next Java stack frame matching an entry in {@code methods}.
 487      *
 488      * @param frame the starting point of the search, where {@code null} refers to the topmost frame
 489      * @param methods the methods to look for, where {@code null} means that any frame is returned
 490      * @return the frame, or {@code null} if the end of the stack was reached during the search
 491      */
 492     public native HotSpotStackFrameReference getNextStackFrame(HotSpotStackFrameReference frame, HotSpotResolvedJavaMethodImpl[] methods, int initialSkip);
 493 
 494     /**
 495      * Materializes all virtual objects within {@code stackFrame} updates its locals.
 496      *
 497      * @param invalidate if {@code true}, the compiled method for the stack frame will be
 498      *            invalidated.
 499      */
 500     native void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate);
 501 
 502     /**
 503      * Gets the v-table index for interface method {@code method} in the receiver {@code type} or
 504      * {@link HotSpotVMConfig#invalidVtableIndex} if {@code method} is not in {@code type}'s
 505      * v-table.
 506      *
 507      * @throws InternalError if {@code type} is an interface or {@code method} is not held by an
 508      *             interface or class represented by {@code type} is not initialized
 509      */
 510     native int getVtableIndexForInterfaceMethod(HotSpotResolvedObjectTypeImpl type, HotSpotResolvedJavaMethodImpl method);
 511 
 512     /**
 513      * Determines if debug info should also be emitted at non-safepoint locations.
 514      */
 515     public native boolean shouldDebugNonSafepoints();
 516 
 517     /**
 518      * Writes {@code length} bytes from {@code bytes} starting at offset {@code offset} to the
 519      * HotSpot's log stream.
 520      *
 521      * @exception NullPointerException if <code>bytes</code> is <code>null</code>.
 522      * @exception IndexOutOfBoundsException if copying would cause access of data outside array
 523      *                bounds.
 524      */
 525     public native void writeDebugOutput(byte[] bytes, int offset, int length);
 526 
 527     /**
 528      * Flush HotSpot's log stream.
 529      */
 530     public native void flushDebugOutput();
 531 
 532     /**
 533      * Read a value representing a metaspace Method* and return the
 534      * {@link HotSpotResolvedJavaMethodImpl} wrapping it. This method does no checking that the
 535      * location actually contains a valid Method*. If the {@code base} object is a
 536      * {@link HotSpotResolvedJavaMethodImpl}, {@link HotSpotConstantPool} or
 537      * {@link HotSpotResolvedObjectTypeImpl} then the metaspace pointer is fetched from that object
 538      * and used as the base. Otherwise the object itself is used as the base.
 539      *
 540      * @param base an object to read from or null
 541      * @param displacement
 542      * @return null or the resolved method for this location
 543      */
 544     native HotSpotResolvedJavaMethodImpl getResolvedJavaMethod(Object base, long displacement);
 545 
 546     /**
 547      * Read a value representing a metaspace ConstantPool* and return the
 548      * {@link HotSpotConstantPool} wrapping it. This method does no checking that the location
 549      * actually contains a valid ConstantPool*. If the {@code base} object is a
 550      * {@link HotSpotResolvedJavaMethodImpl}, {@link HotSpotConstantPool} or
 551      * {@link HotSpotResolvedObjectTypeImpl} then the metaspace pointer is fetched from that object
 552      * and used as the base. Otherwise the object itself is used as the base.
 553      *
 554      * @param base an object to read from or null
 555      * @param displacement
 556      * @return null or the resolved method for this location
 557      */
 558     native HotSpotConstantPool getConstantPool(Object base, long displacement);
 559 
 560     /**
 561      * Read a value representing a metaspace Klass* and return the
 562      * {@link HotSpotResolvedObjectTypeImpl} wrapping it. The method does no checking that the
 563      * location actually contains a valid Klass*. If the {@code base} object is a
 564      * {@link HotSpotResolvedJavaMethodImpl}, {@link HotSpotConstantPool} or
 565      * {@link HotSpotResolvedObjectTypeImpl} then the metaspace pointer is fetched from that object
 566      * and used as the base. Otherwise the object itself is used as the base.
 567      *
 568      * @param base an object to read from or null
 569      * @param displacement
 570      * @param compressed true if the location contains a compressed Klass*
 571      * @return null or the resolved method for this location
 572      */
 573     native HotSpotResolvedObjectTypeImpl getResolvedJavaType(Object base, long displacement, boolean compressed);
 574 }