/* * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/** * Returns the singleton WhiteBox instance. * * The returned WhiteBox object should be carefully guarded * by the caller, since it can be used to read and write data * at arbitrary memory addresses. It must never be passed to * untrusted code.
*/ publicsynchronizedstatic WhiteBox getWhiteBox() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); if (sm != null) {
sm.checkPermission(new WhiteBoxPermission("getInstance"));
} return instance;
}
static {
registerNatives();
}
// Get the maximum heap size supporting COOPs publicnativelong getCompressedOopsMaxHeapSize(); // Arguments publicnativevoid printHeapSizes();
// Runtime // Make sure class name is in the correct format publicint countAliveClasses(String name) { return countAliveClasses0(name.replace('.', '/'));
} privatenativeint countAliveClasses0(String name);
// Perform a complete concurrent GC cycle, using concurrent GC breakpoints. // Completes any in-progress cycle before performing the requested cycle. // Returns true if the cycle completed successfully. If the cycle was not // successful (e.g. it was aborted), then throws RuntimeException if // errorIfFail is true, returning false otherwise. publicboolean g1RunConcurrentGC(boolean errorIfFail) { try { // Take control, waiting until any in-progress cycle completes.
concurrentGCAcquireControl(); int count = g1CompletedConcurrentMarkCycles();
concurrentGCRunTo(AFTER_MARKING_STARTED, false);
concurrentGCRunToIdle(); if (count < g1CompletedConcurrentMarkCycles()) { returntrue;
} elseif (errorIfFail) { thrownew RuntimeException("Concurrent GC aborted");
} else { returnfalse;
}
} finally {
concurrentGCReleaseControl();
}
}
// Start a concurrent GC cycle, using concurrent GC breakpoints. // The concurrent GC will continue in parallel with the caller. // Completes any in-progress cycle before starting the requested cycle. publicvoid g1StartConcurrentGC() { try { // Take control, waiting until any in-progress cycle completes.
concurrentGCAcquireControl();
concurrentGCRunTo(AFTER_MARKING_STARTED, false);
} finally { // Release control, permitting the cycle to complete.
concurrentGCReleaseControl();
}
}
/** * Enumerates old regions with liveness less than specified and produces some statistics * @param liveness percent of region's liveness (live_objects / total_region_size * 100). * @return long[3] array where long[0] - total count of old regions * long[1] - total memory of old regions * long[2] - lowest estimation of total memory of old regions to be freed (non-full * regions are not included)
*/ publicnativelong[] g1GetMixedGCInfo(int liveness);
// NMT publicnativelong NMTMalloc(long size); publicnativevoid NMTFree(long mem); publicnativelong NMTReserveMemory(long size); publicnativelong NMTAttemptReserveMemoryAt(long addr, long size); publicnativevoid NMTCommitMemory(long addr, long size); publicnativevoid NMTUncommitMemory(long addr, long size); publicnativevoid NMTReleaseMemory(long addr, long size); publicnativelong NMTMallocWithPseudoStack(long size, int index); publicnativelong NMTMallocWithPseudoStackAndType(long size, int index, int type); publicnativeint NMTGetHashSize(); publicnativelong NMTNewArena(long initSize); publicnativevoid NMTFreeArena(long arena); publicnativevoid NMTArenaMalloc(long arena, long size);
publicboolean isMethodCompiled(Executable method) { return isMethodCompiled(method, false/*not osr*/);
} privatenativeboolean isMethodCompiled0(Executable method, boolean isOsr); publicboolean isMethodCompiled(Executable method, boolean isOsr){
Objects.requireNonNull(method); return isMethodCompiled0(method, isOsr);
} publicboolean isMethodCompilable(Executable method) { return isMethodCompilable(method, -1 /*any*/);
} publicboolean isMethodCompilable(Executable method, int compLevel) { return isMethodCompilable(method, compLevel, false/*not osr*/);
} privatenativeboolean isMethodCompilable0(Executable method, int compLevel, boolean isOsr); publicboolean isMethodCompilable(Executable method, int compLevel, boolean isOsr) {
Objects.requireNonNull(method); return isMethodCompilable0(method, compLevel, isOsr);
} privatenativeboolean isMethodQueuedForCompilation0(Executable method); publicboolean isMethodQueuedForCompilation(Executable method) {
Objects.requireNonNull(method); return isMethodQueuedForCompilation0(method);
} // Determine if the compiler corresponding to the compilation level 'compLevel' // and to the compilation context 'compilation_context' provides an intrinsic // for the method 'method'. An intrinsic is available for method 'method' if: // - the intrinsic is enabled (by using the appropriate command-line flag) and // - the platform on which the VM is running provides the instructions necessary // for the compiler to generate the intrinsic code. // // The compilation context is related to using the DisableIntrinsic flag on a // per-method level, see hotspot/src/share/vm/compiler/abstractCompiler.hpp // for more details. publicboolean isIntrinsicAvailable(Executable method,
Executable compilationContext, int compLevel) {
Objects.requireNonNull(method); return isIntrinsicAvailable0(method, compilationContext, compLevel);
} // If usage of the DisableIntrinsic flag is not expected (or the usage can be ignored), // use the below method that does not require the compilation context as argument. publicboolean isIntrinsicAvailable(Executable method, int compLevel) { return isIntrinsicAvailable(method, null, compLevel);
} privatenativeboolean isIntrinsicAvailable0(Executable method,
Executable compilationContext, int compLevel); publicint deoptimizeMethod(Executable method) { return deoptimizeMethod(method, false/*not osr*/);
} privatenativeint deoptimizeMethod0(Executable method, boolean isOsr); publicint deoptimizeMethod(Executable method, boolean isOsr) {
Objects.requireNonNull(method); return deoptimizeMethod0(method, isOsr);
} publicvoid makeMethodNotCompilable(Executable method) {
makeMethodNotCompilable(method, -1 /*any*/);
} publicvoid makeMethodNotCompilable(Executable method, int compLevel) {
makeMethodNotCompilable(method, compLevel, false/*not osr*/);
} privatenativevoid makeMethodNotCompilable0(Executable method, int compLevel, boolean isOsr); publicvoid makeMethodNotCompilable(Executable method, int compLevel, boolean isOsr) {
Objects.requireNonNull(method);
makeMethodNotCompilable0(method, compLevel, isOsr);
} publicint getMethodCompilationLevel(Executable method) { return getMethodCompilationLevel(method, false/*not osr*/);
} privatenativeint getMethodCompilationLevel0(Executable method, boolean isOsr); publicint getMethodCompilationLevel(Executable method, boolean isOsr) {
Objects.requireNonNull(method); return getMethodCompilationLevel0(method, isOsr);
} publicint getMethodDecompileCount(Executable method) {
Objects.requireNonNull(method); return getMethodDecompileCount0(method);
} privatenativeint getMethodDecompileCount0(Executable method); // Get the total trap count of a method. If the trap count for a specific reason // did overflow, this includes the overflow trap count of the method. publicint getMethodTrapCount(Executable method) {
Objects.requireNonNull(method); return getMethodTrapCount0(method, null);
} // Get the trap count of a method for a specific reason. If the trap count for // that reason did overflow, this includes the overflow trap count of the method. publicint getMethodTrapCount(Executable method, String reason) {
Objects.requireNonNull(method); return getMethodTrapCount0(method, reason);
} privatenativeint getMethodTrapCount0(Executable method, String reason); // Get the total deopt count. publicint getDeoptCount() { return getDeoptCount0(null, null);
} // Get the deopt count for a specific reason and a specific action. If either // one of 'reason' or 'action' is null, the method returns the sum of all // deoptimizations with the specific 'action' or 'reason' respectively. // If both arguments are null, the method returns the total deopt count. publicint getDeoptCount(String reason, String action) { return getDeoptCount0(reason, action);
} privatenativeint getDeoptCount0(String reason, String action); privatenativeboolean testSetDontInlineMethod0(Executable method, boolean value); publicboolean testSetDontInlineMethod(Executable method, boolean value) {
Objects.requireNonNull(method); return testSetDontInlineMethod0(method, value);
} publicint getCompileQueuesSize() { return getCompileQueueSize(-1 /*any*/);
} publicnativeint getCompileQueueSize(int compLevel); privatenativeboolean testSetForceInlineMethod0(Executable method, boolean value); publicboolean testSetForceInlineMethod(Executable method, boolean value) {
Objects.requireNonNull(method); return testSetForceInlineMethod0(method, value);
} publicboolean enqueueMethodForCompilation(Executable method, int compLevel) { return enqueueMethodForCompilation(method, compLevel, -1 /*InvocationEntryBci*/);
} privatenativeboolean enqueueMethodForCompilation0(Executable method, int compLevel, int entry_bci); publicboolean enqueueMethodForCompilation(Executable method, int compLevel, int entry_bci) {
Objects.requireNonNull(method); return enqueueMethodForCompilation0(method, compLevel, entry_bci);
} privatenativeboolean enqueueInitializerForCompilation0(Class<?> aClass, int compLevel); publicboolean enqueueInitializerForCompilation(Class<?> aClass, int compLevel) {
Objects.requireNonNull(aClass); return enqueueInitializerForCompilation0(aClass, compLevel);
} privatenativevoid clearMethodState0(Executable method); publicnativevoid markMethodProfiled(Executable method); publicvoid clearMethodState(Executable method) {
Objects.requireNonNull(method);
clearMethodState0(method);
} publicnativevoid lockCompilation(); publicnativevoid unlockCompilation(); privatenativeint getMethodEntryBci0(Executable method); publicint getMethodEntryBci(Executable method) {
Objects.requireNonNull(method); return getMethodEntryBci0(method);
} privatenative Object[] getNMethod0(Executable method, boolean isOsr); public Object[] getNMethod(Executable method, boolean isOsr) {
Objects.requireNonNull(method); return getNMethod0(method, isOsr);
} publicnativelong allocateCodeBlob(int size, int type); publiclong allocateCodeBlob(long size, int type) { int intSize = (int) size; if ((long) intSize != size || size < 0) { thrownew IllegalArgumentException( "size argument has illegal value " + size);
} return allocateCodeBlob( intSize, type);
} publicnativevoid freeCodeBlob(long addr); publicnative Object[] getCodeHeapEntries(int type); publicnativeint getCompilationActivityMode(); privatenativelong getMethodData0(Executable method); publiclong getMethodData(Executable method) {
Objects.requireNonNull(method); return getMethodData0(method);
} publicnative Object[] getCodeBlob(long addr);
// All collectors supporting concurrent GC breakpoints are expected // to provide at least the following breakpoints. publicfinal String AFTER_MARKING_STARTED = "AFTER MARKING STARTED"; publicfinal String BEFORE_MARKING_COMPLETED = "BEFORE MARKING COMPLETED";
// Collectors supporting concurrent GC breakpoints that do reference // processing concurrently should provide the following breakpoint. publicfinal String AFTER_CONCURRENT_REFERENCE_PROCESSING_STARTED = "AFTER CONCURRENT REFERENCE PROCESSING STARTED";
// Allow concurrent GC to run to breakpoint. // Throws IllegalStateException if reached end of cycle first. publicvoid concurrentGCRunTo(String breakpoint) {
concurrentGCRunTo(breakpoint, true);
}
// Allow concurrent GC to run to breakpoint. // Returns true if reached breakpoint. If reached end of cycle first, // then throws IllegalStateException if errorIfFail is true, returning // false otherwise. publicboolean concurrentGCRunTo(String breakpoint, boolean errorIfFail) {
checkConcurrentGCBreakpointsSupported();
checkConcurrentGCIsControlled(); if (breakpoint == null) { thrownew NullPointerException("null breakpoint");
} elseif (concurrentGCRunTo0(breakpoint)) { returntrue;
} elseif (errorIfFail) { thrownew IllegalStateException("Missed requested breakpoint \"" + breakpoint + "\"");
} else { returnfalse;
}
}
// Tests on ReservedSpace/VirtualSpace classes publicnativeint stressVirtualSpaceResize(long reservedSpaceSize, long magnitude, longiterations); publicnativevoid readFromNoaccessArea(); publicnativelong getThreadStackSize(); publicnativelong getThreadRemainingStackSize();
// CPU features publicnative String getCPUFeatures();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.