annotate src/share/vm/opto/locknode.cpp @ 196:d1605aabd0a1 jdk7-b30

6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
author xdono
date Wed, 02 Jul 2008 12:55:16 -0700
parents 6dbf1a175d6b
children 424f9bfe6b96
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
196
d1605aabd0a1 6719955: Update copyright year
xdono
parents: 66
diff changeset
2 * Copyright 1999-2008 Sun Microsystems, Inc. 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 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "incls/_locknode.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
29 const RegMask &BoxLockNode::in_RegMask(uint i) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
30 return _inmask;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 }
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 const RegMask &BoxLockNode::out_RegMask() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
34 return *Matcher::idealreg2regmask[Op_RegP];
a61af66fc99e Initial load
duke
parents:
diff changeset
35 }
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 uint BoxLockNode::size_of() const { return sizeof(*this); }
a61af66fc99e Initial load
duke
parents:
diff changeset
38
66
6dbf1a175d6b 6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents: 0
diff changeset
39 BoxLockNode::BoxLockNode( int slot ) : Node( Compile::current()->root() ),
6dbf1a175d6b 6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents: 0
diff changeset
40 _slot(slot), _is_eliminated(false) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
41 init_class_id(Class_BoxLock);
a61af66fc99e Initial load
duke
parents:
diff changeset
42 init_flags(Flag_rematerialize);
a61af66fc99e Initial load
duke
parents:
diff changeset
43 OptoReg::Name reg = OptoReg::stack2reg(_slot);
a61af66fc99e Initial load
duke
parents:
diff changeset
44 _inmask.Insert(reg);
a61af66fc99e Initial load
duke
parents:
diff changeset
45 }
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 //------------------------------cmp--------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
48 uint BoxLockNode::cmp( const Node &n ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 const BoxLockNode &bn = (const BoxLockNode &)n;
a61af66fc99e Initial load
duke
parents:
diff changeset
50 return bn._slot == _slot;
a61af66fc99e Initial load
duke
parents:
diff changeset
51 }
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 OptoReg::Name BoxLockNode::stack_slot(Node* box_node) {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // Chase down the BoxNode
a61af66fc99e Initial load
duke
parents:
diff changeset
55 while (!box_node->is_BoxLock()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // if (box_node->is_SpillCopy()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // Node *m = box_node->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // if (m->is_Mach() && m->as_Mach()->ideal_Opcode() == Op_StoreP) {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // box_node = m->in(m->as_Mach()->operand_index(2));
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
63 assert(box_node->is_SpillCopy() || box_node->is_Phi(), "Bad spill of Lock.");
a61af66fc99e Initial load
duke
parents:
diff changeset
64 box_node = box_node->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
65 }
a61af66fc99e Initial load
duke
parents:
diff changeset
66 return box_node->in_RegMask(0).find_first_elem();
a61af66fc99e Initial load
duke
parents:
diff changeset
67 }
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
70 //-----------------------------hash--------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
71 uint FastLockNode::hash() const { return NO_HASH; }
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 //------------------------------cmp--------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
74 uint FastLockNode::cmp( const Node &n ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 return (&n == this); // Always fail except on self
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
79 //-----------------------------hash--------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
80 uint FastUnlockNode::hash() const { return NO_HASH; }
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 //------------------------------cmp--------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
83 uint FastUnlockNode::cmp( const Node &n ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
84 return (&n == this); // Always fail except on self
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 //
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // Create a counter which counts the number of times this lock is acquired
a61af66fc99e Initial load
duke
parents:
diff changeset
89 //
a61af66fc99e Initial load
duke
parents:
diff changeset
90 void FastLockNode::create_lock_counter(JVMState* state) {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 BiasedLockingNamedCounter* blnc = (BiasedLockingNamedCounter*)
a61af66fc99e Initial load
duke
parents:
diff changeset
92 OptoRuntime::new_named_counter(state, NamedCounter::BiasedLockingCounter);
a61af66fc99e Initial load
duke
parents:
diff changeset
93 _counters = blnc->counters();
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
97 //------------------------------do_monitor_enter-------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
98 void Parse::do_monitor_enter() {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 kill_dead_locals();
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 // Null check; get casted pointer.
a61af66fc99e Initial load
duke
parents:
diff changeset
102 Node *obj = do_null_check(peek(), T_OBJECT);
a61af66fc99e Initial load
duke
parents:
diff changeset
103 // Check for locking null object
a61af66fc99e Initial load
duke
parents:
diff changeset
104 if (stopped()) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // the monitor object is not part of debug info expression stack
a61af66fc99e Initial load
duke
parents:
diff changeset
107 pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // Insert a FastLockNode which takes as arguments the current thread pointer,
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // the obj pointer & the address of the stack slot pair used for the lock.
a61af66fc99e Initial load
duke
parents:
diff changeset
111 shared_lock(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 //------------------------------do_monitor_exit--------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
115 void Parse::do_monitor_exit() {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 kill_dead_locals();
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 pop(); // Pop oop to unlock
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // Because monitors are guarenteed paired (else we bail out), we know
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // the matching Lock for this Unlock. Hence we know there is no need
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // for a null check on Unlock.
a61af66fc99e Initial load
duke
parents:
diff changeset
122 shared_unlock(map()->peek_monitor_box(), map()->peek_monitor_obj());
a61af66fc99e Initial load
duke
parents:
diff changeset
123 }