annotate src/share/vm/opto/locknode.cpp @ 1145:e018e6884bd8

6631166: CMS: better heuristics when combatting fragmentation Summary: Autonomic per-worker free block cache sizing, tunable coalition policies, fixes to per-size block statistics, retuned gain and bandwidth of some feedback loop filters to allow quicker reactivity to abrupt changes in ambient demand, and other heuristics to reduce fragmentation of the CMS old gen. Also tightened some assertions, including those related to locking. Reviewed-by: jmasa
author ysr
date Wed, 23 Dec 2009 09:23:54 -0800
parents 98cb887364d3
children c18cbe5936b8
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
460
424f9bfe6b96 6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents: 196
diff changeset
47 //-----------------------------hash--------------------------------------------
424f9bfe6b96 6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents: 196
diff changeset
48 uint BoxLockNode::hash() const {
424f9bfe6b96 6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents: 196
diff changeset
49 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
50 }
424f9bfe6b96 6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents: 196
diff changeset
51
0
a61af66fc99e Initial load
duke
parents:
diff changeset
52 //------------------------------cmp--------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
53 uint BoxLockNode::cmp( const Node &n ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 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
55 return bn._slot == _slot && bn._is_eliminated == _is_eliminated;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57
a61af66fc99e Initial load
duke
parents:
diff changeset
58 OptoReg::Name BoxLockNode::stack_slot(Node* box_node) {
a61af66fc99e Initial load
duke
parents:
diff changeset
59 // Chase down the BoxNode
a61af66fc99e Initial load
duke
parents:
diff changeset
60 while (!box_node->is_BoxLock()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // if (box_node->is_SpillCopy()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // Node *m = box_node->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // if (m->is_Mach() && m->as_Mach()->ideal_Opcode() == Op_StoreP) {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // box_node = m->in(m->as_Mach()->operand_index(2));
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // continue;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // }
a61af66fc99e Initial load
duke
parents:
diff changeset
68 assert(box_node->is_SpillCopy() || box_node->is_Phi(), "Bad spill of Lock.");
a61af66fc99e Initial load
duke
parents:
diff changeset
69 box_node = box_node->in(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
70 }
a61af66fc99e Initial load
duke
parents:
diff changeset
71 return box_node->in_RegMask(0).find_first_elem();
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73
a61af66fc99e Initial load
duke
parents:
diff changeset
74 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
75 //-----------------------------hash--------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
76 uint FastLockNode::hash() const { return NO_HASH; }
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 //------------------------------cmp--------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
79 uint FastLockNode::cmp( const Node &n ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 return (&n == this); // Always fail except on self
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
84 //-----------------------------hash--------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
85 uint FastUnlockNode::hash() const { return NO_HASH; }
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 //------------------------------cmp--------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
88 uint FastUnlockNode::cmp( const Node &n ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 return (&n == this); // Always fail except on self
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 //
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // Create a counter which counts the number of times this lock is acquired
a61af66fc99e Initial load
duke
parents:
diff changeset
94 //
a61af66fc99e Initial load
duke
parents:
diff changeset
95 void FastLockNode::create_lock_counter(JVMState* state) {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 BiasedLockingNamedCounter* blnc = (BiasedLockingNamedCounter*)
a61af66fc99e Initial load
duke
parents:
diff changeset
97 OptoRuntime::new_named_counter(state, NamedCounter::BiasedLockingCounter);
a61af66fc99e Initial load
duke
parents:
diff changeset
98 _counters = blnc->counters();
a61af66fc99e Initial load
duke
parents:
diff changeset
99 }
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
102 //------------------------------do_monitor_enter-------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
103 void Parse::do_monitor_enter() {
a61af66fc99e Initial load
duke
parents:
diff changeset
104 kill_dead_locals();
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // Null check; get casted pointer.
a61af66fc99e Initial load
duke
parents:
diff changeset
107 Node *obj = do_null_check(peek(), T_OBJECT);
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // Check for locking null object
a61af66fc99e Initial load
duke
parents:
diff changeset
109 if (stopped()) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // the monitor object is not part of debug info expression stack
a61af66fc99e Initial load
duke
parents:
diff changeset
112 pop();
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // Insert a FastLockNode which takes as arguments the current thread pointer,
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // the obj pointer & the address of the stack slot pair used for the lock.
a61af66fc99e Initial load
duke
parents:
diff changeset
116 shared_lock(obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
117 }
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 //------------------------------do_monitor_exit--------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
120 void Parse::do_monitor_exit() {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 kill_dead_locals();
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 pop(); // Pop oop to unlock
605
98cb887364d3 6810672: Comment typos
twisti
parents: 460
diff changeset
124 // Because monitors are guaranteed paired (else we bail out), we know
0
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // the matching Lock for this Unlock. Hence we know there is no need
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // for a null check on Unlock.
a61af66fc99e Initial load
duke
parents:
diff changeset
127 shared_unlock(map()->peek_monitor_box(), map()->peek_monitor_obj());
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }