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

Mon, 29 Apr 2013 11:03:49 -0700

author
mikael
date
Mon, 29 Apr 2013 11:03:49 -0700
changeset 4989
f32b6c267d2e
parent 4955
01d5f04e64dc
child 5073
d17700c82d7d
permissions
-rw-r--r--

8012015: Use PROT_NONE when reserving memory
Summary: Reserved memory had PROT_READ+PROT_WRITE access on Linux/bsd, now changed to PROT_NONE.
Reviewed-by: dholmes, ctornqvi

mgerdin@3619 1 /*
katleman@4916 2 * Copyright (c) 2012, 2013, 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
mgerdin@3619 64 // Memory
mgerdin@3619 65 public native long getObjectAddress(Object o);
mgerdin@3619 66 public native int getHeapOopSize();
mgerdin@3619 67
coleenp@4037 68 // Runtime
coleenp@4037 69 // Make sure class name is in the correct format
coleenp@4037 70 public boolean isClassAlive(String name) {
coleenp@4037 71 return isClassAlive0(name.replace('.', '/'));
coleenp@4037 72 }
coleenp@4037 73 private native boolean isClassAlive0(String name);
coleenp@4037 74
mgerdin@3619 75 // G1
mgerdin@3619 76 public native boolean g1InConcurrentMark();
mgerdin@3619 77 public native boolean g1IsHumongous(Object o);
mgerdin@3619 78 public native long g1NumFreeRegions();
mgerdin@3619 79 public native int g1RegionSize();
nloodin@3681 80 public native Object[] parseCommandLine(String commandline, DiagnosticCommand[] args);
ctornqvi@4512 81
ctornqvi@4512 82 // NMT
ctornqvi@4885 83 public native long NMTMalloc(long size);
ctornqvi@4885 84 public native void NMTFree(long mem);
ctornqvi@4885 85 public native long NMTReserveMemory(long size);
ctornqvi@4885 86 public native void NMTCommitMemory(long addr, long size);
ctornqvi@4885 87 public native void NMTUncommitMemory(long addr, long size);
ctornqvi@4885 88 public native void NMTReleaseMemory(long addr, long size);
ctornqvi@4512 89 public native boolean NMTWaitForDataMerge();
iignatyev@4592 90
iignatyev@4592 91 // Compiler
iignatyev@4592 92 public native void deoptimizeAll();
iignatyev@4951 93 public native boolean isMethodCompiled(Executable method);
iignatyev@4951 94 public boolean isMethodCompilable(Executable method) {
iignatyev@4908 95 return isMethodCompilable(method, -1 /*any*/);
iignatyev@4908 96 }
iignatyev@4951 97 public native boolean isMethodCompilable(Executable method, int compLevel);
iignatyev@4951 98 public native boolean isMethodQueuedForCompilation(Executable method);
iignatyev@4951 99 public native int deoptimizeMethod(Executable method);
iignatyev@4951 100 public void makeMethodNotCompilable(Executable method) {
iignatyev@4951 101 makeMethodNotCompilable(method, -1 /*any*/);
iignatyev@4951 102 }
iignatyev@4951 103 public native void makeMethodNotCompilable(Executable method, int compLevel);
iignatyev@4951 104 public native int getMethodCompilationLevel(Executable method);
iignatyev@4951 105 public native boolean testSetDontInlineMethod(Executable method, boolean value);
iignatyev@4592 106 public native int getCompileQueuesSize();
iignatyev@4951 107 public native boolean testSetForceInlineMethod(Executable method, boolean value);
iignatyev@4951 108 public native boolean enqueueMethodForCompilation(Executable method, int compLevel);
iignatyev@4951 109 public native void clearMethodState(Executable method);
mgerdin@4850 110
iignatyev@4951 111 // Intered strings
mgerdin@4850 112 public native boolean isInStringTable(String str);
mgerdin@4850 113
mikael@4989 114 // Memory
mikael@4989 115 public native long reserveMemory(long size);
mikael@4989 116
mgerdin@4850 117 // force Full GC
mgerdin@4850 118 public native void fullGC();
mgerdin@3619 119 }

mercurial