annotate src/share/vm/opto/locknode.cpp @ 2426:1d1603768966

7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass Summary: Update the copyright to be 2010 on all changed files in OpenJDK Reviewed-by: ohair
author trims
date Tue, 05 Apr 2011 14:12:31 -0700
parents f95d63e2154a
children e9a5e0a812c8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 605
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 605
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 605
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "opto/locknode.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "opto/parse.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "opto/rootnode.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "opto/runtime.hpp"
0
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
32 const RegMask &BoxLockNode::in_RegMask(uint i) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
33 return _inmask;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 }
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 const RegMask &BoxLockNode::out_RegMask() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
37 return *Matcher::idealreg2regmask[Op_RegP];
a61af66fc99e Initial load
duke
parents:
diff changeset
38 }
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 uint BoxLockNode::size_of() const { return sizeof(*this); }
a61af66fc99e Initial load
duke
parents:
diff changeset
41
66
6dbf1a175d6b 6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents: 0
diff changeset
42 BoxLockNode::BoxLockNode( int slot ) : Node( Compile::current()->root() ),
6dbf1a175d6b 6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents: 0
diff changeset
43 _slot(slot), _is_eliminated(false) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
44 init_class_id(Class_BoxLock);
a61af66fc99e Initial load
duke
parents:
diff changeset
45 init_flags(Flag_rematerialize);
a61af66fc99e Initial load
duke
parents:
diff changeset
46 OptoReg::Name reg = OptoReg::stack2reg(_slot);
a61af66fc99e Initial load
duke
parents:
diff changeset
47 _inmask.Insert(reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
48 }
a61af66fc99e Initial load
duke
parents:
diff changeset
49
460
424f9bfe6b96 6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents: 196
diff changeset
50 //-----------------------------hash--------------------------------------------
424f9bfe6b96 6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents: 196
diff changeset
51 uint BoxLockNode::hash() const {
424f9bfe6b96 6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents: 196
diff changeset
52 return Node::hash() + _slot + (_is_eliminated ? Compile::current()->fixed_slots() : 0);
424f9bfe6b96 6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents: 196
diff changeset
53 }
424f9bfe6b96 6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents: 196
diff changeset
54
0
a61af66fc99e Initial load
duke
parents:
diff changeset
55 //------------------------------cmp--------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
56 uint BoxLockNode::cmp( const Node &n ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 const BoxLockNode &bn = (const BoxLockNode &)n;
460
424f9bfe6b96 6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents: 196
diff changeset
58 return bn._slot == _slot && bn._is_eliminated == _is_eliminated;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
59 }
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 OptoReg::Name BoxLockNode::stack_slot(Node* box_node) {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // Chase down the BoxNode
a61af66fc99e Initial load
duke
parents:
diff changeset
63 while (!box_node->is_BoxLock()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // if (box_node->is_SpillCopy()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // Node *m = box_node->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // if (m->is_Mach() && m->as_Mach()->ideal_Opcode() == Op_StoreP) {
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // box_node = m->in(m->as_Mach()->operand_index(2));
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
71 assert(box_node->is_SpillCopy() || box_node->is_Phi(), "Bad spill of Lock.");
a61af66fc99e Initial load
duke
parents:
diff changeset
72 box_node = box_node->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
73 }
a61af66fc99e Initial load
duke
parents:
diff changeset
74 return box_node->in_RegMask(0).find_first_elem();
a61af66fc99e Initial load
duke
parents:
diff changeset
75 }
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
78 //-----------------------------hash--------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
79 uint FastLockNode::hash() const { return NO_HASH; }
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 //------------------------------cmp--------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
82 uint FastLockNode::cmp( const Node &n ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 return (&n == this); // Always fail except on self
a61af66fc99e Initial load
duke
parents:
diff changeset
84 }
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
87 //-----------------------------hash--------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
88 uint FastUnlockNode::hash() const { return NO_HASH; }
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 //------------------------------cmp--------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
91 uint FastUnlockNode::cmp( const Node &n ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 return (&n == this); // Always fail except on self
a61af66fc99e Initial load
duke
parents:
diff changeset
93 }
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 //
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // Create a counter which counts the number of times this lock is acquired
a61af66fc99e Initial load
duke
parents:
diff changeset
97 //
a61af66fc99e Initial load
duke
parents:
diff changeset
98 void FastLockNode::create_lock_counter(JVMState* state) {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 BiasedLockingNamedCounter* blnc = (BiasedLockingNamedCounter*)
a61af66fc99e Initial load
duke
parents:
diff changeset
100 OptoRuntime::new_named_counter(state, NamedCounter::BiasedLockingCounter);
a61af66fc99e Initial load
duke
parents:
diff changeset
101 _counters = blnc->counters();
a61af66fc99e Initial load
duke
parents:
diff changeset
102 }
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
105 //------------------------------do_monitor_enter-------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
106 void Parse::do_monitor_enter() {
a61af66fc99e Initial load
duke
parents:
diff changeset
107 kill_dead_locals();
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // Null check; get casted pointer.
a61af66fc99e Initial load
duke
parents:
diff changeset
110 Node *obj = do_null_check(peek(), T_OBJECT);
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // Check for locking null object
a61af66fc99e Initial load
duke
parents:
diff changeset
112 if (stopped()) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // the monitor object is not part of debug info expression stack
a61af66fc99e Initial load
duke
parents:
diff changeset
115 pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // Insert a FastLockNode which takes as arguments the current thread pointer,
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // the obj pointer & the address of the stack slot pair used for the lock.
a61af66fc99e Initial load
duke
parents:
diff changeset
119 shared_lock(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 //------------------------------do_monitor_exit--------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
123 void Parse::do_monitor_exit() {
a61af66fc99e Initial load
duke
parents:
diff changeset
124 kill_dead_locals();
a61af66fc99e Initial load
duke
parents:
diff changeset
125
a61af66fc99e Initial load
duke
parents:
diff changeset
126 pop(); // Pop oop to unlock
605
98cb887364d3 6810672: Comment typos
twisti
parents: 460
diff changeset
127 // Because monitors are guaranteed paired (else we bail out), we know
0
a61af66fc99e Initial load
duke
parents:
diff changeset
128 // the matching Lock for this Unlock. Hence we know there is no need
a61af66fc99e Initial load
duke
parents:
diff changeset
129 // for a null check on Unlock.
a61af66fc99e Initial load
duke
parents:
diff changeset
130 shared_unlock(map()->peek_monitor_box(), map()->peek_monitor_obj());
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }