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> 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 */ 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 } | 1 /* 2 * Copyright (c) 2011, 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 static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; 27 import static jdk.vm.ci.inittimer.InitTimer.timer; 28 29 import java.lang.reflect.Constructor; 30 import java.lang.reflect.Method; 31 32 import jdk.vm.ci.code.InstalledCode; 33 import jdk.vm.ci.code.InvalidInstalledCodeException; 34 import jdk.vm.ci.code.TargetDescription; 35 import jdk.vm.ci.hotspotvmconfig.HotSpotVMField; 36 import jdk.vm.ci.inittimer.InitTimer; 37 import jdk.vm.ci.meta.JavaType; 38 import jdk.vm.ci.meta.ResolvedJavaMethod; 39 import jdk.vm.ci.meta.ResolvedJavaType; 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 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 * Gets the {@link CompilerToVM} instance associated with the singleton 66 * {@link HotSpotJVMCIRuntime} instance. 67 */ 68 public static CompilerToVM compilerToVM() { 69 return runtime().getCompilerToVM(); 70 } 71 72 /** 73 * Copies the original bytecode of {@code method} into a new byte array and returns it. 74 * 75 * @return a new byte array containing the original bytecode of {@code method} 76 */ 77 native byte[] getBytecode(HotSpotResolvedJavaMethodImpl method); 78 79 /** 80 * Gets the number of entries in {@code method}'s exception handler table or 0 if it has not 81 * exception handler table. 82 */ 83 native int getExceptionTableLength(HotSpotResolvedJavaMethodImpl method); 84 85 /** 86 * Gets the address of the first entry in {@code method}'s exception handler table. 87 * 88 * Each entry is a native object described by these fields: 89 * 90 * <ul> 91 * <li>{@link HotSpotVMConfig#exceptionTableElementSize}</li> 92 * <li>{@link HotSpotVMConfig#exceptionTableElementStartPcOffset}</li> 292 293 /** 294 * Gets the appendix object (if any) associated with the entry at index {@code cpi} in 295 * {@code constantPool}. 296 */ 297 native Object lookupAppendixInPool(HotSpotConstantPool constantPool, int cpi); 298 299 /** 300 * Installs the result of a compilation into the code cache. 301 * 302 * @param target the target where this code should be installed 303 * @param compiledCode the result of a compilation 304 * @param code the details of the installed CodeBlob are written to this object 305 * @return the outcome of the installation which will be one of 306 * {@link HotSpotVMConfig#codeInstallResultOk}, 307 * {@link HotSpotVMConfig#codeInstallResultCacheFull}, 308 * {@link HotSpotVMConfig#codeInstallResultCodeTooLarge}, 309 * {@link HotSpotVMConfig#codeInstallResultDependenciesFailed} or 310 * {@link HotSpotVMConfig#codeInstallResultDependenciesInvalid}. 311 */ 312 native int installCode(TargetDescription target, HotSpotCompiledCode compiledCode, InstalledCode code, HotSpotSpeculationLog speculationLog); 313 314 public native int getMetadata(TargetDescription target, HotSpotCompiledCode compiledCode, HotSpotMetaData metaData); 315 316 /** 317 * Notifies the VM of statistics for a completed compilation. 318 * 319 * @param id the identifier of the compilation 320 * @param method the method compiled 321 * @param osr specifies if the compilation was for on-stack-replacement 322 * @param processedBytecodes the number of bytecodes processed during the compilation, including 323 * the bytecodes of all inlined methods 324 * @param time the amount time spent compiling {@code method} 325 * @param timeUnitsPerSecond the granularity of the units for the {@code time} value 326 * @param installedCode the nmethod installed as a result of the compilation 327 */ 328 synchronized native void notifyCompilationStatistics(int id, HotSpotResolvedJavaMethodImpl method, boolean osr, int processedBytecodes, long time, long timeUnitsPerSecond, 329 InstalledCode installedCode); 330 331 /** 332 * Resets all compilation statistics. 333 */ 334 native void resetCompilationStatistics(); 335 336 /** 337 * Initializes the fields of {@code config}. 338 */ 339 native long initializeConfiguration(HotSpotVMConfig config); 340 341 /** 342 * Resolves the implementation of {@code method} for virtual dispatches on objects of dynamic 343 * type {@code exactReceiver}. This resolution process only searches "up" the class hierarchy of 344 * {@code exactReceiver}. 345 * 346 * @param caller the caller or context type used to perform access checks 347 * @return the link-time resolved method (might be abstract) or {@code 0} if it can not be 348 * linked 349 */ 350 native HotSpotResolvedJavaMethodImpl resolveMethod(HotSpotResolvedObjectTypeImpl exactReceiver, HotSpotResolvedJavaMethodImpl method, HotSpotResolvedObjectTypeImpl caller); 351 352 /** 353 * Gets the static initializer of {@code type}. 354 * 355 * @return 0 if {@code type} has no static initializer 356 */ 357 native HotSpotResolvedJavaMethodImpl getClassInitializer(HotSpotResolvedObjectTypeImpl type); 358 359 /** 360 * Determines if {@code type} or any of its currently loaded subclasses overrides 361 * {@code Object.finalize()}. 362 */ 363 native boolean hasFinalizableSubclass(HotSpotResolvedObjectTypeImpl type); 364 365 /** 366 * Gets the method corresponding to {@code holder} and slot number {@code slot} (i.e. 367 * {@link Method#slot} or {@link Constructor#slot}). 368 */ 369 native HotSpotResolvedJavaMethodImpl getResolvedJavaMethodAtSlot(Class<?> holder, int slot); 370 371 /** 372 * Gets the maximum absolute offset of a PC relative call to {@code address} from any position 373 * in the code cache. 374 * 375 * @param address an address that may be called from any code in the code cache 376 * @return -1 if {@code address == 0} 377 */ 378 native long getMaxCallTargetOffset(long address); 379 380 /** 381 * Gets a textual disassembly of {@code codeBlob}. 382 * 383 * @return a non-zero length string containing a disassembly of {@code codeBlob} or null if 384 * {@code codeBlob} could not be disassembled for some reason 385 */ 386 // The HotSpot disassembler seems not to be thread safe so it's better to synchronize its usage 387 synchronized native String disassembleCodeBlob(InstalledCode installedCode); 388 389 /** 390 * Gets a stack trace element for {@code method} at bytecode index {@code bci}. 391 */ 392 native StackTraceElement getStackTraceElement(HotSpotResolvedJavaMethodImpl method, int bci); 393 394 /** 395 * Executes some {@code installedCode} with arguments {@code args}. 396 * 397 * @return the result of executing {@code installedCode} 398 * @throws InvalidInstalledCodeException if {@code installedCode} has been invalidated 399 */ 400 native Object executeInstalledCode(Object[] args, InstalledCode installedCode) throws InvalidInstalledCodeException; 401 402 /** 403 * Gets the line number table for {@code method}. The line number table is encoded as (bci, 404 * source line number) pairs. 405 * 406 * @return the line number table for {@code method} or null if it doesn't have one 407 */ 445 * 446 * @param address address of an oop field within a VM data structure 447 */ 448 native Object readUncompressedOop(long address); 449 450 /** 451 * Determines if {@code method} should not be inlined or compiled. 452 */ 453 native void doNotInlineOrCompile(HotSpotResolvedJavaMethodImpl method); 454 455 /** 456 * Invalidates the profiling information for {@code method} and (re)initializes it such that 457 * profiling restarts upon its next invocation. 458 */ 459 native void reprofile(HotSpotResolvedJavaMethodImpl method); 460 461 /** 462 * Invalidates {@code installedCode} such that {@link InvalidInstalledCodeException} will be 463 * raised the next time {@code installedCode} is executed. 464 */ 465 native void invalidateInstalledCode(InstalledCode installedCode); 466 467 /** 468 * Collects the current values of all JVMCI benchmark counters, summed up over all threads. 469 */ 470 native long[] collectCounters(); 471 472 /** 473 * Determines if {@code metaspaceMethodData} is mature. 474 */ 475 native boolean isMature(long metaspaceMethodData); 476 477 /** 478 * Generate a unique id to identify the result of the compile. 479 */ 480 native int allocateCompileId(HotSpotResolvedJavaMethodImpl method, int entryBCI); 481 482 /** 483 * Determines if {@code method} has OSR compiled code identified by {@code entryBCI} for 484 * compilation level {@code level}. 485 */ 486 native boolean hasCompiledCodeForOSR(HotSpotResolvedJavaMethodImpl method, int entryBCI, int level); 487 488 /** 489 * Gets the value of {@code metaspaceSymbol} as a String. 490 */ 491 native String getSymbol(long metaspaceSymbol); 492 493 /** 494 * Looks for the next Java stack frame matching an entry in {@code methods}. 495 * 496 * @param frame the starting point of the search, where {@code null} refers to the topmost frame 497 * @param methods the methods to look for, where {@code null} means that any frame is returned 498 * @return the frame, or {@code null} if the end of the stack was reached during the search 499 */ 500 native HotSpotStackFrameReference getNextStackFrame(HotSpotStackFrameReference frame, ResolvedJavaMethod[] methods, int initialSkip); 501 502 /** 503 * Materializes all virtual objects within {@code stackFrame} updates its locals. 504 * 505 * @param invalidate if {@code true}, the compiled method for the stack frame will be 506 * invalidated. 507 */ 508 native void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate); 509 510 /** 511 * Gets the v-table index for interface method {@code method} in the receiver {@code type} or 512 * {@link HotSpotVMConfig#invalidVtableIndex} if {@code method} is not in {@code type}'s 513 * v-table. 514 * 515 * @throws InternalError if {@code type} is an interface or {@code method} is not held by an 516 * interface or class represented by {@code type} is not initialized 517 */ 518 native int getVtableIndexForInterfaceMethod(HotSpotResolvedObjectTypeImpl type, HotSpotResolvedJavaMethodImpl method); 519 520 /** 521 * Determines if debug info should also be emitted at non-safepoint locations. 522 */ 523 524 native boolean shouldDebugNonSafepoints(); 525 526 /** 527 * Writes {@code length} bytes from {@code bytes} starting at offset {@code offset} to the 528 * HotSpot's log stream. 529 * 530 * @exception NullPointerException if {@code bytes == null} 531 * @exception IndexOutOfBoundsException if copying would cause access of data outside array 532 * bounds 533 */ 534 native void writeDebugOutput(byte[] bytes, int offset, int length); 535 536 /** 537 * Flush HotSpot's log stream. 538 */ 539 native void flushDebugOutput(); 540 541 /** 542 * Read a HotSpot Method* value from the memory location described by {@code base} plus 543 * {@code displacement} and return the {@link HotSpotResolvedJavaMethodImpl} wrapping it. This 544 * method does no checking that the memory location actually contains a valid pointer and may 545 * crash the VM if an invalid location is provided. If the {@code base} is null then 546 * {@code displacement} is used by itself. If {@code base} is a 547 * {@link HotSpotResolvedJavaMethodImpl}, {@link HotSpotConstantPool} or 548 * {@link HotSpotResolvedObjectTypeImpl} then the metaspace pointer is fetched from that object 549 * and added to {@code displacement}. Any other non-null object type causes an 550 * {@link IllegalArgumentException} to be thrown. 551 * 552 * @param base an object to read from or null 553 * @param displacement 554 * @return null or the resolved method for this location 555 */ 556 native HotSpotResolvedJavaMethodImpl getResolvedJavaMethod(Object base, long displacement); 557 558 /** 559 * Read a HotSpot ConstantPool* value from the memory location described by {@code base} plus 560 * {@code displacement} and return the {@link HotSpotConstantPool} wrapping it. This method does 561 * no checking that the memory location actually contains a valid pointer and may crash the VM 562 * if an invalid location is provided. If the {@code base} is null then {@code displacement} is 563 * used by itself. If {@code base} is a {@link HotSpotResolvedJavaMethodImpl}, 564 * {@link HotSpotConstantPool} or {@link HotSpotResolvedObjectTypeImpl} then the metaspace 565 * pointer is fetched from that object and added to {@code displacement}. Any other non-null 566 * object type causes an {@link IllegalArgumentException} to be thrown. 567 * 568 * @param base an object to read from or null 569 * @param displacement 570 * @return null or the resolved method for this location 571 */ 572 native HotSpotConstantPool getConstantPool(Object base, long displacement); 573 574 /** 575 * Read a HotSpot Klass* value from the memory location described by {@code base} plus 576 * {@code displacement} and return the {@link HotSpotResolvedObjectTypeImpl} wrapping it. This 577 * method does no checking that the memory location actually contains a valid pointer and may 578 * crash the VM if an invalid location is provided. If the {@code base} is null then 579 * {@code displacement} is used by itself. If {@code base} is a 580 * {@link HotSpotResolvedJavaMethodImpl}, {@link HotSpotConstantPool} or 581 * {@link HotSpotResolvedObjectTypeImpl} then the metaspace pointer is fetched from that object 582 * and added to {@code displacement}. Any other non-null object type causes an 583 * {@link IllegalArgumentException} to be thrown. 584 * 585 * @param base an object to read from or null 586 * @param displacement 587 * @param compressed true if the location contains a compressed Klass* 588 * @return null or the resolved method for this location 589 */ 590 native HotSpotResolvedObjectTypeImpl getResolvedJavaType(Object base, long displacement, boolean compressed); 591 592 /** 593 * Return the size of the HotSpot ProfileData* pointed at by {@code position}. If 594 * {@code position} is outside the space of the MethodData then an 595 * {@link IllegalArgumentException} is thrown. A {@code position} inside the MethodData but that 596 * isn't pointing at a valid ProfileData will crash the VM. 597 * 598 * @param metaspaceMethodData 599 * @param position 600 * @return the size of the ProfileData item pointed at by {@code position} 601 * @throws IllegalArgumentException if an out of range position is given 602 */ 603 native int methodDataProfileDataSize(long metaspaceMethodData, int position); 604 } |