1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
1521
1522 //=============================================================================
1523 Node *LockNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1524
1525 // perform any generic optimizations first (returns 'this' or NULL)
1526 Node *result = SafePointNode::Ideal(phase, can_reshape);
1527 if (result != NULL) return result;
1528 // Don't bother trying to transform a dead node
1529 if (in(0) && in(0)->is_top()) return NULL;
1530
1531 // Now see if we can optimize away this lock. We don't actually
1532 // remove the locking here, we simply set the _eliminate flag which
1533 // prevents macro expansion from expanding the lock. Since we don't
1534 // modify the graph, the value returned from this function is the
1535 // one computed above.
1536 if (can_reshape && EliminateLocks && !is_non_esc_obj()) {
1537 //
1538 // If we are locking an unescaped object, the lock/unlock is unnecessary
1539 //
1540 ConnectionGraph *cgr = phase->C->congraph();
1541 PointsToNode::EscapeState es = PointsToNode::GlobalEscape;
1542 if (cgr != NULL)
1543 es = cgr->escape_state(obj_node());
1544 if (es != PointsToNode::UnknownEscape && es != PointsToNode::GlobalEscape) {
1545 assert(!is_eliminated() || is_coarsened(), "sanity");
1546 // The lock could be marked eliminated by lock coarsening
1547 // code during first IGVN before EA. Replace coarsened flag
1548 // to eliminate all associated locks/unlocks.
1549 this->set_non_esc_obj();
1550 return result;
1551 }
1552
1553 //
1554 // Try lock coarsening
1555 //
1556 PhaseIterGVN* iter = phase->is_IterGVN();
1557 if (iter != NULL && !is_eliminated()) {
1558
1559 GrowableArray<AbstractLockNode*> lock_ops;
1560
1561 Node *ctrl = next_control(in(0));
1562
1563 // now search back for a matching Unlock
1564 if (find_matching_unlock(ctrl, this, lock_ops)) {
1663 //=============================================================================
1664 Node *UnlockNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1665
1666 // perform any generic optimizations first (returns 'this' or NULL)
1667 Node *result = SafePointNode::Ideal(phase, can_reshape);
1668 if (result != NULL) return result;
1669 // Don't bother trying to transform a dead node
1670 if (in(0) && in(0)->is_top()) return NULL;
1671
1672 // Now see if we can optimize away this unlock. We don't actually
1673 // remove the unlocking here, we simply set the _eliminate flag which
1674 // prevents macro expansion from expanding the unlock. Since we don't
1675 // modify the graph, the value returned from this function is the
1676 // one computed above.
1677 // Escape state is defined after Parse phase.
1678 if (can_reshape && EliminateLocks && !is_non_esc_obj()) {
1679 //
1680 // If we are unlocking an unescaped object, the lock/unlock is unnecessary.
1681 //
1682 ConnectionGraph *cgr = phase->C->congraph();
1683 PointsToNode::EscapeState es = PointsToNode::GlobalEscape;
1684 if (cgr != NULL)
1685 es = cgr->escape_state(obj_node());
1686 if (es != PointsToNode::UnknownEscape && es != PointsToNode::GlobalEscape) {
1687 assert(!is_eliminated() || is_coarsened(), "sanity");
1688 // The lock could be marked eliminated by lock coarsening
1689 // code during first IGVN before EA. Replace coarsened flag
1690 // to eliminate all associated locks/unlocks.
1691 this->set_non_esc_obj();
1692 }
1693 }
1694 return result;
1695 }
|
1 /*
2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
1521
1522 //=============================================================================
1523 Node *LockNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1524
1525 // perform any generic optimizations first (returns 'this' or NULL)
1526 Node *result = SafePointNode::Ideal(phase, can_reshape);
1527 if (result != NULL) return result;
1528 // Don't bother trying to transform a dead node
1529 if (in(0) && in(0)->is_top()) return NULL;
1530
1531 // Now see if we can optimize away this lock. We don't actually
1532 // remove the locking here, we simply set the _eliminate flag which
1533 // prevents macro expansion from expanding the lock. Since we don't
1534 // modify the graph, the value returned from this function is the
1535 // one computed above.
1536 if (can_reshape && EliminateLocks && !is_non_esc_obj()) {
1537 //
1538 // If we are locking an unescaped object, the lock/unlock is unnecessary
1539 //
1540 ConnectionGraph *cgr = phase->C->congraph();
1541 if (cgr != NULL && cgr->not_global_escape(obj_node())) {
1542 assert(!is_eliminated() || is_coarsened(), "sanity");
1543 // The lock could be marked eliminated by lock coarsening
1544 // code during first IGVN before EA. Replace coarsened flag
1545 // to eliminate all associated locks/unlocks.
1546 this->set_non_esc_obj();
1547 return result;
1548 }
1549
1550 //
1551 // Try lock coarsening
1552 //
1553 PhaseIterGVN* iter = phase->is_IterGVN();
1554 if (iter != NULL && !is_eliminated()) {
1555
1556 GrowableArray<AbstractLockNode*> lock_ops;
1557
1558 Node *ctrl = next_control(in(0));
1559
1560 // now search back for a matching Unlock
1561 if (find_matching_unlock(ctrl, this, lock_ops)) {
1660 //=============================================================================
1661 Node *UnlockNode::Ideal(PhaseGVN *phase, bool can_reshape) {
1662
1663 // perform any generic optimizations first (returns 'this' or NULL)
1664 Node *result = SafePointNode::Ideal(phase, can_reshape);
1665 if (result != NULL) return result;
1666 // Don't bother trying to transform a dead node
1667 if (in(0) && in(0)->is_top()) return NULL;
1668
1669 // Now see if we can optimize away this unlock. We don't actually
1670 // remove the unlocking here, we simply set the _eliminate flag which
1671 // prevents macro expansion from expanding the unlock. Since we don't
1672 // modify the graph, the value returned from this function is the
1673 // one computed above.
1674 // Escape state is defined after Parse phase.
1675 if (can_reshape && EliminateLocks && !is_non_esc_obj()) {
1676 //
1677 // If we are unlocking an unescaped object, the lock/unlock is unnecessary.
1678 //
1679 ConnectionGraph *cgr = phase->C->congraph();
1680 if (cgr != NULL && cgr->not_global_escape(obj_node())) {
1681 assert(!is_eliminated() || is_coarsened(), "sanity");
1682 // The lock could be marked eliminated by lock coarsening
1683 // code during first IGVN before EA. Replace coarsened flag
1684 // to eliminate all associated locks/unlocks.
1685 this->set_non_esc_obj();
1686 }
1687 }
1688 return result;
1689 }
|