test/testlibrary/whitebox/sun/hotspot/WhiteBox.java

Thu, 27 Mar 2014 11:17:26 +0400

author
iignatyev
date
Thu, 27 Mar 2014 11:17:26 +0400
changeset 6525
4abb719c5620
parent 6427
a48e16541e6b
child 6876
710a3c8b516e
child 6963
0c48231c5c84
permissions
-rw-r--r--

8038240: new WB API to get nmethod
Reviewed-by: morris, kvn

mgerdin@3619 1 /*
iignatyev@6525 2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
mgerdin@3619 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
mgerdin@3619 4 *
mgerdin@3619 5 * This code is free software; you can redistribute it and/or modify it
mgerdin@3619 6 * under the terms of the GNU General Public License version 2 only, as
mgerdin@3619 7 * published by the Free Software Foundation.
mgerdin@3619 8 *
mgerdin@3619 9 * This code is distributed in the hope that it will be useful, but WITHOUT
mgerdin@3619 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
mgerdin@3619 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mgerdin@3619 12 * version 2 for more details (a copy is included in the LICENSE file that
mgerdin@3619 13 * accompanied this code).
mgerdin@3619 14 *
mgerdin@3619 15 * You should have received a copy of the GNU General Public License version
mgerdin@3619 16 * 2 along with this work; if not, write to the Free Software Foundation,
mgerdin@3619 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
mgerdin@3619 18 *
mgerdin@3619 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
mgerdin@3619 20 * or visit www.oracle.com if you need additional information or have any
mgerdin@3619 21 * questions.
mgerdin@3619 22 *
mgerdin@3619 23 */
mgerdin@3619 24
mgerdin@3619 25 package sun.hotspot;
iignatyev@4592 26
iignatyev@4951 27 import java.lang.reflect.Executable;
mgerdin@3619 28 import java.security.BasicPermission;
nloodin@3681 29 import sun.hotspot.parser.DiagnosticCommand;
mgerdin@3619 30
mgerdin@3619 31 public class WhiteBox {
mgerdin@3619 32
mgerdin@3619 33 @SuppressWarnings("serial")
mgerdin@3619 34 public static class WhiteBoxPermission extends BasicPermission {
mgerdin@3619 35 public WhiteBoxPermission(String s) {
mgerdin@3619 36 super(s);
mgerdin@3619 37 }
mgerdin@3619 38 }
mgerdin@3619 39
mgerdin@3619 40 private WhiteBox() {}
mgerdin@3619 41 private static final WhiteBox instance = new WhiteBox();
mgerdin@3619 42 private static native void registerNatives();
mgerdin@3619 43
mgerdin@3619 44 /**
mgerdin@3619 45 * Returns the singleton WhiteBox instance.
mgerdin@3619 46 *
mgerdin@3619 47 * The returned WhiteBox object should be carefully guarded
mgerdin@3619 48 * by the caller, since it can be used to read and write data
mgerdin@3619 49 * at arbitrary memory addresses. It must never be passed to
mgerdin@3619 50 * untrusted code.
mgerdin@3619 51 */
mgerdin@3619 52 public synchronized static WhiteBox getWhiteBox() {
mgerdin@3619 53 SecurityManager sm = System.getSecurityManager();
mgerdin@3619 54 if (sm != null) {
mgerdin@3619 55 sm.checkPermission(new WhiteBoxPermission("getInstance"));
mgerdin@3619 56 }
mgerdin@3619 57 return instance;
mgerdin@3619 58 }
mgerdin@3619 59
mgerdin@3619 60 static {
mgerdin@3619 61 registerNatives();
mgerdin@3619 62 }
mgerdin@3619 63
tschatzl@5701 64 // Get the maximum heap size supporting COOPs
tschatzl@5701 65 public native long getCompressedOopsMaxHeapSize();
tschatzl@5073 66 // Arguments
tschatzl@5073 67 public native void printHeapSizes();
tschatzl@5073 68
mgerdin@3619 69 // Memory
mgerdin@3619 70 public native long getObjectAddress(Object o);
mgerdin@3619 71 public native int getHeapOopSize();
mgerdin@3619 72
coleenp@4037 73 // Runtime
coleenp@4037 74 // Make sure class name is in the correct format
coleenp@4037 75 public boolean isClassAlive(String name) {
coleenp@4037 76 return isClassAlive0(name.replace('.', '/'));
coleenp@4037 77 }
coleenp@4037 78 private native boolean isClassAlive0(String name);
coleenp@4037 79
mgerdin@3619 80 // G1
mgerdin@3619 81 public native boolean g1InConcurrentMark();
mgerdin@3619 82 public native boolean g1IsHumongous(Object o);
mgerdin@3619 83 public native long g1NumFreeRegions();
mgerdin@3619 84 public native int g1RegionSize();
nloodin@3681 85 public native Object[] parseCommandLine(String commandline, DiagnosticCommand[] args);
ctornqvi@4512 86
ctornqvi@4512 87 // NMT
ctornqvi@4885 88 public native long NMTMalloc(long size);
ctornqvi@4885 89 public native void NMTFree(long mem);
ctornqvi@4885 90 public native long NMTReserveMemory(long size);
ctornqvi@4885 91 public native void NMTCommitMemory(long addr, long size);
ctornqvi@4885 92 public native void NMTUncommitMemory(long addr, long size);
ctornqvi@4885 93 public native void NMTReleaseMemory(long addr, long size);
ctornqvi@4512 94 public native boolean NMTWaitForDataMerge();
cjplummer@5586 95 public native boolean NMTIsDetailSupported();
iignatyev@4592 96
iignatyev@4592 97 // Compiler
iignatyev@4592 98 public native void deoptimizeAll();
iignatyev@5541 99 public boolean isMethodCompiled(Executable method) {
iignatyev@5541 100 return isMethodCompiled(method, false /*not osr*/);
iignatyev@4908 101 }
iignatyev@5541 102 public native boolean isMethodCompiled(Executable method, boolean isOsr);
iignatyev@5541 103 public boolean isMethodCompilable(Executable method) {
iignatyev@5541 104 return isMethodCompilable(method, -1 /*any*/);
iignatyev@5541 105 }
iignatyev@5541 106 public boolean isMethodCompilable(Executable method, int compLevel) {
iignatyev@5541 107 return isMethodCompilable(method, compLevel, false /*not osr*/);
iignatyev@5541 108 }
iignatyev@5541 109 public native boolean isMethodCompilable(Executable method, int compLevel, boolean isOsr);
iignatyev@4951 110 public native boolean isMethodQueuedForCompilation(Executable method);
iignatyev@5541 111 public int deoptimizeMethod(Executable method) {
iignatyev@5541 112 return deoptimizeMethod(method, false /*not osr*/);
iignatyev@4951 113 }
iignatyev@5541 114 public native int deoptimizeMethod(Executable method, boolean isOsr);
iignatyev@5541 115 public void makeMethodNotCompilable(Executable method) {
iignatyev@5541 116 makeMethodNotCompilable(method, -1 /*any*/);
iignatyev@5541 117 }
iignatyev@5541 118 public void makeMethodNotCompilable(Executable method, int compLevel) {
iignatyev@5541 119 makeMethodNotCompilable(method, compLevel, false /*not osr*/);
iignatyev@5541 120 }
iignatyev@5541 121 public native void makeMethodNotCompilable(Executable method, int compLevel, boolean isOsr);
iignatyev@5541 122 public int getMethodCompilationLevel(Executable method) {
iignatyev@5541 123 return getMethodCompilationLevel(method, false /*not ost*/);
iignatyev@5541 124 }
iignatyev@5541 125 public native int getMethodCompilationLevel(Executable method, boolean isOsr);
iignatyev@4951 126 public native boolean testSetDontInlineMethod(Executable method, boolean value);
iignatyev@5541 127 public int getCompileQueuesSize() {
iignatyev@5541 128 return getCompileQueueSize(-1 /*any*/);
iignatyev@5541 129 }
iignatyev@5541 130 public native int getCompileQueueSize(int compLevel);
iignatyev@4951 131 public native boolean testSetForceInlineMethod(Executable method, boolean value);
iignatyev@5541 132 public boolean enqueueMethodForCompilation(Executable method, int compLevel) {
iignatyev@5541 133 return enqueueMethodForCompilation(method, compLevel, -1 /*InvocationEntryBci*/);
iignatyev@5541 134 }
iignatyev@5541 135 public native boolean enqueueMethodForCompilation(Executable method, int compLevel, int entry_bci);
iignatyev@4951 136 public native void clearMethodState(Executable method);
iignatyev@5541 137 public native int getMethodEntryBci(Executable method);
iignatyev@6525 138 public native Object[] getNMethod(Executable method, boolean isOsr);
mgerdin@4850 139
iignatyev@4951 140 // Intered strings
mgerdin@4850 141 public native boolean isInStringTable(String str);
mgerdin@4850 142
mikael@4989 143 // Memory
mikael@5174 144 public native void readReservedMemory();
mikael@4989 145
mgerdin@4850 146 // force Full GC
mgerdin@4850 147 public native void fullGC();
mgerdin@6078 148
mgerdin@6078 149 // Tests on ReservedSpace/VirtualSpace classes
mgerdin@6078 150 public native int stressVirtualSpaceResize(long reservedSpaceSize, long magnitude, long iterations);
mgerdin@6078 151 public native void runMemoryUnitTests();
mgerdin@6078 152 public native void readFromNoaccessArea();
mgerdin@6078 153
iignatyev@6427 154 // CPU features
iignatyev@6427 155 public native String getCPUFeatures();
iignatyev@6427 156
mgerdin@3619 157 }

mercurial