Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/WordTest.java @ 6543:ec196bfc458b
Minor fixes after cleanup
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Tue, 09 Oct 2012 16:16:39 -0700 |
parents | 31aa76ffd3bb |
children | 0e20ad1ea98b 8d16b9b2c51e |
rev | line source |
---|---|
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
1 /* |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
4 * |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
8 * |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
14 * |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
18 * |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
21 * questions. |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
22 */ |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.snippets; |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
24 |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
25 import java.lang.reflect.*; |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
26 |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
27 import org.junit.*; |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.graal.api.code.*; |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.api.meta.*; |
6540
31aa76ffd3bb
Rename project graal.api to graal.api.runtime
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6539
diff
changeset
|
31 import com.oracle.graal.api.runtime.*; |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.graal.compiler.*; |
6334
f8ba3bb81f6f
Renamed com.oracle.graal.tests project to com.oracle.graal.compiler.test
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5685
diff
changeset
|
33 import com.oracle.graal.compiler.test.*; |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
34 import com.oracle.graal.nodes.*; |
5685
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
35 import com.oracle.graal.snippets.Snippet.InliningPolicy; |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
36 |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
37 /** |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 * Tests for the {@link Word} type. |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
39 */ |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 public class WordTest extends GraalCompilerTest implements SnippetsInterface { |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
41 |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 private final SnippetInstaller installer; |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
44 public WordTest() { |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 TargetDescription target = Graal.getRequiredCapability(GraalCompiler.class).target; |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 installer = new SnippetInstaller(runtime, target); |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
48 |
5685
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
49 private static final ThreadLocal<InliningPolicy> inliningPolicy = new ThreadLocal<>(); |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
50 |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
51 @Override |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
52 protected StructuredGraph parse(Method m) { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6526
diff
changeset
|
53 ResolvedJavaMethod resolvedMethod = runtime.lookupJavaMethod(m); |
5685
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
54 return installer.makeGraph(resolvedMethod, inliningPolicy.get()); |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
55 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
56 |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 @Test |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 public void test_arithmetic() { |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 long[] words = new long[] {Long.MIN_VALUE, Long.MIN_VALUE + 1, -1L, 0L, 1L, Long.MAX_VALUE - 1, Long.MAX_VALUE}; |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 for (long word : words) { |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 for (int addend = -1000; addend < 1000; addend++) { |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
62 test("plus_int", word, addend); |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 test("plus_int", word, -addend); |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 test("minus_int", word, addend); |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 test("minus_int", word, -addend); |
6373
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
66 test("plus_long", word, (long) addend); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
67 test("plus_long", word, (long) -addend); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
68 test("minus_long", word, (long) addend); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
69 test("minus_long", word, (long) -addend); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
70 |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
71 test("and_int", word, addend); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
72 test("and_int", word, -addend); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
73 test("or_int", word, addend); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
74 test("or_int", word, -addend); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
75 test("and_long", word, (long) addend); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
76 test("and_long", word, (long) -addend); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
77 test("or_long", word, (long) addend); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
78 test("or_long", word, (long) -addend); |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
79 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
80 for (long addend : words) { |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 test("plus_int", word, (int) addend); |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 test("minus_int", word, (int) addend); |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
83 test("plus_int", word, -((int) addend)); |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
84 test("minus_int", word, -((int) addend)); |
6373
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
85 test("plus_long", word, addend); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
86 test("minus_long", word, addend); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
87 test("plus_long", word, -addend); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
88 test("minus_long", word, -addend); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
89 |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
90 test("and_int", word, (int) addend); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
91 test("or_int", word, (int) addend); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
92 test("and_int", word, -((int) addend)); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
93 test("or_int", word, -((int) addend)); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
94 test("and_long", word, addend); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
95 test("or_long", word, addend); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
96 test("and_long", word, -addend); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
97 test("or_long", word, -addend); |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
98 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
99 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
100 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
101 |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
102 @Test |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
103 public void test_compare() { |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
104 long[] words = new long[] {Long.MIN_VALUE, Long.MIN_VALUE + 1, -1L, 0L, 1L, Long.MAX_VALUE - 1, Long.MAX_VALUE}; |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
105 for (long word1 : words) { |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
106 for (long word2 : words) { |
5666
48a2505efb54
added verification phase for snippets to ensure word types are not incorrectly mixed with Object types
Doug Simon <doug.simon@oracle.com>
parents:
5650
diff
changeset
|
107 for (String method : new String[] {"aboveOrEqual", "above", "belowOrEqual", "below"}) { |
48a2505efb54
added verification phase for snippets to ensure word types are not incorrectly mixed with Object types
Doug Simon <doug.simon@oracle.com>
parents:
5650
diff
changeset
|
108 test(method, word1, word2); |
48a2505efb54
added verification phase for snippets to ensure word types are not incorrectly mixed with Object types
Doug Simon <doug.simon@oracle.com>
parents:
5650
diff
changeset
|
109 test(method, word2, word1); |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
110 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
111 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
112 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
113 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
114 |
5685
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
115 @Test |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
116 public void test_fromObject() { |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
117 inliningPolicy.set(new InliningPolicy() { |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
118 public boolean shouldInline(ResolvedJavaMethod method, ResolvedJavaMethod caller) { |
6539
2463eb24b644
Cleanup of Graal API: Rename methods so that it follows the getXxx naming convention and so that they are similar to the names of the java.lang.reflect classes. Remove unused methods.
Christian Wimmer <christian.wimmer@oracle.com>
parents:
6526
diff
changeset
|
119 return InliningPolicy.Default.shouldInline(method, caller) && !method.getName().equals("hashCode"); |
5685
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
120 } |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
121 }); |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
122 test("fromToObject", "object1", "object2"); |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
123 test("fromToObject", "object1", "object1"); |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
124 test("fromToObject", "object", null); |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
125 test("fromToObject", null, "object"); |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
126 test("fromToObject", null, null); |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
127 inliningPolicy.set(null); |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
128 } |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
129 |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
130 @Snippet |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
131 public static long plus_int(long word, int addend) { |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
132 return Word.fromLong(word).plus(addend).toLong(); |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
133 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
134 |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
135 @Snippet |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
136 public static long minus_int(long word, int addend) { |
6373
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
137 return Word.fromLong(word).minus(addend).toLong(); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
138 } |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
139 |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
140 @Snippet |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
141 public static long plus_long(long word, long addend) { |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
142 return Word.fromLong(word).plus(addend).toLong(); |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
143 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
144 |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
145 @Snippet |
6373
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
146 public static long minus_long(long word, long addend) { |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
147 return Word.fromLong(word).minus(addend).toLong(); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
148 } |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
149 |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
150 @Snippet |
5666
48a2505efb54
added verification phase for snippets to ensure word types are not incorrectly mixed with Object types
Doug Simon <doug.simon@oracle.com>
parents:
5650
diff
changeset
|
151 public static boolean aboveOrEqual(long word1, long word2) { |
48a2505efb54
added verification phase for snippets to ensure word types are not incorrectly mixed with Object types
Doug Simon <doug.simon@oracle.com>
parents:
5650
diff
changeset
|
152 return Word.fromLong(word1).aboveOrEqual(Word.fromLong(word2)); |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
153 } |
5666
48a2505efb54
added verification phase for snippets to ensure word types are not incorrectly mixed with Object types
Doug Simon <doug.simon@oracle.com>
parents:
5650
diff
changeset
|
154 |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
155 @Snippet |
5666
48a2505efb54
added verification phase for snippets to ensure word types are not incorrectly mixed with Object types
Doug Simon <doug.simon@oracle.com>
parents:
5650
diff
changeset
|
156 public static boolean above(long word1, long word2) { |
48a2505efb54
added verification phase for snippets to ensure word types are not incorrectly mixed with Object types
Doug Simon <doug.simon@oracle.com>
parents:
5650
diff
changeset
|
157 return Word.fromLong(word1).above(Word.fromLong(word2)); |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
158 } |
5666
48a2505efb54
added verification phase for snippets to ensure word types are not incorrectly mixed with Object types
Doug Simon <doug.simon@oracle.com>
parents:
5650
diff
changeset
|
159 |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
160 @Snippet |
5666
48a2505efb54
added verification phase for snippets to ensure word types are not incorrectly mixed with Object types
Doug Simon <doug.simon@oracle.com>
parents:
5650
diff
changeset
|
161 public static boolean belowOrEqual(long word1, long word2) { |
48a2505efb54
added verification phase for snippets to ensure word types are not incorrectly mixed with Object types
Doug Simon <doug.simon@oracle.com>
parents:
5650
diff
changeset
|
162 return Word.fromLong(word1).belowOrEqual(Word.fromLong(word2)); |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
163 } |
5666
48a2505efb54
added verification phase for snippets to ensure word types are not incorrectly mixed with Object types
Doug Simon <doug.simon@oracle.com>
parents:
5650
diff
changeset
|
164 |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
165 @Snippet |
5666
48a2505efb54
added verification phase for snippets to ensure word types are not incorrectly mixed with Object types
Doug Simon <doug.simon@oracle.com>
parents:
5650
diff
changeset
|
166 public static boolean below(long word1, long word2) { |
48a2505efb54
added verification phase for snippets to ensure word types are not incorrectly mixed with Object types
Doug Simon <doug.simon@oracle.com>
parents:
5650
diff
changeset
|
167 return Word.fromLong(word1).below(Word.fromLong(word2)); |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
168 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
169 |
5685
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
170 @Snippet |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
171 public static int fromToObject(Object o1, Object o2) { |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
172 return Word.fromObject(o1).toObject().hashCode() + Word.fromObject(o2).toObject().hashCode(); |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
173 } |
6373
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
174 |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
175 @Snippet |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
176 public static long and_int(long word, int addend) { |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
177 return Word.fromLong(word).and(addend).toLong(); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
178 } |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
179 |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
180 @Snippet |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
181 public static long or_int(long word, int addend) { |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
182 return Word.fromLong(word).or(addend).toLong(); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
183 } |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
184 |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
185 @Snippet |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
186 public static long and_long(long word, long addend) { |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
187 return Word.fromLong(word).and(addend).toLong(); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
188 } |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
189 |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
190 @Snippet |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
191 public static long or_long(long word, long addend) { |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
192 return Word.fromLong(word).or(addend).toLong(); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
193 } |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
194 } |