Mercurial > hg > graal-jvmci-8
annotate test/compiler/floatingpoint/TestPow2.java @ 23993:7b65bd0ebeb7
removed duplicate registration of StubRoutines::_multiplyToLen in vmstructs
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 31 Jan 2017 22:59:16 +0100 |
parents | f958bebdee26 |
children |
rev | line source |
---|---|
23940
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
1 /* |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
4 * |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
8 * |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
13 * accompanied this code). |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
14 * |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
18 * |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
21 * questions. |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
22 */ |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
23 |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
24 /* |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
25 * @test |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
26 * @bug 8063086 |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
27 * @summary X^2 special case for C2 yields different result than interpreter |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
28 * @library /testlibrary /testlibrary/whitebox /compiler/whitebox |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
29 * @build TestPow2 |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
30 * @run main ClassFileInstaller sun.hotspot.WhiteBox |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
31 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
32 * -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestPow2 |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
33 * |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
34 */ |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
35 |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
36 import java.lang.reflect.*; |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
37 import sun.hotspot.WhiteBox; |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
38 |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
39 public class TestPow2 { |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
40 |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
41 private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
42 |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
43 private static final double base = 5350.456329377186; |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
44 private static final double exp = 2.0; |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
45 |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
46 static double m() { |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
47 return Math.pow(base, exp); |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
48 } |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
49 |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
50 static public void main(String[] args) throws NoSuchMethodException { |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
51 Method test_method = TestPow2.class.getDeclaredMethod("m"); |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
52 |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
53 double interpreter_result = m(); |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
54 |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
55 // Compile with C1 if possible |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
56 WHITE_BOX.enqueueMethodForCompilation(test_method, CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE); |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
57 |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
58 double c1_result = m(); |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
59 |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
60 WHITE_BOX.deoptimizeMethod(test_method); |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
61 |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
62 // Compile it with C2 if possible |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
63 WHITE_BOX.enqueueMethodForCompilation(test_method, CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION); |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
64 |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
65 double c2_result = m(); |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
66 |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
67 if (interpreter_result != c1_result || interpreter_result != c2_result || |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
68 c1_result != c2_result) { |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
69 System.out.println("interpreter = " + interpreter_result + " c1 = " + c1_result + " c2 = " + c2_result); |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
70 throw new RuntimeException("Test Failed"); |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
71 } |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
72 } |
f958bebdee26
8063086: Math.pow yields different results upon repeated calls
csahu
parents:
diff
changeset
|
73 } |