comparison src/share/vm/opto/locknode.cpp @ 4970:33df1aeaebbf

Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Mon, 27 Feb 2012 13:10:13 +0100
parents 89d0a5d40008
children b9a9ed0f8eeb
comparison
equal deleted inserted replaced
4703:2cfb7fb2dce7 4970:33df1aeaebbf
47 _inmask.Insert(reg); 47 _inmask.Insert(reg);
48 } 48 }
49 49
50 //-----------------------------hash-------------------------------------------- 50 //-----------------------------hash--------------------------------------------
51 uint BoxLockNode::hash() const { 51 uint BoxLockNode::hash() const {
52 if (EliminateNestedLocks)
53 return NO_HASH; // Each locked region has own BoxLock node
52 return Node::hash() + _slot + (_is_eliminated ? Compile::current()->fixed_slots() : 0); 54 return Node::hash() + _slot + (_is_eliminated ? Compile::current()->fixed_slots() : 0);
53 } 55 }
54 56
55 //------------------------------cmp-------------------------------------------- 57 //------------------------------cmp--------------------------------------------
56 uint BoxLockNode::cmp( const Node &n ) const { 58 uint BoxLockNode::cmp( const Node &n ) const {
59 if (EliminateNestedLocks)
60 return (&n == this); // Always fail except on self
57 const BoxLockNode &bn = (const BoxLockNode &)n; 61 const BoxLockNode &bn = (const BoxLockNode &)n;
58 return bn._slot == _slot && bn._is_eliminated == _is_eliminated; 62 return bn._slot == _slot && bn._is_eliminated == _is_eliminated;
59 } 63 }
60 64
61 OptoReg::Name BoxLockNode::stack_slot(Node* box_node) { 65 BoxLockNode* BoxLockNode::box_node(Node* box) {
62 // Chase down the BoxNode 66 // Chase down the BoxNode after RA which may spill box nodes.
63 while (!box_node->is_BoxLock()) { 67 while (!box->is_BoxLock()) {
64 // if (box_node->is_SpillCopy()) { 68 // if (box_node->is_SpillCopy()) {
65 // Node *m = box_node->in(1); 69 // Node *m = box_node->in(1);
66 // if (m->is_Mach() && m->as_Mach()->ideal_Opcode() == Op_StoreP) { 70 // if (m->is_Mach() && m->as_Mach()->ideal_Opcode() == Op_StoreP) {
67 // box_node = m->in(m->as_Mach()->operand_index(2)); 71 // box_node = m->in(m->as_Mach()->operand_index(2));
68 // continue; 72 // continue;
69 // } 73 // }
70 // } 74 // }
71 assert(box_node->is_SpillCopy() || box_node->is_Phi(), "Bad spill of Lock."); 75 assert(box->is_SpillCopy() || box->is_Phi(), "Bad spill of Lock.");
72 box_node = box_node->in(1); 76 // Only BoxLock nodes with the same stack slot are merged.
77 // So it is enough to trace one path to find the slot value.
78 box = box->in(1);
73 } 79 }
74 return box_node->in_RegMask(0).find_first_elem(); 80 return box->as_BoxLock();
81 }
82
83 OptoReg::Name BoxLockNode::reg(Node* box) {
84 return box_node(box)->in_RegMask(0).find_first_elem();
85 }
86
87 // Is BoxLock node used for one simple lock region (same box and obj)?
88 bool BoxLockNode::is_simple_lock_region(LockNode** unique_lock, Node* obj) {
89 LockNode* lock = NULL;
90 bool has_one_lock = false;
91 for (uint i = 0; i < this->outcnt(); i++) {
92 Node* n = this->raw_out(i);
93 assert(!n->is_Phi(), "should not merge BoxLock nodes");
94 if (n->is_AbstractLock()) {
95 AbstractLockNode* alock = n->as_AbstractLock();
96 // Check lock's box since box could be referenced by Lock's debug info.
97 if (alock->box_node() == this) {
98 if (alock->obj_node()->eqv_uncast(obj)) {
99 if ((unique_lock != NULL) && alock->is_Lock()) {
100 if (lock == NULL) {
101 lock = alock->as_Lock();
102 has_one_lock = true;
103 } else if (lock != alock->as_Lock()) {
104 has_one_lock = false;
105 }
106 }
107 } else {
108 return false; // Different objects
109 }
110 }
111 }
112 }
113 #ifdef ASSERT
114 // Verify that FastLock and Safepoint reference only this lock region.
115 for (uint i = 0; i < this->outcnt(); i++) {
116 Node* n = this->raw_out(i);
117 if (n->is_FastLock()) {
118 FastLockNode* flock = n->as_FastLock();
119 assert((flock->box_node() == this) && flock->obj_node()->eqv_uncast(obj),"");
120 }
121 // Don't check monitor info in safepoints since the referenced object could
122 // be different from the locked object. It could be Phi node of different
123 // cast nodes which point to this locked object.
124 // We assume that no other objects could be referenced in monitor info
125 // associated with this BoxLock node because all associated locks and
126 // unlocks are reference only this one object.
127 }
128 #endif
129 if (unique_lock != NULL && has_one_lock) {
130 *unique_lock = lock;
131 }
132 return true;
75 } 133 }
76 134
77 //============================================================================= 135 //=============================================================================
78 //-----------------------------hash-------------------------------------------- 136 //-----------------------------hash--------------------------------------------
79 uint FastLockNode::hash() const { return NO_HASH; } 137 uint FastLockNode::hash() const { return NO_HASH; }