Mercurial > hg > truffle
annotate graal/com.oracle.graal.jtt/src/com/oracle/graal/jtt/optimize/ConditionalElimination02.java @ 14991:64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sun, 06 Apr 2014 17:46:24 +0200 |
parents | 67969c1f20fb |
children | 48c1ebd24120 |
rev | line source |
---|---|
11317
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
1 /* |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
2 * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
4 * |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
8 * |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
13 * accompanied this code). |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
14 * |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
18 * |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
21 * questions. |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
22 */ |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
23 package com.oracle.graal.jtt.optimize; |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
24 |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
25 import java.util.*; |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
26 |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
27 import org.junit.*; |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
28 |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
29 import com.oracle.graal.api.meta.*; |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
30 import com.oracle.graal.jtt.*; |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
31 |
11349 | 32 public class ConditionalElimination02 extends JTTTest { |
11317
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
33 |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
34 private static Object o = null; |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
35 |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
36 private static class A { |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
37 |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
38 public A(int y) { |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
39 this.y = y; |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
40 } |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
41 |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
42 int y; |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
43 } |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
44 |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
45 public int test(A a, boolean isNull, boolean isVeryNull) { |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
46 if (o == null) { |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
47 if (!isNull) { |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
48 if (o == null) { |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
49 return a.y; |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
50 } |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
51 } |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
52 if (!isVeryNull) { |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
53 if (o == null) { |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
54 return a.y; |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
55 } |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
56 } |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
57 } |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
58 return -1; |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
59 } |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
60 |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
61 @Test |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
62 public void run0() throws Throwable { |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
63 runTest(EnumSet.of(DeoptimizationReason.NullCheckException), "test", new A(5), false, false); |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
64 } |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
65 |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
66 @Test |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
67 public void run1() throws Throwable { |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
68 runTest(EnumSet.of(DeoptimizationReason.NullCheckException), "test", new Object[]{null, true, true}); |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
69 } |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
70 |
12fe444e68d2
Fix bug in ConditionalElimination phase: when replacing a ifnode with a guard, the guard has to be checked before entering the surviving branch
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
diff
changeset
|
71 } |