1 /*
   2  * Copyright (c) 2020, Red Hat, Inc. 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 /*
  25  * @test
  26  * @summary Test for disabled Runtime.sizeOf with 32-bit compressed oops
  27  * @library /test/lib
  28  *
  29  * @run main/othervm -Xmx128m
  30  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni
  31  *                   -XX:-RuntimeSizeOf
  32  *                   -Xint
  33  *                   SizeOfDisabled
  34  *
  35  * @run main/othervm -Xmx128m
  36  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni
  37  *                   -XX:-RuntimeSizeOf
  38  *                   -XX:TieredStopAtLevel=1
  39  *                   SizeOfDisabled
  40  *
  41  * @run main/othervm -Xmx128m
  42  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni
  43  *                   -XX:-RuntimeSizeOf
  44  *                   -XX:TieredStopAtLevel=2
  45  *                   SizeOfDisabled
  46  *
  47  * @run main/othervm -Xmx128m
  48  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni
  49  *                   -XX:-RuntimeSizeOf
  50  *                   -XX:TieredStopAtLevel=3
  51  *                   SizeOfDisabled
  52  *
  53  * @run main/othervm -Xmx128m
  54  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni
  55  *                   -XX:-RuntimeSizeOf
  56  *                   -XX:TieredStopAtLevel=4
  57  *                   SizeOfDisabled
  58  *
  59  * @run main/othervm -Xmx128m
  60  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni
  61  *                   -XX:-RuntimeSizeOf
  62  *                   -XX:-TieredCompilation
  63  *                   SizeOfDisabled
  64  */
  65 
  66 /*
  67  * @test
  68  * @summary Test for disabled Runtime.sizeOf with zero-based compressed oops
  69  * @library /test/lib
  70  * @requires vm.bits == 64
  71  *
  72  * @run main/othervm -Xmx4g
  73  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni
  74  *                   -XX:-RuntimeSizeOf
  75  *                   -Xint
  76  *                   SizeOfDisabled
  77  *
  78  * @run main/othervm -Xmx4g
  79  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni
  80  *                   -XX:-RuntimeSizeOf
  81  *                   -XX:TieredStopAtLevel=1
  82  *                   SizeOfDisabled
  83  *
  84  * @run main/othervm -Xmx4g
  85  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni
  86  *                   -XX:-RuntimeSizeOf
  87  *                   -XX:TieredStopAtLevel=2
  88  *                   SizeOfDisabled
  89  *
  90  * @run main/othervm -Xmx4g
  91  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni
  92  *                   -XX:-RuntimeSizeOf
  93  *                   -XX:TieredStopAtLevel=3
  94  *                   SizeOfDisabled
  95  *
  96  * @run main/othervm -Xmx4g
  97  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni
  98  *                   -XX:-RuntimeSizeOf
  99  *                   -XX:TieredStopAtLevel=4
 100  *                   SizeOfDisabled
 101  *
 102  * @run main/othervm -Xmx4g
 103  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni
 104  *                   -XX:-RuntimeSizeOf
 105  *                   -XX:-TieredCompilation
 106  *                   SizeOfDisabled
 107  */
 108 
 109 /*
 110  * @test
 111  * @summary Test for disabled Runtime.sizeOf without compressed oops
 112  * @library /test/lib
 113  * @requires vm.bits == 64
 114  *
 115  * @run main/othervm -Xmx128m -XX:-UseCompressedOops
 116  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni
 117  *                   -XX:-RuntimeSizeOf
 118  *                   -Xint
 119  *                   SizeOfDisabled
 120  *
 121  * @run main/othervm -Xmx128m -XX:-UseCompressedOops
 122  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni
 123  *                   -XX:-RuntimeSizeOf
 124  *                   -XX:TieredStopAtLevel=1
 125  *                   SizeOfDisabled
 126  *
 127  * @run main/othervm -Xmx128m -XX:-UseCompressedOops
 128  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni
 129  *                   -XX:-RuntimeSizeOf
 130  *                   -XX:TieredStopAtLevel=2
 131  *                   SizeOfDisabled
 132  *
 133  * @run main/othervm -Xmx128m -XX:-UseCompressedOops
 134  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni
 135  *                   -XX:-RuntimeSizeOf
 136  *                   -XX:TieredStopAtLevel=3
 137  *                   SizeOfDisabled
 138  *
 139  * @run main/othervm -Xmx128m -XX:-UseCompressedOops
 140  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni
 141  *                   -XX:-RuntimeSizeOf
 142  *                   -XX:TieredStopAtLevel=4
 143  *                   SizeOfDisabled
 144  *
 145  * @run main/othervm -Xmx128m -XX:-UseCompressedOops
 146  *                   -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni
 147  *                   -XX:-RuntimeSizeOf
 148  *                   -XX:-TieredCompilation
 149  *                   SizeOfDisabled
 150  */
 151 
 152 import java.lang.reflect.Field;
 153 
 154 public class SizeOfDisabled {
 155 
 156     public static void main(String ... args) throws Exception {
 157         for (int c = 0; c < RuntimeOfUtil.ITERS; c++) {
 158             RuntimeOfUtil.assertEquals(-1, Runtime.sizeOf(new Object()));
 159         }
 160     }
 161 
 162 }