annotate graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/LockEliminationPhase.java @ 20019:fa9d90e73569

check whether a StateSplit node being added via GraphBuilderContext has a null stateAfter before setting one
author Doug Simon <doug.simon@oracle.com>
date Tue, 24 Mar 2015 11:56:10 +0100
parents 61d3cb8e1280
children 1ab2c7bb6f0f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7493
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
23 package com.oracle.graal.phases.common;
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25 import com.oracle.graal.nodes.*;
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
26 import com.oracle.graal.nodes.java.*;
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
27 import com.oracle.graal.nodes.util.*;
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28 import com.oracle.graal.phases.*;
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
29
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30 public class LockEliminationPhase extends Phase {
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32 @Override
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33 protected void run(StructuredGraph graph) {
19403
61d3cb8e1280 Add generic parameter to NodeClass. Change Graph#getNodes(Class) to Graph#getNodes(NodeClass).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 13794
diff changeset
34 for (MonitorExitNode node : graph.getNodes(MonitorExitNode.TYPE)) {
7493
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 FixedNode next = node.next();
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36 if (next instanceof MonitorEnterNode) {
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37 MonitorEnterNode monitorEnterNode = (MonitorEnterNode) next;
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
38 if (monitorEnterNode.object() == node.object()) {
13794
2eb56f87b01e add GraphUtil.removeFixedWithUnusedInputs
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
39 GraphUtil.removeFixedWithUnusedInputs(monitorEnterNode);
2eb56f87b01e add GraphUtil.removeFixedWithUnusedInputs
Lukas Stadler <lukas.stadler@jku.at>
parents: 7530
diff changeset
40 GraphUtil.removeFixedWithUnusedInputs(node);
7493
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41 }
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
42 }
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
43 }
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
44 }
741ceb12ff7d Implement basic lock elimination phase.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
45 }