author | vromero |
Mon, 02 Jun 2014 22:36:40 +0100 | |
changeset 24793 | bb58a9f1ae10 |
parent 5547 | f4b087cbb361 |
permissions | -rw-r--r-- |
2031
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
1 |
/* |
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2031
diff
changeset
|
2 |
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. |
2031
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
4 |
* |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
8 |
* |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
13 |
* accompanied this code). |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
14 |
* |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
18 |
* |
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2031
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2031
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
2031
diff
changeset
|
21 |
* questions. |
2031
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
22 |
*/ |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
23 |
|
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
24 |
/** |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
25 |
* @test |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
26 |
* @bug 6800154 |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
27 |
* @summary Add comments to long_by_long_mulhi() for better understandability |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
28 |
* |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
29 |
* @run main/othervm -Xcomp -XX:CompileOnly=Test6800154.divcomp Test6800154 |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
30 |
*/ |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
31 |
|
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
32 |
import java.net.URLClassLoader; |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
33 |
|
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
34 |
public class Test6800154 implements Runnable { |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
35 |
static final long[] DIVIDENDS = { |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
36 |
0, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
37 |
1, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
38 |
2, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
39 |
1423487, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
40 |
4444441, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
41 |
4918923241323L, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
42 |
-1, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
43 |
-24351, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
44 |
0x3333, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
45 |
0x0000000080000000L, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
46 |
0x7fffffffffffffffL, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
47 |
0x8000000000000000L |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
48 |
}; |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
49 |
|
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
50 |
static final long[] DIVISORS = { |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
51 |
1, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
52 |
2, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
53 |
17, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
54 |
12342, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
55 |
24123, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
56 |
143444, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
57 |
123444442344L, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
58 |
-1, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
59 |
-2, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
60 |
-4423423234231423L, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
61 |
0x0000000080000000L, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
62 |
0x7fffffffffffffffL, |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
63 |
0x8000000000000000L |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
64 |
}; |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
65 |
|
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
66 |
// Initialize DIVISOR so that it is final in this class. |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
67 |
static final long DIVISOR; |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
68 |
|
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
69 |
static { |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
70 |
long value = 0; |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
71 |
try { |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
72 |
value = Long.decode(System.getProperty("divisor")); |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
73 |
} catch (Throwable e) { |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
74 |
} |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
75 |
DIVISOR = value; |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
76 |
} |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
77 |
|
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
78 |
public static void main(String[] args) throws Exception |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
79 |
{ |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
80 |
Class cl = Class.forName("Test6800154"); |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
81 |
URLClassLoader apploader = (URLClassLoader) cl.getClassLoader(); |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
82 |
|
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
83 |
// Iterate over all divisors. |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
84 |
for (int i = 0; i < DIVISORS.length; i++) { |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
85 |
System.setProperty("divisor", "" + DIVISORS[i]); |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
86 |
ClassLoader loader = new URLClassLoader(apploader.getURLs(), apploader.getParent()); |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
87 |
Class c = loader.loadClass("Test6800154"); |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
88 |
Runnable r = (Runnable) c.newInstance(); |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
89 |
r.run(); |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
90 |
} |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
91 |
} |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
92 |
|
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
93 |
public void run() |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
94 |
{ |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
95 |
// Iterate over all dividends. |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
96 |
for (int i = 0; i < DIVIDENDS.length; i++) { |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
97 |
long dividend = DIVIDENDS[i]; |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
98 |
|
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
99 |
long expected = divint(dividend); |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
100 |
long result = divcomp(dividend); |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
101 |
|
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
102 |
if (result != expected) |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
103 |
throw new InternalError(dividend + " / " + DIVISOR + " failed: " + result + " != " + expected); |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
104 |
} |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
105 |
} |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
106 |
|
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
107 |
static long divint(long a) { return a / DIVISOR; } |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
108 |
static long divcomp(long a) { return a / DIVISOR; } |
24e034f56dcb
6800154: Add comments to long_by_long_mulhi() for better understandability
twisti
parents:
diff
changeset
|
109 |
} |