1/* 2 * Copyright (c) 2012, 2012, Oracle and/or its affiliates. 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 */ 23package org.graalvm.compiler.jtt.jdk; 24 25import org.junit.Test; 26 27import org.graalvm.compiler.jtt.JTTTest; 28 29public class LongBits extends JTTTest { 30 31 @SuppressWarnings("unused") private static long init = Long.reverseBytes(42); 32 private static long original = 0x0102030405060708L; 33 private static long v = 0b1000L; 34 private static long v2 = 0x0100000000L; 35 private static long zero = 0L; 36 37 public static long test(long o) { 38 return Long.reverseBytes(o); 39 } 40 41 public static int test2(long o) { 42 return Long.numberOfLeadingZeros(o); 43 } 44 45 public static int test3(long o) { 46 return Long.numberOfTrailingZeros(o); 47 } 48 49 public static int test4(long o) { 50 return Long.bitCount(o); 51 } 52 53 @Test 54 public void run0() { 55 runTest("test", original); 56 } 57 58 @Test 59 public void run1() { 60 runTest("test3", v); 61 } 62 63 @Test 64 public void run2() { 65 runTest("test2", v); 66 } 67 68 @Test 69 public void run3() { 70 runTest("test3", zero); 71 } 72 73 @Test 74 public void run4() { 75 runTest("test2", zero); 76 } 77 78 @Test 79 public void run5() { 80 runTest("test", 0x0102030405060708L); 81 } 82 83 @Test 84 public void run6() { 85 runTest("test3", 0b1000L); 86 } 87 88 @Test 89 public void run7() { 90 runTest("test2", 0b1000L); 91 } 92 93 @Test 94 public void run8() { 95 runTest("test3", 0L); 96 } 97 98 @Test 99 public void run9() { 100 runTest("test2", 0L); 101 } 102 103 @Test 104 public void run10() { 105 runTest("test2", v2); 106 } 107 108 @Test 109 public void run11() { 110 runTest("test3", v2); 111 } 112 113 @Test 114 public void run12() { 115 runTest("test2", 0x0100000000L); 116 } 117 118 @Test 119 public void run13() { 120 runTest("test3", 0x0100000000L); 121 } 122 123 @Test 124 public void run14() { 125 runTest("test4", 0L); 126 runTest("test4", 1L); 127 runTest("test4", 0xffff00ffL); 128 runTest("test4", 0xffffffffL); 129 runTest("test4", 0x3ffffffffL); 130 runTest("test4", 0xffffffff3L); 131 runTest("test4", 0xffffffffffffffffL); 132 } 133} 134