test/runtime/memory/ReadVMPageSize.java

Wed, 26 Nov 2014 10:32:21 -0800

author
minqi
date
Wed, 26 Nov 2014 10:32:21 -0800
changeset 7779
cc5c3ef1f03a
permissions
-rw-r--r--

8053995: Add method to WhiteBox to get vm pagesize.
Summary: Unsafe is not recommended and may deprecated in future. Added a WhiteBox API to get VM page size.
Reviewed-by: dholmes, ccheung, mseledtsov
Contributed-by: yumin.qi@oracle.com

minqi@7779 1 /*
minqi@7779 2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
minqi@7779 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
minqi@7779 4 *
minqi@7779 5 * This code is free software; you can redistribute it and/or modify it
minqi@7779 6 * under the terms of the GNU General Public License version 2 only, as
minqi@7779 7 * published by the Free Software Foundation.
minqi@7779 8 *
minqi@7779 9 * This code is distributed in the hope that it will be useful, but WITHOUT
minqi@7779 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
minqi@7779 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
minqi@7779 12 * version 2 for more details (a copy is included in the LICENSE file that
minqi@7779 13 * accompanied this code).
minqi@7779 14 *
minqi@7779 15 * You should have received a copy of the GNU General Public License version
minqi@7779 16 * 2 along with this work; if not, write to the Free Software Foundation,
minqi@7779 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
minqi@7779 18 *
minqi@7779 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
minqi@7779 20 * or visit www.oracle.com if you need additional information or have any
minqi@7779 21 * questions.
minqi@7779 22 */
minqi@7779 23
minqi@7779 24 /*
minqi@7779 25 * @test
minqi@7779 26 * @summary Using WhiteBox to get VM page size
minqi@7779 27 * @library /testlibrary /testlibrary/whitebox
minqi@7779 28 * @build ReadVMPageSize
minqi@7779 29 * @run main ClassFileInstaller sun.hotspot.WhiteBox
minqi@7779 30 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI ReadVMPageSize
minqi@7779 31 */
minqi@7779 32
minqi@7779 33 import com.oracle.java.testlibrary.*;
minqi@7779 34 import sun.hotspot.WhiteBox;
minqi@7779 35
minqi@7779 36 public class ReadVMPageSize {
minqi@7779 37 public static void main(String args[]) throws Exception {
minqi@7779 38 WhiteBox wb = WhiteBox.getWhiteBox();
minqi@7779 39 int pageSize = wb.getVMPageSize();
minqi@7779 40 if (pageSize < 0) {
minqi@7779 41 throw new Exception("pageSize < 0");
minqi@7779 42 } else {
minqi@7779 43 System.out.println("Page size = " + pageSize);
minqi@7779 44 }
minqi@7779 45 }
minqi@7779 46 }

mercurial