Merge
This commit is contained in:
commit
9eaf76fc72
@ -1625,21 +1625,20 @@ Node *LockNode::Ideal(PhaseGVN *phase, bool can_reshape) {
|
||||
|
||||
//=============================================================================
|
||||
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 @@ bool LockNode::is_nested_lock_region() {
|
||||
// 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;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ uint BoxLockNode::cmp( const Node &n ) const {
|
||||
}
|
||||
|
||||
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 @@ OptoReg::Name BoxLockNode::reg(Node* box) {
|
||||
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 @@ bool BoxLockNode::is_simple_lock_region(LockNode** unique_lock, Node* obj) {
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 @@ public:
|
||||
|
||||
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; }
|
||||
|
@ -1829,8 +1829,7 @@ void PhaseMacroExpand::mark_eliminated_box(Node* oldbox, Node* obj) {
|
||||
|
||||
// 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 @@ void PhaseMacroExpand::expand_lock_node(LockNode *lock) {
|
||||
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 @@ void PhaseMacroExpand::expand_unlock_node(UnlockNode *unlock) {
|
||||
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
|
||||
|
||||
|
@ -1604,7 +1604,16 @@ void Parse::merge_common(Parse::Block* target, int pnum) {
|
||||
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 @@ PhiNode *Parse::ensure_phi(int idx, bool nocreate) {
|
||||
} 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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user