Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.graal.replacements.test/src/com/oracle/graal/replacements/test/WordTest.java @ 13132:922dd1415c0a
Commit pass target as a parameter to ReplacementImpl, so that it does not require a CodeCacheProvider
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Fri, 22 Nov 2013 12:17:53 -0800 |
parents | 90494fdf11c8 |
children | bd21ee1a874c |
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 */ |
8944
e7766460ddb3
Move tests into *.test packages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8631
diff
changeset
|
23 package com.oracle.graal.replacements.test; |
5650
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 com.oracle.graal.api.code.*; |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
28 import com.oracle.graal.api.meta.*; |
6334
f8ba3bb81f6f
Renamed com.oracle.graal.tests project to com.oracle.graal.compiler.test
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
5685
diff
changeset
|
29 import com.oracle.graal.compiler.test.*; |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.nodes.*; |
8944
e7766460ddb3
Move tests into *.test packages.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
8631
diff
changeset
|
31 import com.oracle.graal.replacements.*; |
12429
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12362
diff
changeset
|
32 import com.oracle.graal.replacements.Snippet.SnippetInliningPolicy; |
5124eeec1a7b
split HotSpotRuntime into separate provider implementations
Doug Simon <doug.simon@oracle.com>
parents:
12362
diff
changeset
|
33 import com.oracle.graal.test.*; |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
34 import com.oracle.graal.word.*; |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
35 |
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 * Tests for the {@link Word} type. |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 */ |
8413
d9347ee39fbe
rename: SnippetsInterface -> Snippets
Doug Simon <doug.simon@oracle.com>
parents:
8410
diff
changeset
|
39 public class WordTest extends GraalCompilerTest implements Snippets { |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
40 |
8628
77de2f3df379
renames: [HotSpot]ReplacementsInstaller -> [HotSpot]ReplacementsImpl
Doug Simon <doug.simon@oracle.com>
parents:
8416
diff
changeset
|
41 private final ReplacementsImpl installer; |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
42 |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
43 public WordTest() { |
13132
922dd1415c0a
Commit pass target as a parameter to ReplacementImpl, so that it does not require a CodeCacheProvider
Christian Wimmer <christian.wimmer@oracle.com>
parents:
12432
diff
changeset
|
44 installer = new ReplacementsImpl(getProviders(), new Assumptions(false), getTarget()); |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
45 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
46 |
7064
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6543
diff
changeset
|
47 private static final ThreadLocal<SnippetInliningPolicy> inliningPolicy = new ThreadLocal<>(); |
5685
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
48 |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 @Override |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 protected StructuredGraph parse(Method m) { |
11959
23ccaa863eda
made CodeCacheProvider independent of MetaAccessProvider (GRAAL-511)
Doug Simon <doug.simon@oracle.com>
parents:
11870
diff
changeset
|
51 ResolvedJavaMethod resolvedMethod = getMetaAccess().lookupJavaMethod(m); |
11870
a80d09922fc1
new parameter on Snippet annotation to remove all frame states
Lukas Stadler <lukas.stadler@jku.at>
parents:
10513
diff
changeset
|
52 return installer.makeGraph(resolvedMethod, null, inliningPolicy.get(), false); |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 |
8341
c38d2870439e
unittest: move testcases that takes longer than 100ms into longunittest
Bernhard Urban <bernhard.urban@jku.at>
parents:
7901
diff
changeset
|
55 @LongTest |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
56 public void construction() { |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
57 long[] words = new long[]{Long.MIN_VALUE, Long.MIN_VALUE + 1, -1L, 0L, 1L, Long.MAX_VALUE - 1, Long.MAX_VALUE, Integer.MAX_VALUE - 1L, Integer.MAX_VALUE, Integer.MAX_VALUE + 1L, |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
58 Integer.MIN_VALUE - 1L, Integer.MIN_VALUE, Integer.MIN_VALUE + 1L}; |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 for (long word : words) { |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
60 test("unsignedLong", word); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
61 test("unsignedInt", (int) word); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
62 test("signedLong", word); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
63 test("signedInt", (int) word); |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
64 } |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
65 } |
6373
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
66 |
8341
c38d2870439e
unittest: move testcases that takes longer than 100ms into longunittest
Bernhard Urban <bernhard.urban@jku.at>
parents:
7901
diff
changeset
|
67 @LongTest |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
68 public void testArithmetic() { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
69 long[] words = new long[]{Long.MIN_VALUE, Long.MIN_VALUE + 1, -1L, 0L, 1L, Long.MAX_VALUE - 1, Long.MAX_VALUE, Integer.MAX_VALUE - 1L, Integer.MAX_VALUE, Integer.MAX_VALUE + 1L, |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
70 Integer.MIN_VALUE - 1L, Integer.MIN_VALUE, Integer.MIN_VALUE + 1L}; |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
71 for (long word : words) { |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
72 test("unsignedNot", word); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
73 test("signedNot", word); |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
74 for (long addend : words) { |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
75 test("unsignedPlusInt", word, (int) addend); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
76 test("unsignedMinusInt", word, (int) addend); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
77 test("unsignedPlusInt", word, -((int) addend)); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
78 test("unsignedMinusInt", word, -((int) addend)); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
79 test("unsignedPlusLong", word, addend); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
80 test("unsignedMinusLong", word, addend); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
81 test("unsignedPlusLong", word, -addend); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
82 test("unsignedMinusLong", word, -addend); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
83 test("signedPlusInt", word, (int) addend); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
84 test("signedMinusInt", word, (int) addend); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
85 test("signedPlusInt", word, -((int) addend)); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
86 test("signedMinusInt", word, -((int) addend)); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
87 test("signedPlusLong", word, addend); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
88 test("signedMinusLong", word, addend); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
89 test("signedPlusLong", word, -addend); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
90 test("signedMinusLong", word, -addend); |
6373
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
91 |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
92 test("andInt", word, (int) addend); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
93 test("orInt", word, (int) addend); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
94 test("andInt", word, -((int) addend)); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
95 test("orInt", word, -((int) addend)); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
96 test("andLong", word, addend); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
97 test("orLong", word, addend); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
98 test("andLong", word, -addend); |
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
99 test("orLong", word, -addend); |
5650
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 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
103 |
8341
c38d2870439e
unittest: move testcases that takes longer than 100ms into longunittest
Bernhard Urban <bernhard.urban@jku.at>
parents:
7901
diff
changeset
|
104 @LongTest |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
105 public void testCompare() { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7300
diff
changeset
|
106 long[] words = new long[]{Long.MIN_VALUE, Long.MIN_VALUE + 1, -1L, 0L, 1L, Long.MAX_VALUE - 1, Long.MAX_VALUE}; |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
107 for (long word1 : words) { |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
108 for (long word2 : words) { |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7300
diff
changeset
|
109 for (String method : new String[]{"aboveOrEqual", "above", "belowOrEqual", "below"}) { |
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
|
110 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
|
111 test(method, word2, word1); |
5650
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 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
115 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
116 |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
117 @Snippet |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
118 public static long unsignedLong(long word) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
119 return Word.unsigned(word).rawValue(); |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
120 } |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
121 |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
122 @Snippet |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
123 public static long unsignedInt(int word) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
124 return Word.unsigned(word).rawValue(); |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
125 } |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
126 |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
127 @Snippet |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
128 public static long signedLong(long word) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
129 return Word.signed(word).rawValue(); |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
130 } |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
131 |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
132 @Snippet |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
133 public static long signedInt(int word) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
134 return Word.signed(word).rawValue(); |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
135 } |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
136 |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
137 @Snippet |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
138 public static long unsignedPlusInt(long word, int addend) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
139 return Word.unsigned(word).add(addend).rawValue(); |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
140 } |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
141 |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
142 @Snippet |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
143 public static long unsignedMinusInt(long word, int addend) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
144 return Word.unsigned(word).subtract(addend).rawValue(); |
5685
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
145 } |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
146 |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
147 @Snippet |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
148 public static long unsignedPlusLong(long word, long addend) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
149 return Word.unsigned(word).add(Word.unsigned(addend)).rawValue(); |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
150 } |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
151 |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
152 @Snippet |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
153 public static long unsignedMinusLong(long word, long addend) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
154 return Word.unsigned(word).subtract(Word.unsigned(addend)).rawValue(); |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
155 } |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
156 |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
157 @Snippet |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
158 public static long signedPlusInt(long word, int addend) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
159 return Word.signed(word).add(addend).rawValue(); |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
160 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
161 |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
162 @Snippet |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
163 public static long signedMinusInt(long word, int addend) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
164 return Word.signed(word).subtract(addend).rawValue(); |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
165 } |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
166 |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
167 @Snippet |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
168 public static long signedPlusLong(long word, long addend) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
169 return Word.signed(word).add(Word.signed(addend)).rawValue(); |
6373
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
170 } |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
171 |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
172 @Snippet |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
173 public static long signedMinusLong(long word, long addend) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
174 return Word.signed(word).subtract(Word.signed(addend)).rawValue(); |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
175 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
176 |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
177 @Snippet |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
178 public static long signedNot(long word) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
179 return Word.signed(word).not().rawValue(); |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
180 } |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
181 |
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
182 @Snippet |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
183 public static long unsignedNot(long word) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
184 return Word.unsigned(word).not().rawValue(); |
6373
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
185 } |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
186 |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
187 @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
|
188 public static boolean aboveOrEqual(long word1, long word2) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
189 return Word.unsigned(word1).aboveOrEqual(Word.unsigned(word2)); |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
190 } |
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
|
191 |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
192 @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
|
193 public static boolean above(long word1, long word2) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
194 return Word.unsigned(word1).aboveThan(Word.unsigned(word2)); |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
195 } |
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
|
196 |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
197 @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
|
198 public static boolean belowOrEqual(long word1, long word2) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
199 return Word.unsigned(word1).belowOrEqual(Word.unsigned(word2)); |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
200 } |
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
|
201 |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
202 @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
|
203 public static boolean below(long word1, long word2) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
204 return Word.unsigned(word1).belowThan(Word.unsigned(word2)); |
5685
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
205 } |
6373
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
206 |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
207 @Snippet |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
208 public static long andInt(long word, int addend) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
209 return Word.unsigned(word).and(addend).rawValue(); |
6373
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
210 } |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
211 |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
212 @Snippet |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
213 public static long orInt(long word, int addend) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
214 return Word.unsigned(word).or(addend).rawValue(); |
6373
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
215 } |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
216 |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
217 @Snippet |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
218 public static long andLong(long word, long addend) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
219 return Word.unsigned(word).and(Word.unsigned(addend)).rawValue(); |
6373
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
220 } |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
221 |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
222 @Snippet |
10513
00b70a864d3b
updated Checkstyle rules to prohibit underscores in method names and fixed current violations
Doug Simon <doug.simon@oracle.com>
parents:
8944
diff
changeset
|
223 public static long orLong(long word, long addend) { |
7300
2912b72d840a
More complete and reusable Word type
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7271
diff
changeset
|
224 return Word.unsigned(word).or(Word.unsigned(addend)).rawValue(); |
6373
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
225 } |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
226 } |