Mercurial > hg > graal-compiler
annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/cfs/FlowSensitiveReductionPhase.java @ 15388:769fc3629f59
Add phase FlowSensitiveReductionPhase.
It is possible to remove GuardingPiNodes, CheckCastNodes, and FixedGuards during
HighTier under certain conditions (control-flow sensitive conditions).
The phase added in this commit (FlowSensitiveReductionPhase) does that,
and in addition replaces usages with "downcasting" PiNodes when possible
thus resulting in more precise object stamps (e.g., non-null).
Finally, usages of floating, side-effects free, expressions are also simplified
(as per control-flow sensitive conditions).
The newly added phase runs only during HighTier and can be deactivated
using Graal option FlowSensitiveReduction (it is active by default).
author | Miguel Garcia <miguel.m.garcia@oracle.com> |
---|---|
date | Fri, 25 Apr 2014 16:50:52 +0200 |
parents | |
children | e9029a026dc9 |
rev | line source |
---|---|
15388
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
1 /* |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
4 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
8 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
13 * accompanied this code). |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
14 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
18 * |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
21 * questions. |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
22 */ |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
23 package com.oracle.graal.phases.common.cfs; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
24 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
25 import com.oracle.graal.api.meta.*; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
26 import com.oracle.graal.debug.*; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
27 import com.oracle.graal.nodes.*; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
28 import com.oracle.graal.phases.*; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
29 import com.oracle.graal.phases.tiers.PhaseContext; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
30 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
31 public class FlowSensitiveReductionPhase extends BasePhase<PhaseContext> { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
32 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
33 private final MetaAccessProvider metaAccess; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
34 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
35 public MetaAccessProvider getMetaAccess() { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
36 return metaAccess; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
37 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
38 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
39 public FlowSensitiveReductionPhase(MetaAccessProvider metaAccess) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
40 this.metaAccess = metaAccess; |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
41 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
42 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
43 @Override |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
44 protected final void run(StructuredGraph graph, PhaseContext context) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
45 try (Debug.Scope s = Debug.scope("FlowSensitiveReduction")) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
46 new FlowSensitiveReduction(graph.start(), new State(), context).apply(); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
47 } catch (Throwable e) { |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
48 throw Debug.handle(e); |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
49 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
50 } |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
51 |
769fc3629f59
Add phase FlowSensitiveReductionPhase.
Miguel Garcia <miguel.m.garcia@oracle.com>
parents:
diff
changeset
|
52 } |