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