--- a/hotspot/src/share/vm/opto/callnode.cpp Fri Jan 13 00:27:53 2012 -0800
+++ b/hotspot/src/share/vm/opto/callnode.cpp Fri Jan 13 00:51:43 2012 -0800
@@ -1625,21 +1625,20 @@
//=============================================================================
bool LockNode::is_nested_lock_region() {
- Node* box = box_node();
- if (!box->is_BoxLock() || box->as_BoxLock()->stack_slot() <= 0)
+ BoxLockNode* box = box_node()->as_BoxLock();
+ int stk_slot = box->stack_slot();
+ if (stk_slot <= 0)
return false; // External lock or it is not Box (Phi node).
// Ignore complex cases: merged locks or multiple locks.
- BoxLockNode* box_lock = box->as_BoxLock();
Node* obj = obj_node();
LockNode* unique_lock = NULL;
- if (!box_lock->is_simple_lock_region(&unique_lock, obj) ||
+ if (!box->is_simple_lock_region(&unique_lock, obj) ||
(unique_lock != this)) {
return false;
}
// Look for external lock for the same object.
- int stk_slot = box_lock->stack_slot();
SafePointNode* sfn = this->as_SafePoint();
JVMState* youngest_jvms = sfn->jvms();
int max_depth = youngest_jvms->depth();
@@ -1649,7 +1648,7 @@
// Loop over monitors
for (int idx = 0; idx < num_mon; idx++) {
Node* obj_node = sfn->monitor_obj(jvms, idx);
- BoxLockNode* box_node = BoxLockNode::box_node(sfn->monitor_box(jvms, idx));
+ BoxLockNode* box_node = sfn->monitor_box(jvms, idx)->as_BoxLock();
if ((box_node->stack_slot() < stk_slot) && obj_node->eqv_uncast(obj)) {
return true;
}
--- a/hotspot/src/share/vm/opto/locknode.cpp Fri Jan 13 00:27:53 2012 -0800
+++ b/hotspot/src/share/vm/opto/locknode.cpp Fri Jan 13 00:51:43 2012 -0800
@@ -63,7 +63,7 @@
}
BoxLockNode* BoxLockNode::box_node(Node* box) {
- // Chase down the BoxNode
+ // Chase down the BoxNode after RA which may spill box nodes.
while (!box->is_BoxLock()) {
// if (box_node->is_SpillCopy()) {
// Node *m = box_node->in(1);
@@ -84,18 +84,13 @@
return box_node(box)->in_RegMask(0).find_first_elem();
}
-bool BoxLockNode::same_slot(Node* box1, Node* box2) {
- return box_node(box1)->_slot == box_node(box2)->_slot;
-}
-
// Is BoxLock node used for one simple lock region (same box and obj)?
bool BoxLockNode::is_simple_lock_region(LockNode** unique_lock, Node* obj) {
LockNode* lock = NULL;
bool has_one_lock = false;
for (uint i = 0; i < this->outcnt(); i++) {
Node* n = this->raw_out(i);
- if (n->is_Phi())
- return false; // Merged regions
+ assert(!n->is_Phi(), "should not merge BoxLock nodes");
if (n->is_AbstractLock()) {
AbstractLockNode* alock = n->as_AbstractLock();
// Check lock's box since box could be referenced by Lock's debug info.
@@ -135,7 +130,19 @@
Node* obj_node = sfn->monitor_obj(jvms, idx);
Node* box_node = sfn->monitor_box(jvms, idx);
if (box_node == this) {
- assert(obj_node->eqv_uncast(obj),"");
+ if (!obj_node->eqv_uncast(obj)) {
+ tty->cr();
+ tty->print_cr("=====monitor info has different obj=====");
+ tty->print_cr("obj:");
+ obj->dump(1); tty->cr();
+ tty->print_cr("obj uncast:");
+ obj->uncast()->dump(); tty->cr();
+ tty->print_cr("obj_node:");
+ obj_node->dump(1); tty->cr();
+ tty->print_cr("obj_node uncast:");
+ obj_node->uncast()->dump();
+ }
+ assert(obj_node->eqv_uncast(obj),"monitor info has different obj");
}
}
}
--- a/hotspot/src/share/vm/opto/locknode.hpp Fri Jan 13 00:27:53 2012 -0800
+++ b/hotspot/src/share/vm/opto/locknode.hpp Fri Jan 13 00:51:43 2012 -0800
@@ -49,9 +49,9 @@
//------------------------------BoxLockNode------------------------------------
class BoxLockNode : public Node {
- const int _slot;
- RegMask _inmask;
- bool _is_eliminated; // indicates this lock was safely eliminated
+ const int _slot; // stack slot
+ RegMask _inmask; // OptoReg corresponding to stack slot
+ bool _is_eliminated; // Associated locks were safely eliminated
public:
BoxLockNode( int lock );
@@ -68,7 +68,9 @@
static OptoReg::Name reg(Node* box_node);
static BoxLockNode* box_node(Node* box_node);
- static bool same_slot(Node* box1, Node* box2);
+ static bool same_slot(Node* box1, Node* box2) {
+ return box1->as_BoxLock()->_slot == box2->as_BoxLock()->_slot;
+ }
int stack_slot() const { return _slot; }
bool is_eliminated() const { return _is_eliminated; }
--- a/hotspot/src/share/vm/opto/macro.cpp Fri Jan 13 00:27:53 2012 -0800
+++ b/hotspot/src/share/vm/opto/macro.cpp Fri Jan 13 00:51:43 2012 -0800
@@ -1829,8 +1829,7 @@
// Create new "eliminated" BoxLock node and use it in monitor debug info
// instead of oldbox for the same object.
- BoxLockNode* box = BoxLockNode::box_node(oldbox);
- BoxLockNode* newbox = box->clone()->as_BoxLock();
+ BoxLockNode* newbox = oldbox->clone()->as_BoxLock();
// Note: BoxLock node is marked eliminated only here and it is used
// to indicate that all associated lock and unlock nodes are marked
@@ -2047,7 +2046,7 @@
Node* box = lock->box_node();
Node* flock = lock->fastlock_node();
- assert(!BoxLockNode::box_node(box)->is_eliminated(), "sanity");
+ assert(!box->as_BoxLock()->is_eliminated(), "sanity");
// Make the merge point
Node *region;
@@ -2283,7 +2282,7 @@
Node* obj = unlock->obj_node();
Node* box = unlock->box_node();
- assert(!BoxLockNode::box_node(box)->is_eliminated(), "sanity");
+ assert(!box->as_BoxLock()->is_eliminated(), "sanity");
// No need for a null check on unlock
--- a/hotspot/src/share/vm/opto/parse1.cpp Fri Jan 13 00:27:53 2012 -0800
+++ b/hotspot/src/share/vm/opto/parse1.cpp Fri Jan 13 00:51:43 2012 -0800
@@ -1604,7 +1604,16 @@
continue;
default: // All normal stuff
if (phi == NULL) {
- if (!check_elide_phi || !target->can_elide_SEL_phi(j)) {
+ const JVMState* jvms = map()->jvms();
+ if (EliminateNestedLocks &&
+ jvms->is_mon(j) && jvms->is_monitor_box(j)) {
+ // BoxLock nodes are not commoning.
+ // Use old BoxLock node as merged box.
+ assert(newin->jvms()->is_monitor_box(j), "sanity");
+ // This assert also tests that nodes are BoxLock.
+ assert(BoxLockNode::same_slot(n, m), "sanity");
+ C->gvn_replace_by(n, m);
+ } else if (!check_elide_phi || !target->can_elide_SEL_phi(j)) {
phi = ensure_phi(j, nophi);
}
}
@@ -1819,12 +1828,8 @@
} else if (jvms->is_stk(idx)) {
t = block()->stack_type_at(idx - jvms->stkoff());
} else if (jvms->is_mon(idx)) {
- if (EliminateNestedLocks && jvms->is_monitor_box(idx)) {
- // BoxLock nodes are not commoning. Create Phi.
- t = o->bottom_type(); // TypeRawPtr::BOTTOM
- } else {
- t = TypeInstPtr::BOTTOM; // this is sufficient for a lock object
- }
+ assert(!jvms->is_monitor_box(idx), "no phis for boxes");
+ t = TypeInstPtr::BOTTOM; // this is sufficient for a lock object
} else if ((uint)idx < TypeFunc::Parms) {
t = o->bottom_type(); // Type::RETURN_ADDRESS or such-like.
} else {