Mercurial > hg > truffle
annotate graal/com.oracle.graal.hotspot.test/src/com/oracle/graal/hotspot/test/ForeignCallDeoptimizeTest.java @ 19271:421a2bf6dc44
Rename LowLevel{High,Mid,Low}Tier to LIR{High,Mid,Low}Tier.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Wed, 11 Feb 2015 15:32:33 +0100 |
parents | bcb1e5c232d8 |
children | 48c1ebd24120 |
rev | line source |
---|---|
18227
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
1 /* |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
4 * |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
8 * |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
14 * |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
18 * |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
21 * questions. |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
22 */ |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.hotspot.test; |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
24 |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
25 import org.junit.*; |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
26 |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
27 import com.oracle.graal.api.meta.*; |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
28 import com.oracle.graal.api.replacements.*; |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.graal.api.runtime.*; |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
30 import com.oracle.graal.compiler.test.*; |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
31 import com.oracle.graal.graph.Node.ConstantNodeParameter; |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
32 import com.oracle.graal.graph.Node.NodeIntrinsic; |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
33 import com.oracle.graal.hotspot.meta.*; |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
34 import com.oracle.graal.nodes.extended.*; |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
35 import com.oracle.graal.nodes.spi.*; |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
36 import com.oracle.graal.runtime.*; |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
37 |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
38 /** |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
39 * Tests that deoptimization upon exception handling works. |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
40 */ |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
41 public class ForeignCallDeoptimizeTest extends GraalCompilerTest { |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
42 |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
43 private static boolean substitutionsInstalled; |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
44 |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
45 public ForeignCallDeoptimizeTest() { |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
46 if (!substitutionsInstalled) { |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
47 Replacements replacements = Graal.getRequiredCapability(RuntimeProvider.class).getHostBackend().getProviders().getReplacements(); |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
48 replacements.registerSubstitutions(ForeignCallDeoptimizeTest.class, Substitutions.class); |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
49 substitutionsInstalled = true; |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
50 } |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
51 } |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
52 |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
53 @ClassSubstitution(ForeignCallDeoptimizeTest.class) |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
54 static class Substitutions { |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
55 |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
56 @MethodSubstitution(isStatic = true) |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
57 static int testCallInt(int value) { |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
58 return testDeoptimizeCallInt(HotSpotForeignCallsProviderImpl.TEST_DEOPTIMIZE_CALL_INT, value); |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
59 } |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
60 } |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
61 |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
62 /** |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
63 * Exercise deoptimization inside of a non leaf runtime call. |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
64 */ |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
65 @NodeIntrinsic(ForeignCallNode.class) |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
66 static native int testDeoptimizeCallInt(@ConstantNodeParameter ForeignCallDescriptor descriptor, int value); |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
67 |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
68 public static int testCallInt(int value) { |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
69 return value; |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
70 } |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
71 |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
72 public static int testForeignCall(int value) { |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
73 if (testCallInt(value) != value) { |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
74 throw new InternalError(); |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
75 } |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
76 return value; |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
77 } |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
78 |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
79 @Test |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
80 public void test1() { |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
81 test("testForeignCall", 0); |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
82 } |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
83 |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
84 @Test |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
85 public void test2() { |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
86 test("testForeignCall", -1); |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
87 } |
bcb1e5c232d8
Test deoptimization inside ForeignCallNode
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
diff
changeset
|
88 } |