Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.snippets.test/src/com/oracle/graal/snippets/WordTest.java @ 7134:3de18d9cd04e
Remove a usasge of getMirrorOrFail
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Tue, 04 Dec 2012 11:02:56 -0800 |
parents | 585fc9f79ebc |
children | 9c06e8bd8769 |
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.*; |
7096
585fc9f79ebc
Remove ResolvedJavaType.isClass()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7076
diff
changeset
|
35 import com.oracle.graal.nodes.extended.*; |
585fc9f79ebc
Remove ResolvedJavaType.isClass()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7076
diff
changeset
|
36 import com.oracle.graal.snippets.Snippet.DefaultSnippetInliningPolicy; |
7064
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6543
diff
changeset
|
37 import com.oracle.graal.snippets.Snippet.SnippetInliningPolicy; |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
38 |
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 * Tests for the {@link Word} type. |
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 public class WordTest extends GraalCompilerTest implements SnippetsInterface { |
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 private final SnippetInstaller installer; |
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 public WordTest() { |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
47 TargetDescription target = Graal.getRequiredCapability(GraalCompiler.class).target; |
7076 | 48 installer = new SnippetInstaller(runtime, new Assumptions(false), target); |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
49 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
50 |
7064
8d16b9b2c51e
first part of refactoring the InliningPhase
Christian Haeubl <haeubl@ssw.jku.at>
parents:
6543
diff
changeset
|
51 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
|
52 |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
53 @Override |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
54 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
|
55 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
|
56 return installer.makeGraph(resolvedMethod, inliningPolicy.get()); |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
57 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
58 |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
59 @Test |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
60 public void test_arithmetic() { |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
61 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
|
62 for (long word : words) { |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
63 for (int addend = -1000; addend < 1000; addend++) { |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
64 test("plus_int", word, addend); |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
65 test("plus_int", word, -addend); |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
66 test("minus_int", word, addend); |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
67 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
|
68 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
|
69 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
|
70 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
|
71 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
|
72 |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
73 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
|
74 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
|
75 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
|
76 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
|
77 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
|
78 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
|
79 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
|
80 test("or_long", word, (long) -addend); |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
81 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
82 for (long addend : words) { |
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); |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
85 test("plus_int", word, -((int) addend)); |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
86 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
|
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 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
|
90 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
|
91 |
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_int", word, -((int) addend)); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
95 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
|
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); |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
98 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
|
99 test("or_long", 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 |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
104 @Test |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
105 public void test_compare() { |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
106 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
|
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) { |
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
|
109 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
|
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 |
5685
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
117 @Test |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
118 public void test_fromObject() { |
7134
3de18d9cd04e
Remove a usasge of getMirrorOrFail
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7096
diff
changeset
|
119 inliningPolicy.set(new DefaultSnippetInliningPolicy(runtime(), new BoxingMethodPool(runtime())) { |
7096
585fc9f79ebc
Remove ResolvedJavaType.isClass()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7076
diff
changeset
|
120 @Override |
5685
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
121 public boolean shouldInline(ResolvedJavaMethod method, ResolvedJavaMethod caller) { |
7096
585fc9f79ebc
Remove ResolvedJavaType.isClass()
Christian Wimmer <christian.wimmer@oracle.com>
parents:
7076
diff
changeset
|
122 return super.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
|
123 } |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
124 }); |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
125 test("fromToObject", "object1", "object2"); |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
126 test("fromToObject", "object1", "object1"); |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
127 test("fromToObject", "object", null); |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
128 test("fromToObject", null, "object"); |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
129 test("fromToObject", null, null); |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
130 inliningPolicy.set(null); |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
131 } |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
132 |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
133 @Snippet |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
134 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
|
135 return Word.fromLong(word).plus(addend).toLong(); |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
136 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
137 |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
138 @Snippet |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
139 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
|
140 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
|
141 } |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
142 |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
143 @Snippet |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
144 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
|
145 return Word.fromLong(word).plus(addend).toLong(); |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
146 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
147 |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
148 @Snippet |
6373
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
149 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
|
150 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
|
151 } |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
152 |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
153 @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
|
154 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
|
155 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
|
156 } |
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
|
157 |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
158 @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
|
159 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
|
160 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
|
161 } |
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
|
162 |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
163 @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
|
164 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
|
165 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
|
166 } |
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
|
167 |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
168 @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
|
169 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
|
170 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
|
171 } |
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
172 |
5685
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
173 @Snippet |
757fc384f9b7
added simple tests for Word.fromObject() and Word.toObject()
Doug Simon <doug.simon@oracle.com>
parents:
5666
diff
changeset
|
174 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
|
175 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
|
176 } |
6373
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
177 |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
178 @Snippet |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
179 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
|
180 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
|
181 } |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
182 |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
183 @Snippet |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
184 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
|
185 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
|
186 } |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
187 |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
188 @Snippet |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
189 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
|
190 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
|
191 } |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
192 |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
193 @Snippet |
12fb1809cedc
added AND, OR and XOR intrinsics on Word types
Doug Simon <doug.simon@oracle.com>
parents:
6334
diff
changeset
|
194 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
|
195 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
|
196 } |
5650
8d420cfd2a6f
added unit tests for the Word type
Doug Simon <doug.simon@oracle.com>
parents:
diff
changeset
|
197 } |