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 Magic.timestamp* with 32-bit compressed oops 27 * @library /test/lib 28 * 29 * @run main/othervm -Xmx128m 30 * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni 31 * -Xint 32 * Timestamp 33 * 34 * @run main/othervm -Xmx128m 35 * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni 36 * -XX:TieredStopAtLevel=1 37 * Timestamp 38 * 39 * @run main/othervm -Xmx128m 40 * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni 41 * -XX:-TieredCompilation 42 * Timestamp 43 */ 44 45 /* 46 * @test 47 * @summary Test for Magic.timestamp* with zero-based compressed oops 48 * @library /test/lib 49 * @requires vm.bits == 64 50 * 51 * @run main/othervm -Xmx4g 52 * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni 53 * -Xint 54 * Timestamp 55 * 56 * @run main/othervm -Xmx4g 57 * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni 58 * -XX:TieredStopAtLevel=1 59 * Timestamp 60 * 61 * @run main/othervm -Xmx4g 62 * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni 63 * -XX:-TieredCompilation 64 * Timestamp 65 */ 66 67 /* 68 * @test 69 * @summary Test for Magic.timestamp* without compressed oops 70 * @library /test/lib 71 * @requires vm.bits == 64 72 * 73 * @run main/othervm -Xmx128m -XX:-UseCompressedOops 74 * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni 75 * -Xint 76 * Timestamp 77 * 78 * @run main/othervm -Xmx128m -XX:-UseCompressedOops 79 * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni 80 * -XX:TieredStopAtLevel=1 81 * Timestamp 82 * 83 * @run main/othervm -Xmx128m -XX:-UseCompressedOops 84 * -XX:+UnlockDiagnosticVMOptions -XX:+AbortVMOnCompilationFailure -Xcheck:jni 85 * -XX:-TieredCompilation 86 * Timestamp 87 */ 88 89 import java.lang.reflect.Field; 90 91 import net.shipilev.Magic; 92 93 public class Timestamp { 94 95 public static void main(String ... args) throws Exception { 96 test_timestamp(); 97 test_timestampSerial(); 98 } 99 100 private static void test_timestamp() throws Exception { 101 for (int c = 0; c < MagicUtil.ITERS; c++) { 102 MagicUtil.assertNotEquals(0, Magic.timestamp()); 103 } 104 } 105 106 private static void test_timestampSerial() throws Exception { 107 for (int c = 0; c < MagicUtil.ITERS; c++) { 108 MagicUtil.assertNotEquals(0, Magic.timestampSerial()); 109 } 110 } 111 }