annotate graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/jdk/ShortBits.java @ 14991:64dcb92ee75a

Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sun, 06 Apr 2014 17:46:24 +0200
parents e70abc187ff3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13666
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
1 /*
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
4 *
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
7 * published by the Free Software Foundation.
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
8 *
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
13 * accompanied this code).
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
14 *
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
18 *
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
21 * questions.
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
22 */
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
23 package com.oracle.graal.jtt.jdk;
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
24
14991
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13666
diff changeset
25 import org.junit.*;
64dcb92ee75a Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13666
diff changeset
26
13666
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
27 import com.oracle.graal.jtt.*;
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
28
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
29 public class ShortBits extends JTTTest {
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
30 @SuppressWarnings("unused") private static short init = Short.reverseBytes((short) 42);
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
31 private static short original = 0x1708;
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
32
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
33 public static short test(short o) {
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
34 return Short.reverseBytes(o);
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
35 }
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
36
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
37 @Test
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
38 public void run0() {
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
39 runTest("test", original);
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
40 }
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
41
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
42 @Test
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
43 public void run1() {
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
44 runTest("test", (short) 0x1708L);
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
45 }
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
46
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
47 @Test
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
48 public void run2() {
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
49 runTest("test", (short) 0);
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
50 runTest("test", (short) 1);
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
51 runTest("test", (short) -1);
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
52 runTest("test", (short) 0x00ff);
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
53 runTest("test", (short) 0xff00);
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
54 runTest("test", (short) 0xffff);
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
55 runTest("test", (short) 0x3fff);
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
56 }
e70abc187ff3 method substitution for {Character,Short}.reverseBytes()
Bernhard Urban <bernhard.urban@jku.at>
parents:
diff changeset
57 }