Mercurial > hg > graal-compiler
annotate src/share/vm/opto/callnode.cpp @ 931:72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
Summary: use PcDesc to keep record of the reexecute bit instead of using DebugInfoStreams
Reviewed-by: kvn, never, twisti
author | cfang |
---|---|
date | Thu, 20 Aug 2009 12:42:57 -0700 |
parents | 15bbd3f505c0 |
children | 873ec3787992 |
rev | line source |
---|---|
0 | 1 /* |
844 | 2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 // Portions of code courtesy of Clifford Click | |
26 | |
27 // Optimization - Graph Style | |
28 | |
29 #include "incls/_precompiled.incl" | |
30 #include "incls/_callnode.cpp.incl" | |
31 | |
32 //============================================================================= | |
33 uint StartNode::size_of() const { return sizeof(*this); } | |
34 uint StartNode::cmp( const Node &n ) const | |
35 { return _domain == ((StartNode&)n)._domain; } | |
36 const Type *StartNode::bottom_type() const { return _domain; } | |
37 const Type *StartNode::Value(PhaseTransform *phase) const { return _domain; } | |
38 #ifndef PRODUCT | |
39 void StartNode::dump_spec(outputStream *st) const { st->print(" #"); _domain->dump_on(st);} | |
40 #endif | |
41 | |
42 //------------------------------Ideal------------------------------------------ | |
43 Node *StartNode::Ideal(PhaseGVN *phase, bool can_reshape){ | |
44 return remove_dead_region(phase, can_reshape) ? this : NULL; | |
45 } | |
46 | |
47 //------------------------------calling_convention----------------------------- | |
48 void StartNode::calling_convention( BasicType* sig_bt, VMRegPair *parm_regs, uint argcnt ) const { | |
49 Matcher::calling_convention( sig_bt, parm_regs, argcnt, false ); | |
50 } | |
51 | |
52 //------------------------------Registers-------------------------------------- | |
53 const RegMask &StartNode::in_RegMask(uint) const { | |
54 return RegMask::Empty; | |
55 } | |
56 | |
57 //------------------------------match------------------------------------------ | |
58 // Construct projections for incoming parameters, and their RegMask info | |
59 Node *StartNode::match( const ProjNode *proj, const Matcher *match ) { | |
60 switch (proj->_con) { | |
61 case TypeFunc::Control: | |
62 case TypeFunc::I_O: | |
63 case TypeFunc::Memory: | |
64 return new (match->C, 1) MachProjNode(this,proj->_con,RegMask::Empty,MachProjNode::unmatched_proj); | |
65 case TypeFunc::FramePtr: | |
66 return new (match->C, 1) MachProjNode(this,proj->_con,Matcher::c_frame_ptr_mask, Op_RegP); | |
67 case TypeFunc::ReturnAdr: | |
68 return new (match->C, 1) MachProjNode(this,proj->_con,match->_return_addr_mask,Op_RegP); | |
69 case TypeFunc::Parms: | |
70 default: { | |
71 uint parm_num = proj->_con - TypeFunc::Parms; | |
72 const Type *t = _domain->field_at(proj->_con); | |
73 if (t->base() == Type::Half) // 2nd half of Longs and Doubles | |
74 return new (match->C, 1) ConNode(Type::TOP); | |
75 uint ideal_reg = Matcher::base2reg[t->base()]; | |
76 RegMask &rm = match->_calling_convention_mask[parm_num]; | |
77 return new (match->C, 1) MachProjNode(this,proj->_con,rm,ideal_reg); | |
78 } | |
79 } | |
80 return NULL; | |
81 } | |
82 | |
83 //------------------------------StartOSRNode---------------------------------- | |
84 // The method start node for an on stack replacement adapter | |
85 | |
86 //------------------------------osr_domain----------------------------- | |
87 const TypeTuple *StartOSRNode::osr_domain() { | |
88 const Type **fields = TypeTuple::fields(2); | |
89 fields[TypeFunc::Parms+0] = TypeRawPtr::BOTTOM; // address of osr buffer | |
90 | |
91 return TypeTuple::make(TypeFunc::Parms+1, fields); | |
92 } | |
93 | |
94 //============================================================================= | |
95 const char * const ParmNode::names[TypeFunc::Parms+1] = { | |
96 "Control", "I_O", "Memory", "FramePtr", "ReturnAdr", "Parms" | |
97 }; | |
98 | |
99 #ifndef PRODUCT | |
100 void ParmNode::dump_spec(outputStream *st) const { | |
101 if( _con < TypeFunc::Parms ) { | |
102 st->print(names[_con]); | |
103 } else { | |
104 st->print("Parm%d: ",_con-TypeFunc::Parms); | |
105 // Verbose and WizardMode dump bottom_type for all nodes | |
106 if( !Verbose && !WizardMode ) bottom_type()->dump_on(st); | |
107 } | |
108 } | |
109 #endif | |
110 | |
111 uint ParmNode::ideal_reg() const { | |
112 switch( _con ) { | |
113 case TypeFunc::Control : // fall through | |
114 case TypeFunc::I_O : // fall through | |
115 case TypeFunc::Memory : return 0; | |
116 case TypeFunc::FramePtr : // fall through | |
117 case TypeFunc::ReturnAdr: return Op_RegP; | |
118 default : assert( _con > TypeFunc::Parms, "" ); | |
119 // fall through | |
120 case TypeFunc::Parms : { | |
121 // Type of argument being passed | |
122 const Type *t = in(0)->as_Start()->_domain->field_at(_con); | |
123 return Matcher::base2reg[t->base()]; | |
124 } | |
125 } | |
126 ShouldNotReachHere(); | |
127 return 0; | |
128 } | |
129 | |
130 //============================================================================= | |
131 ReturnNode::ReturnNode(uint edges, Node *cntrl, Node *i_o, Node *memory, Node *frameptr, Node *retadr ) : Node(edges) { | |
132 init_req(TypeFunc::Control,cntrl); | |
133 init_req(TypeFunc::I_O,i_o); | |
134 init_req(TypeFunc::Memory,memory); | |
135 init_req(TypeFunc::FramePtr,frameptr); | |
136 init_req(TypeFunc::ReturnAdr,retadr); | |
137 } | |
138 | |
139 Node *ReturnNode::Ideal(PhaseGVN *phase, bool can_reshape){ | |
140 return remove_dead_region(phase, can_reshape) ? this : NULL; | |
141 } | |
142 | |
143 const Type *ReturnNode::Value( PhaseTransform *phase ) const { | |
144 return ( phase->type(in(TypeFunc::Control)) == Type::TOP) | |
145 ? Type::TOP | |
146 : Type::BOTTOM; | |
147 } | |
148 | |
149 // Do we Match on this edge index or not? No edges on return nodes | |
150 uint ReturnNode::match_edge(uint idx) const { | |
151 return 0; | |
152 } | |
153 | |
154 | |
155 #ifndef PRODUCT | |
156 void ReturnNode::dump_req() const { | |
157 // Dump the required inputs, enclosed in '(' and ')' | |
158 uint i; // Exit value of loop | |
159 for( i=0; i<req(); i++ ) { // For all required inputs | |
160 if( i == TypeFunc::Parms ) tty->print("returns"); | |
161 if( in(i) ) tty->print("%c%d ", Compile::current()->node_arena()->contains(in(i)) ? ' ' : 'o', in(i)->_idx); | |
162 else tty->print("_ "); | |
163 } | |
164 } | |
165 #endif | |
166 | |
167 //============================================================================= | |
168 RethrowNode::RethrowNode( | |
169 Node* cntrl, | |
170 Node* i_o, | |
171 Node* memory, | |
172 Node* frameptr, | |
173 Node* ret_adr, | |
174 Node* exception | |
175 ) : Node(TypeFunc::Parms + 1) { | |
176 init_req(TypeFunc::Control , cntrl ); | |
177 init_req(TypeFunc::I_O , i_o ); | |
178 init_req(TypeFunc::Memory , memory ); | |
179 init_req(TypeFunc::FramePtr , frameptr ); | |
180 init_req(TypeFunc::ReturnAdr, ret_adr); | |
181 init_req(TypeFunc::Parms , exception); | |
182 } | |
183 | |
184 Node *RethrowNode::Ideal(PhaseGVN *phase, bool can_reshape){ | |
185 return remove_dead_region(phase, can_reshape) ? this : NULL; | |
186 } | |
187 | |
188 const Type *RethrowNode::Value( PhaseTransform *phase ) const { | |
189 return (phase->type(in(TypeFunc::Control)) == Type::TOP) | |
190 ? Type::TOP | |
191 : Type::BOTTOM; | |
192 } | |
193 | |
194 uint RethrowNode::match_edge(uint idx) const { | |
195 return 0; | |
196 } | |
197 | |
198 #ifndef PRODUCT | |
199 void RethrowNode::dump_req() const { | |
200 // Dump the required inputs, enclosed in '(' and ')' | |
201 uint i; // Exit value of loop | |
202 for( i=0; i<req(); i++ ) { // For all required inputs | |
203 if( i == TypeFunc::Parms ) tty->print("exception"); | |
204 if( in(i) ) tty->print("%c%d ", Compile::current()->node_arena()->contains(in(i)) ? ' ' : 'o', in(i)->_idx); | |
205 else tty->print("_ "); | |
206 } | |
207 } | |
208 #endif | |
209 | |
210 //============================================================================= | |
211 // Do we Match on this edge index or not? Match only target address & method | |
212 uint TailCallNode::match_edge(uint idx) const { | |
213 return TypeFunc::Parms <= idx && idx <= TypeFunc::Parms+1; | |
214 } | |
215 | |
216 //============================================================================= | |
217 // Do we Match on this edge index or not? Match only target address & oop | |
218 uint TailJumpNode::match_edge(uint idx) const { | |
219 return TypeFunc::Parms <= idx && idx <= TypeFunc::Parms+1; | |
220 } | |
221 | |
222 //============================================================================= | |
223 JVMState::JVMState(ciMethod* method, JVMState* caller) { | |
224 assert(method != NULL, "must be valid call site"); | |
225 _method = method; | |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
704
diff
changeset
|
226 _reexecute = Reexecute_Undefined; |
0 | 227 debug_only(_bci = -99); // random garbage value |
228 debug_only(_map = (SafePointNode*)-1); | |
229 _caller = caller; | |
230 _depth = 1 + (caller == NULL ? 0 : caller->depth()); | |
231 _locoff = TypeFunc::Parms; | |
232 _stkoff = _locoff + _method->max_locals(); | |
233 _monoff = _stkoff + _method->max_stack(); | |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
234 _scloff = _monoff; |
0 | 235 _endoff = _monoff; |
236 _sp = 0; | |
237 } | |
238 JVMState::JVMState(int stack_size) { | |
239 _method = NULL; | |
240 _bci = InvocationEntryBci; | |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
704
diff
changeset
|
241 _reexecute = Reexecute_Undefined; |
0 | 242 debug_only(_map = (SafePointNode*)-1); |
243 _caller = NULL; | |
244 _depth = 1; | |
245 _locoff = TypeFunc::Parms; | |
246 _stkoff = _locoff; | |
247 _monoff = _stkoff + stack_size; | |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
248 _scloff = _monoff; |
0 | 249 _endoff = _monoff; |
250 _sp = 0; | |
251 } | |
252 | |
253 //--------------------------------of_depth------------------------------------- | |
254 JVMState* JVMState::of_depth(int d) const { | |
255 const JVMState* jvmp = this; | |
256 assert(0 < d && (uint)d <= depth(), "oob"); | |
257 for (int skip = depth() - d; skip > 0; skip--) { | |
258 jvmp = jvmp->caller(); | |
259 } | |
260 assert(jvmp->depth() == (uint)d, "found the right one"); | |
261 return (JVMState*)jvmp; | |
262 } | |
263 | |
264 //-----------------------------same_calls_as----------------------------------- | |
265 bool JVMState::same_calls_as(const JVMState* that) const { | |
266 if (this == that) return true; | |
267 if (this->depth() != that->depth()) return false; | |
268 const JVMState* p = this; | |
269 const JVMState* q = that; | |
270 for (;;) { | |
271 if (p->_method != q->_method) return false; | |
272 if (p->_method == NULL) return true; // bci is irrelevant | |
273 if (p->_bci != q->_bci) return false; | |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
704
diff
changeset
|
274 if (p->_reexecute != q->_reexecute) return false; |
0 | 275 p = p->caller(); |
276 q = q->caller(); | |
277 if (p == q) return true; | |
278 assert(p != NULL && q != NULL, "depth check ensures we don't run off end"); | |
279 } | |
280 } | |
281 | |
282 //------------------------------debug_start------------------------------------ | |
283 uint JVMState::debug_start() const { | |
284 debug_only(JVMState* jvmroot = of_depth(1)); | |
285 assert(jvmroot->locoff() <= this->locoff(), "youngest JVMState must be last"); | |
286 return of_depth(1)->locoff(); | |
287 } | |
288 | |
289 //-------------------------------debug_end------------------------------------- | |
290 uint JVMState::debug_end() const { | |
291 debug_only(JVMState* jvmroot = of_depth(1)); | |
292 assert(jvmroot->endoff() <= this->endoff(), "youngest JVMState must be last"); | |
293 return endoff(); | |
294 } | |
295 | |
296 //------------------------------debug_depth------------------------------------ | |
297 uint JVMState::debug_depth() const { | |
298 uint total = 0; | |
299 for (const JVMState* jvmp = this; jvmp != NULL; jvmp = jvmp->caller()) { | |
300 total += jvmp->debug_size(); | |
301 } | |
302 return total; | |
303 } | |
304 | |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
305 #ifndef PRODUCT |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
306 |
0 | 307 //------------------------------format_helper---------------------------------- |
308 // Given an allocation (a Chaitin object) and a Node decide if the Node carries | |
309 // any defined value or not. If it does, print out the register or constant. | |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
310 static void format_helper( PhaseRegAlloc *regalloc, outputStream* st, Node *n, const char *msg, uint i, GrowableArray<SafePointScalarObjectNode*> *scobjs ) { |
0 | 311 if (n == NULL) { st->print(" NULL"); return; } |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
312 if (n->is_SafePointScalarObject()) { |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
313 // Scalar replacement. |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
314 SafePointScalarObjectNode* spobj = n->as_SafePointScalarObject(); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
315 scobjs->append_if_missing(spobj); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
316 int sco_n = scobjs->find(spobj); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
317 assert(sco_n >= 0, ""); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
318 st->print(" %s%d]=#ScObj" INT32_FORMAT, msg, i, sco_n); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
319 return; |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
320 } |
0 | 321 if( OptoReg::is_valid(regalloc->get_reg_first(n))) { // Check for undefined |
322 char buf[50]; | |
323 regalloc->dump_register(n,buf); | |
324 st->print(" %s%d]=%s",msg,i,buf); | |
325 } else { // No register, but might be constant | |
326 const Type *t = n->bottom_type(); | |
327 switch (t->base()) { | |
328 case Type::Int: | |
329 st->print(" %s%d]=#"INT32_FORMAT,msg,i,t->is_int()->get_con()); | |
330 break; | |
331 case Type::AnyPtr: | |
332 assert( t == TypePtr::NULL_PTR, "" ); | |
333 st->print(" %s%d]=#NULL",msg,i); | |
334 break; | |
335 case Type::AryPtr: | |
336 case Type::KlassPtr: | |
337 case Type::InstPtr: | |
338 st->print(" %s%d]=#Ptr" INTPTR_FORMAT,msg,i,t->isa_oopptr()->const_oop()); | |
339 break; | |
331
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
305
diff
changeset
|
340 case Type::NarrowOop: |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
305
diff
changeset
|
341 st->print(" %s%d]=#Ptr" INTPTR_FORMAT,msg,i,t->make_ptr()->isa_oopptr()->const_oop()); |
cecd8eb4e0ca
6706829: Compressed Oops: add debug info for narrow oops
kvn
parents:
305
diff
changeset
|
342 break; |
0 | 343 case Type::RawPtr: |
344 st->print(" %s%d]=#Raw" INTPTR_FORMAT,msg,i,t->is_rawptr()); | |
345 break; | |
346 case Type::DoubleCon: | |
347 st->print(" %s%d]=#%fD",msg,i,t->is_double_constant()->_d); | |
348 break; | |
349 case Type::FloatCon: | |
350 st->print(" %s%d]=#%fF",msg,i,t->is_float_constant()->_f); | |
351 break; | |
352 case Type::Long: | |
353 st->print(" %s%d]=#"INT64_FORMAT,msg,i,t->is_long()->get_con()); | |
354 break; | |
355 case Type::Half: | |
356 case Type::Top: | |
357 st->print(" %s%d]=_",msg,i); | |
358 break; | |
359 default: ShouldNotReachHere(); | |
360 } | |
361 } | |
362 } | |
363 | |
364 //------------------------------format----------------------------------------- | |
365 void JVMState::format(PhaseRegAlloc *regalloc, const Node *n, outputStream* st) const { | |
366 st->print(" #"); | |
367 if( _method ) { | |
368 _method->print_short_name(st); | |
369 st->print(" @ bci:%d ",_bci); | |
370 } else { | |
371 st->print_cr(" runtime stub "); | |
372 return; | |
373 } | |
374 if (n->is_MachSafePoint()) { | |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
375 GrowableArray<SafePointScalarObjectNode*> scobjs; |
0 | 376 MachSafePointNode *mcall = n->as_MachSafePoint(); |
377 uint i; | |
378 // Print locals | |
379 for( i = 0; i < (uint)loc_size(); i++ ) | |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
380 format_helper( regalloc, st, mcall->local(this, i), "L[", i, &scobjs ); |
0 | 381 // Print stack |
382 for (i = 0; i < (uint)stk_size(); i++) { | |
383 if ((uint)(_stkoff + i) >= mcall->len()) | |
384 st->print(" oob "); | |
385 else | |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
386 format_helper( regalloc, st, mcall->stack(this, i), "STK[", i, &scobjs ); |
0 | 387 } |
388 for (i = 0; (int)i < nof_monitors(); i++) { | |
389 Node *box = mcall->monitor_box(this, i); | |
390 Node *obj = mcall->monitor_obj(this, i); | |
391 if ( OptoReg::is_valid(regalloc->get_reg_first(box)) ) { | |
392 while( !box->is_BoxLock() ) box = box->in(1); | |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
393 format_helper( regalloc, st, box, "MON-BOX[", i, &scobjs ); |
0 | 394 } else { |
395 OptoReg::Name box_reg = BoxLockNode::stack_slot(box); | |
396 st->print(" MON-BOX%d=%s+%d", | |
397 i, | |
398 OptoReg::regname(OptoReg::c_frame_pointer), | |
399 regalloc->reg2offset(box_reg)); | |
400 } | |
460
424f9bfe6b96
6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents:
420
diff
changeset
|
401 const char* obj_msg = "MON-OBJ["; |
424f9bfe6b96
6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents:
420
diff
changeset
|
402 if (EliminateLocks) { |
424f9bfe6b96
6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents:
420
diff
changeset
|
403 while( !box->is_BoxLock() ) box = box->in(1); |
424f9bfe6b96
6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents:
420
diff
changeset
|
404 if (box->as_BoxLock()->is_eliminated()) |
424f9bfe6b96
6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents:
420
diff
changeset
|
405 obj_msg = "MON-OBJ(LOCK ELIMINATED)["; |
424f9bfe6b96
6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents:
420
diff
changeset
|
406 } |
424f9bfe6b96
6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents:
420
diff
changeset
|
407 format_helper( regalloc, st, obj, obj_msg, i, &scobjs ); |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
408 } |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
409 |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
410 for (i = 0; i < (uint)scobjs.length(); i++) { |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
411 // Scalar replaced objects. |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
412 st->print_cr(""); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
413 st->print(" # ScObj" INT32_FORMAT " ", i); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
414 SafePointScalarObjectNode* spobj = scobjs.at(i); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
415 ciKlass* cik = spobj->bottom_type()->is_oopptr()->klass(); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
416 assert(cik->is_instance_klass() || |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
417 cik->is_array_klass(), "Not supported allocation."); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
418 ciInstanceKlass *iklass = NULL; |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
419 if (cik->is_instance_klass()) { |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
420 cik->print_name_on(st); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
421 iklass = cik->as_instance_klass(); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
422 } else if (cik->is_type_array_klass()) { |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
423 cik->as_array_klass()->base_element_type()->print_name_on(st); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
424 st->print("[%d]=", spobj->n_fields()); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
425 } else if (cik->is_obj_array_klass()) { |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
426 ciType* cie = cik->as_array_klass()->base_element_type(); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
427 int ndim = 1; |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
428 while (cie->is_obj_array_klass()) { |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
429 ndim += 1; |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
430 cie = cie->as_array_klass()->base_element_type(); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
431 } |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
432 cie->print_name_on(st); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
433 while (ndim-- > 0) { |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
434 st->print("[]"); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
435 } |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
436 st->print("[%d]=", spobj->n_fields()); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
437 } |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
438 st->print("{"); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
439 uint nf = spobj->n_fields(); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
440 if (nf > 0) { |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
441 uint first_ind = spobj->first_index(); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
442 Node* fld_node = mcall->in(first_ind); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
443 ciField* cifield; |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
444 if (iklass != NULL) { |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
445 st->print(" ["); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
446 cifield = iklass->nonstatic_field_at(0); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
447 cifield->print_name_on(st); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
448 format_helper( regalloc, st, fld_node, ":", 0, &scobjs ); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
449 } else { |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
450 format_helper( regalloc, st, fld_node, "[", 0, &scobjs ); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
451 } |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
452 for (uint j = 1; j < nf; j++) { |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
453 fld_node = mcall->in(first_ind+j); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
454 if (iklass != NULL) { |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
455 st->print(", ["); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
456 cifield = iklass->nonstatic_field_at(j); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
457 cifield->print_name_on(st); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
458 format_helper( regalloc, st, fld_node, ":", j, &scobjs ); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
459 } else { |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
460 format_helper( regalloc, st, fld_node, ", [", j, &scobjs ); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
461 } |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
462 } |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
463 } |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
464 st->print(" }"); |
0 | 465 } |
466 } | |
467 st->print_cr(""); | |
468 if (caller() != NULL) caller()->format(regalloc, n, st); | |
469 } | |
470 | |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
471 |
0 | 472 void JVMState::dump_spec(outputStream *st) const { |
473 if (_method != NULL) { | |
474 bool printed = false; | |
475 if (!Verbose) { | |
476 // The JVMS dumps make really, really long lines. | |
477 // Take out the most boring parts, which are the package prefixes. | |
478 char buf[500]; | |
479 stringStream namest(buf, sizeof(buf)); | |
480 _method->print_short_name(&namest); | |
481 if (namest.count() < sizeof(buf)) { | |
482 const char* name = namest.base(); | |
483 if (name[0] == ' ') ++name; | |
484 const char* endcn = strchr(name, ':'); // end of class name | |
485 if (endcn == NULL) endcn = strchr(name, '('); | |
486 if (endcn == NULL) endcn = name + strlen(name); | |
487 while (endcn > name && endcn[-1] != '.' && endcn[-1] != '/') | |
488 --endcn; | |
489 st->print(" %s", endcn); | |
490 printed = true; | |
491 } | |
492 } | |
493 if (!printed) | |
494 _method->print_short_name(st); | |
495 st->print(" @ bci:%d",_bci); | |
931
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
496 if(_reexecute == Reexecute_True) |
72088be4b386
6873116: Modify reexecute implementation to use pcDesc to record the reexecute bit
cfang
parents:
903
diff
changeset
|
497 st->print(" reexecute"); |
0 | 498 } else { |
499 st->print(" runtime stub"); | |
500 } | |
501 if (caller() != NULL) caller()->dump_spec(st); | |
502 } | |
503 | |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
504 |
0 | 505 void JVMState::dump_on(outputStream* st) const { |
506 if (_map && !((uintptr_t)_map & 1)) { | |
507 if (_map->len() > _map->req()) { // _map->has_exceptions() | |
508 Node* ex = _map->in(_map->req()); // _map->next_exception() | |
509 // skip the first one; it's already being printed | |
510 while (ex != NULL && ex->len() > ex->req()) { | |
511 ex = ex->in(ex->req()); // ex->next_exception() | |
512 ex->dump(1); | |
513 } | |
514 } | |
515 _map->dump(2); | |
516 } | |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
704
diff
changeset
|
517 st->print("JVMS depth=%d loc=%d stk=%d mon=%d scalar=%d end=%d mondepth=%d sp=%d bci=%d reexecute=%s method=", |
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
704
diff
changeset
|
518 depth(), locoff(), stkoff(), monoff(), scloff(), endoff(), monitor_depth(), sp(), bci(), should_reexecute()?"true":"false"); |
0 | 519 if (_method == NULL) { |
520 st->print_cr("(none)"); | |
521 } else { | |
522 _method->print_name(st); | |
523 st->cr(); | |
524 if (bci() >= 0 && bci() < _method->code_size()) { | |
525 st->print(" bc: "); | |
526 _method->print_codes_on(bci(), bci()+1, st); | |
527 } | |
528 } | |
529 if (caller() != NULL) { | |
530 caller()->dump_on(st); | |
531 } | |
532 } | |
533 | |
534 // Extra way to dump a jvms from the debugger, | |
535 // to avoid a bug with C++ member function calls. | |
536 void dump_jvms(JVMState* jvms) { | |
537 jvms->dump(); | |
538 } | |
539 #endif | |
540 | |
541 //--------------------------clone_shallow-------------------------------------- | |
542 JVMState* JVMState::clone_shallow(Compile* C) const { | |
543 JVMState* n = has_method() ? new (C) JVMState(_method, _caller) : new (C) JVMState(0); | |
544 n->set_bci(_bci); | |
900
9987d9d5eb0e
6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents:
704
diff
changeset
|
545 n->_reexecute = _reexecute; |
0 | 546 n->set_locoff(_locoff); |
547 n->set_stkoff(_stkoff); | |
548 n->set_monoff(_monoff); | |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
549 n->set_scloff(_scloff); |
0 | 550 n->set_endoff(_endoff); |
551 n->set_sp(_sp); | |
552 n->set_map(_map); | |
553 return n; | |
554 } | |
555 | |
556 //---------------------------clone_deep---------------------------------------- | |
557 JVMState* JVMState::clone_deep(Compile* C) const { | |
558 JVMState* n = clone_shallow(C); | |
559 for (JVMState* p = n; p->_caller != NULL; p = p->_caller) { | |
560 p->_caller = p->_caller->clone_shallow(C); | |
561 } | |
562 assert(n->depth() == depth(), "sanity"); | |
563 assert(n->debug_depth() == debug_depth(), "sanity"); | |
564 return n; | |
565 } | |
566 | |
567 //============================================================================= | |
568 uint CallNode::cmp( const Node &n ) const | |
569 { return _tf == ((CallNode&)n)._tf && _jvms == ((CallNode&)n)._jvms; } | |
570 #ifndef PRODUCT | |
571 void CallNode::dump_req() const { | |
572 // Dump the required inputs, enclosed in '(' and ')' | |
573 uint i; // Exit value of loop | |
574 for( i=0; i<req(); i++ ) { // For all required inputs | |
575 if( i == TypeFunc::Parms ) tty->print("("); | |
576 if( in(i) ) tty->print("%c%d ", Compile::current()->node_arena()->contains(in(i)) ? ' ' : 'o', in(i)->_idx); | |
577 else tty->print("_ "); | |
578 } | |
579 tty->print(")"); | |
580 } | |
581 | |
582 void CallNode::dump_spec(outputStream *st) const { | |
583 st->print(" "); | |
584 tf()->dump_on(st); | |
585 if (_cnt != COUNT_UNKNOWN) st->print(" C=%f",_cnt); | |
586 if (jvms() != NULL) jvms()->dump_spec(st); | |
587 } | |
588 #endif | |
589 | |
590 const Type *CallNode::bottom_type() const { return tf()->range(); } | |
591 const Type *CallNode::Value(PhaseTransform *phase) const { | |
592 if (phase->type(in(0)) == Type::TOP) return Type::TOP; | |
593 return tf()->range(); | |
594 } | |
595 | |
596 //------------------------------calling_convention----------------------------- | |
597 void CallNode::calling_convention( BasicType* sig_bt, VMRegPair *parm_regs, uint argcnt ) const { | |
598 // Use the standard compiler calling convention | |
599 Matcher::calling_convention( sig_bt, parm_regs, argcnt, true ); | |
600 } | |
601 | |
602 | |
603 //------------------------------match------------------------------------------ | |
604 // Construct projections for control, I/O, memory-fields, ..., and | |
605 // return result(s) along with their RegMask info | |
606 Node *CallNode::match( const ProjNode *proj, const Matcher *match ) { | |
607 switch (proj->_con) { | |
608 case TypeFunc::Control: | |
609 case TypeFunc::I_O: | |
610 case TypeFunc::Memory: | |
611 return new (match->C, 1) MachProjNode(this,proj->_con,RegMask::Empty,MachProjNode::unmatched_proj); | |
612 | |
613 case TypeFunc::Parms+1: // For LONG & DOUBLE returns | |
614 assert(tf()->_range->field_at(TypeFunc::Parms+1) == Type::HALF, ""); | |
615 // 2nd half of doubles and longs | |
616 return new (match->C, 1) MachProjNode(this,proj->_con, RegMask::Empty, (uint)OptoReg::Bad); | |
617 | |
618 case TypeFunc::Parms: { // Normal returns | |
619 uint ideal_reg = Matcher::base2reg[tf()->range()->field_at(TypeFunc::Parms)->base()]; | |
620 OptoRegPair regs = is_CallRuntime() | |
621 ? match->c_return_value(ideal_reg,true) // Calls into C runtime | |
622 : match-> return_value(ideal_reg,true); // Calls into compiled Java code | |
623 RegMask rm = RegMask(regs.first()); | |
624 if( OptoReg::is_valid(regs.second()) ) | |
625 rm.Insert( regs.second() ); | |
626 return new (match->C, 1) MachProjNode(this,proj->_con,rm,ideal_reg); | |
627 } | |
628 | |
629 case TypeFunc::ReturnAdr: | |
630 case TypeFunc::FramePtr: | |
631 default: | |
632 ShouldNotReachHere(); | |
633 } | |
634 return NULL; | |
635 } | |
636 | |
637 // Do we Match on this edge index or not? Match no edges | |
638 uint CallNode::match_edge(uint idx) const { | |
639 return 0; | |
640 } | |
641 | |
65 | 642 // |
74
2a9af0b9cb1c
6674600: (Escape Analysis) Optimize memory graph for instance's fields
kvn
parents:
66
diff
changeset
|
643 // Determine whether the call could modify the field of the specified |
2a9af0b9cb1c
6674600: (Escape Analysis) Optimize memory graph for instance's fields
kvn
parents:
66
diff
changeset
|
644 // instance at the specified offset. |
65 | 645 // |
646 bool CallNode::may_modify(const TypePtr *addr_t, PhaseTransform *phase) { | |
647 const TypeOopPtr *adrInst_t = addr_t->isa_oopptr(); | |
648 | |
247 | 649 // If not an OopPtr or not an instance type, assume the worst. |
650 // Note: currently this method is called only for instance types. | |
651 if (adrInst_t == NULL || !adrInst_t->is_known_instance()) { | |
65 | 652 return true; |
653 } | |
247 | 654 // The instance_id is set only for scalar-replaceable allocations which |
655 // are not passed as arguments according to Escape Analysis. | |
65 | 656 return false; |
657 } | |
658 | |
659 // Does this call have a direct reference to n other than debug information? | |
660 bool CallNode::has_non_debug_use(Node *n) { | |
661 const TypeTuple * d = tf()->domain(); | |
662 for (uint i = TypeFunc::Parms; i < d->cnt(); i++) { | |
663 Node *arg = in(i); | |
664 if (arg == n) { | |
665 return true; | |
666 } | |
667 } | |
668 return false; | |
669 } | |
670 | |
671 // Returns the unique CheckCastPP of a call | |
672 // or 'this' if there are several CheckCastPP | |
673 // or returns NULL if there is no one. | |
674 Node *CallNode::result_cast() { | |
675 Node *cast = NULL; | |
676 | |
677 Node *p = proj_out(TypeFunc::Parms); | |
678 if (p == NULL) | |
679 return NULL; | |
680 | |
681 for (DUIterator_Fast imax, i = p->fast_outs(imax); i < imax; i++) { | |
682 Node *use = p->fast_out(i); | |
683 if (use->is_CheckCastPP()) { | |
684 if (cast != NULL) { | |
685 return this; // more than 1 CheckCastPP | |
686 } | |
687 cast = use; | |
688 } | |
689 } | |
690 return cast; | |
691 } | |
692 | |
693 | |
0 | 694 //============================================================================= |
695 uint CallJavaNode::size_of() const { return sizeof(*this); } | |
696 uint CallJavaNode::cmp( const Node &n ) const { | |
697 CallJavaNode &call = (CallJavaNode&)n; | |
698 return CallNode::cmp(call) && _method == call._method; | |
699 } | |
700 #ifndef PRODUCT | |
701 void CallJavaNode::dump_spec(outputStream *st) const { | |
702 if( _method ) _method->print_short_name(st); | |
703 CallNode::dump_spec(st); | |
704 } | |
705 #endif | |
706 | |
707 //============================================================================= | |
708 uint CallStaticJavaNode::size_of() const { return sizeof(*this); } | |
709 uint CallStaticJavaNode::cmp( const Node &n ) const { | |
710 CallStaticJavaNode &call = (CallStaticJavaNode&)n; | |
711 return CallJavaNode::cmp(call); | |
712 } | |
713 | |
714 //----------------------------uncommon_trap_request---------------------------- | |
715 // If this is an uncommon trap, return the request code, else zero. | |
716 int CallStaticJavaNode::uncommon_trap_request() const { | |
717 if (_name != NULL && !strcmp(_name, "uncommon_trap")) { | |
718 return extract_uncommon_trap_request(this); | |
719 } | |
720 return 0; | |
721 } | |
722 int CallStaticJavaNode::extract_uncommon_trap_request(const Node* call) { | |
723 #ifndef PRODUCT | |
724 if (!(call->req() > TypeFunc::Parms && | |
725 call->in(TypeFunc::Parms) != NULL && | |
726 call->in(TypeFunc::Parms)->is_Con())) { | |
727 assert(_in_dump_cnt != 0, "OK if dumping"); | |
728 tty->print("[bad uncommon trap]"); | |
729 return 0; | |
730 } | |
731 #endif | |
732 return call->in(TypeFunc::Parms)->bottom_type()->is_int()->get_con(); | |
733 } | |
734 | |
735 #ifndef PRODUCT | |
736 void CallStaticJavaNode::dump_spec(outputStream *st) const { | |
737 st->print("# Static "); | |
738 if (_name != NULL) { | |
739 st->print("%s", _name); | |
740 int trap_req = uncommon_trap_request(); | |
741 if (trap_req != 0) { | |
742 char buf[100]; | |
743 st->print("(%s)", | |
744 Deoptimization::format_trap_request(buf, sizeof(buf), | |
745 trap_req)); | |
746 } | |
747 st->print(" "); | |
748 } | |
749 CallJavaNode::dump_spec(st); | |
750 } | |
751 #endif | |
752 | |
753 //============================================================================= | |
754 uint CallDynamicJavaNode::size_of() const { return sizeof(*this); } | |
755 uint CallDynamicJavaNode::cmp( const Node &n ) const { | |
756 CallDynamicJavaNode &call = (CallDynamicJavaNode&)n; | |
757 return CallJavaNode::cmp(call); | |
758 } | |
759 #ifndef PRODUCT | |
760 void CallDynamicJavaNode::dump_spec(outputStream *st) const { | |
761 st->print("# Dynamic "); | |
762 CallJavaNode::dump_spec(st); | |
763 } | |
764 #endif | |
765 | |
766 //============================================================================= | |
767 uint CallRuntimeNode::size_of() const { return sizeof(*this); } | |
768 uint CallRuntimeNode::cmp( const Node &n ) const { | |
769 CallRuntimeNode &call = (CallRuntimeNode&)n; | |
770 return CallNode::cmp(call) && !strcmp(_name,call._name); | |
771 } | |
772 #ifndef PRODUCT | |
773 void CallRuntimeNode::dump_spec(outputStream *st) const { | |
774 st->print("# "); | |
775 st->print(_name); | |
776 CallNode::dump_spec(st); | |
777 } | |
778 #endif | |
779 | |
780 //------------------------------calling_convention----------------------------- | |
781 void CallRuntimeNode::calling_convention( BasicType* sig_bt, VMRegPair *parm_regs, uint argcnt ) const { | |
782 Matcher::c_calling_convention( sig_bt, parm_regs, argcnt ); | |
783 } | |
784 | |
785 //============================================================================= | |
786 //------------------------------calling_convention----------------------------- | |
787 | |
788 | |
789 //============================================================================= | |
790 #ifndef PRODUCT | |
791 void CallLeafNode::dump_spec(outputStream *st) const { | |
792 st->print("# "); | |
793 st->print(_name); | |
794 CallNode::dump_spec(st); | |
795 } | |
796 #endif | |
797 | |
798 //============================================================================= | |
799 | |
800 void SafePointNode::set_local(JVMState* jvms, uint idx, Node *c) { | |
801 assert(verify_jvms(jvms), "jvms must match"); | |
802 int loc = jvms->locoff() + idx; | |
803 if (in(loc)->is_top() && idx > 0 && !c->is_top() ) { | |
804 // If current local idx is top then local idx - 1 could | |
805 // be a long/double that needs to be killed since top could | |
806 // represent the 2nd half ofthe long/double. | |
807 uint ideal = in(loc -1)->ideal_reg(); | |
808 if (ideal == Op_RegD || ideal == Op_RegL) { | |
809 // set other (low index) half to top | |
810 set_req(loc - 1, in(loc)); | |
811 } | |
812 } | |
813 set_req(loc, c); | |
814 } | |
815 | |
816 uint SafePointNode::size_of() const { return sizeof(*this); } | |
817 uint SafePointNode::cmp( const Node &n ) const { | |
818 return (&n == this); // Always fail except on self | |
819 } | |
820 | |
821 //-------------------------set_next_exception---------------------------------- | |
822 void SafePointNode::set_next_exception(SafePointNode* n) { | |
823 assert(n == NULL || n->Opcode() == Op_SafePoint, "correct value for next_exception"); | |
824 if (len() == req()) { | |
825 if (n != NULL) add_prec(n); | |
826 } else { | |
827 set_prec(req(), n); | |
828 } | |
829 } | |
830 | |
831 | |
832 //----------------------------next_exception----------------------------------- | |
833 SafePointNode* SafePointNode::next_exception() const { | |
834 if (len() == req()) { | |
835 return NULL; | |
836 } else { | |
837 Node* n = in(req()); | |
838 assert(n == NULL || n->Opcode() == Op_SafePoint, "no other uses of prec edges"); | |
839 return (SafePointNode*) n; | |
840 } | |
841 } | |
842 | |
843 | |
844 //------------------------------Ideal------------------------------------------ | |
845 // Skip over any collapsed Regions | |
846 Node *SafePointNode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
305 | 847 return remove_dead_region(phase, can_reshape) ? this : NULL; |
0 | 848 } |
849 | |
850 //------------------------------Identity--------------------------------------- | |
851 // Remove obviously duplicate safepoints | |
852 Node *SafePointNode::Identity( PhaseTransform *phase ) { | |
853 | |
854 // If you have back to back safepoints, remove one | |
855 if( in(TypeFunc::Control)->is_SafePoint() ) | |
856 return in(TypeFunc::Control); | |
857 | |
858 if( in(0)->is_Proj() ) { | |
859 Node *n0 = in(0)->in(0); | |
860 // Check if he is a call projection (except Leaf Call) | |
861 if( n0->is_Catch() ) { | |
862 n0 = n0->in(0)->in(0); | |
863 assert( n0->is_Call(), "expect a call here" ); | |
864 } | |
865 if( n0->is_Call() && n0->as_Call()->guaranteed_safepoint() ) { | |
866 // Useless Safepoint, so remove it | |
867 return in(TypeFunc::Control); | |
868 } | |
869 } | |
870 | |
871 return this; | |
872 } | |
873 | |
874 //------------------------------Value------------------------------------------ | |
875 const Type *SafePointNode::Value( PhaseTransform *phase ) const { | |
876 if( phase->type(in(0)) == Type::TOP ) return Type::TOP; | |
877 if( phase->eqv( in(0), this ) ) return Type::TOP; // Dead infinite loop | |
878 return Type::CONTROL; | |
879 } | |
880 | |
881 #ifndef PRODUCT | |
882 void SafePointNode::dump_spec(outputStream *st) const { | |
883 st->print(" SafePoint "); | |
884 } | |
885 #endif | |
886 | |
887 const RegMask &SafePointNode::in_RegMask(uint idx) const { | |
888 if( idx < TypeFunc::Parms ) return RegMask::Empty; | |
889 // Values outside the domain represent debug info | |
890 return *(Compile::current()->matcher()->idealreg2debugmask[in(idx)->ideal_reg()]); | |
891 } | |
892 const RegMask &SafePointNode::out_RegMask() const { | |
893 return RegMask::Empty; | |
894 } | |
895 | |
896 | |
897 void SafePointNode::grow_stack(JVMState* jvms, uint grow_by) { | |
898 assert((int)grow_by > 0, "sanity"); | |
899 int monoff = jvms->monoff(); | |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
900 int scloff = jvms->scloff(); |
0 | 901 int endoff = jvms->endoff(); |
902 assert(endoff == (int)req(), "no other states or debug info after me"); | |
903 Node* top = Compile::current()->top(); | |
904 for (uint i = 0; i < grow_by; i++) { | |
905 ins_req(monoff, top); | |
906 } | |
907 jvms->set_monoff(monoff + grow_by); | |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
908 jvms->set_scloff(scloff + grow_by); |
0 | 909 jvms->set_endoff(endoff + grow_by); |
910 } | |
911 | |
912 void SafePointNode::push_monitor(const FastLockNode *lock) { | |
913 // Add a LockNode, which points to both the original BoxLockNode (the | |
914 // stack space for the monitor) and the Object being locked. | |
915 const int MonitorEdges = 2; | |
916 assert(JVMState::logMonitorEdges == exact_log2(MonitorEdges), "correct MonitorEdges"); | |
917 assert(req() == jvms()->endoff(), "correct sizing"); | |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
918 int nextmon = jvms()->scloff(); |
0 | 919 if (GenerateSynchronizationCode) { |
920 add_req(lock->box_node()); | |
921 add_req(lock->obj_node()); | |
922 } else { | |
460
424f9bfe6b96
6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents:
420
diff
changeset
|
923 Node* top = Compile::current()->top(); |
424f9bfe6b96
6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents:
420
diff
changeset
|
924 add_req(top); |
424f9bfe6b96
6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents:
420
diff
changeset
|
925 add_req(top); |
0 | 926 } |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
927 jvms()->set_scloff(nextmon+MonitorEdges); |
0 | 928 jvms()->set_endoff(req()); |
929 } | |
930 | |
931 void SafePointNode::pop_monitor() { | |
932 // Delete last monitor from debug info | |
933 debug_only(int num_before_pop = jvms()->nof_monitors()); | |
934 const int MonitorEdges = (1<<JVMState::logMonitorEdges); | |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
935 int scloff = jvms()->scloff(); |
0 | 936 int endoff = jvms()->endoff(); |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
937 int new_scloff = scloff - MonitorEdges; |
0 | 938 int new_endoff = endoff - MonitorEdges; |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
939 jvms()->set_scloff(new_scloff); |
0 | 940 jvms()->set_endoff(new_endoff); |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
941 while (scloff > new_scloff) del_req(--scloff); |
0 | 942 assert(jvms()->nof_monitors() == num_before_pop-1, ""); |
943 } | |
944 | |
945 Node *SafePointNode::peek_monitor_box() const { | |
946 int mon = jvms()->nof_monitors() - 1; | |
947 assert(mon >= 0, "most have a monitor"); | |
948 return monitor_box(jvms(), mon); | |
949 } | |
950 | |
951 Node *SafePointNode::peek_monitor_obj() const { | |
952 int mon = jvms()->nof_monitors() - 1; | |
953 assert(mon >= 0, "most have a monitor"); | |
954 return monitor_obj(jvms(), mon); | |
955 } | |
956 | |
957 // Do we Match on this edge index or not? Match no edges | |
958 uint SafePointNode::match_edge(uint idx) const { | |
959 if( !needs_polling_address_input() ) | |
960 return 0; | |
961 | |
962 return (TypeFunc::Parms == idx); | |
963 } | |
964 | |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
965 //============== SafePointScalarObjectNode ============== |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
966 |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
967 SafePointScalarObjectNode::SafePointScalarObjectNode(const TypeOopPtr* tp, |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
968 #ifdef ASSERT |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
969 AllocateNode* alloc, |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
970 #endif |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
971 uint first_index, |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
972 uint n_fields) : |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
973 TypeNode(tp, 1), // 1 control input -- seems required. Get from root. |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
974 #ifdef ASSERT |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
975 _alloc(alloc), |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
976 #endif |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
977 _first_index(first_index), |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
978 _n_fields(n_fields) |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
979 { |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
980 init_class_id(Class_SafePointScalarObject); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
981 } |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
982 |
420
a1980da045cc
6462850: generate biased locking code in C2 ideal graph
kvn
parents:
366
diff
changeset
|
983 bool SafePointScalarObjectNode::pinned() const { return true; } |
601
523ded093c31
6809798: SafePointScalarObject node placed into incorrect block during GCM
kvn
parents:
460
diff
changeset
|
984 bool SafePointScalarObjectNode::depends_only_on_test() const { return false; } |
63
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
985 |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
986 uint SafePointScalarObjectNode::ideal_reg() const { |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
987 return 0; // No matching to machine instruction |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
988 } |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
989 |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
990 const RegMask &SafePointScalarObjectNode::in_RegMask(uint idx) const { |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
991 return *(Compile::current()->matcher()->idealreg2debugmask[in(idx)->ideal_reg()]); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
992 } |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
993 |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
994 const RegMask &SafePointScalarObjectNode::out_RegMask() const { |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
995 return RegMask::Empty; |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
996 } |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
997 |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
998 uint SafePointScalarObjectNode::match_edge(uint idx) const { |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
999 return 0; |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1000 } |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1001 |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1002 SafePointScalarObjectNode* |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1003 SafePointScalarObjectNode::clone(int jvms_adj, Dict* sosn_map) const { |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1004 void* cached = (*sosn_map)[(void*)this]; |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1005 if (cached != NULL) { |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1006 return (SafePointScalarObjectNode*)cached; |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1007 } |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1008 Compile* C = Compile::current(); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1009 SafePointScalarObjectNode* res = (SafePointScalarObjectNode*)Node::clone(); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1010 res->_first_index += jvms_adj; |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1011 sosn_map->Insert((void*)this, (void*)res); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1012 return res; |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1013 } |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1014 |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1015 |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1016 #ifndef PRODUCT |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1017 void SafePointScalarObjectNode::dump_spec(outputStream *st) const { |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1018 st->print(" # fields@[%d..%d]", first_index(), |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1019 first_index() + n_fields() - 1); |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1020 } |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1021 |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1022 #endif |
eac007780a58
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint
kvn
parents:
39
diff
changeset
|
1023 |
0 | 1024 //============================================================================= |
1025 uint AllocateNode::size_of() const { return sizeof(*this); } | |
1026 | |
1027 AllocateNode::AllocateNode(Compile* C, const TypeFunc *atype, | |
1028 Node *ctrl, Node *mem, Node *abio, | |
1029 Node *size, Node *klass_node, Node *initial_test) | |
1030 : CallNode(atype, NULL, TypeRawPtr::BOTTOM) | |
1031 { | |
1032 init_class_id(Class_Allocate); | |
1033 init_flags(Flag_is_macro); | |
39
76256d272075
6667612: (Escape Analysis) disable loop cloning if it has a scalar replaceable allocation
kvn
parents:
0
diff
changeset
|
1034 _is_scalar_replaceable = false; |
0 | 1035 Node *topnode = C->top(); |
1036 | |
1037 init_req( TypeFunc::Control , ctrl ); | |
1038 init_req( TypeFunc::I_O , abio ); | |
1039 init_req( TypeFunc::Memory , mem ); | |
1040 init_req( TypeFunc::ReturnAdr, topnode ); | |
1041 init_req( TypeFunc::FramePtr , topnode ); | |
1042 init_req( AllocSize , size); | |
1043 init_req( KlassNode , klass_node); | |
1044 init_req( InitialTest , initial_test); | |
1045 init_req( ALength , topnode); | |
1046 C->add_macro_node(this); | |
1047 } | |
1048 | |
1049 //============================================================================= | |
1050 uint AllocateArrayNode::size_of() const { return sizeof(*this); } | |
1051 | |
704
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1052 Node* AllocateArrayNode::Ideal(PhaseGVN *phase, bool can_reshape) { |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1053 if (remove_dead_region(phase, can_reshape)) return this; |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1054 |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1055 const Type* type = phase->type(Ideal_length()); |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1056 if (type->isa_int() && type->is_int()->_hi < 0) { |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1057 if (can_reshape) { |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1058 PhaseIterGVN *igvn = phase->is_IterGVN(); |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1059 // Unreachable fall through path (negative array length), |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1060 // the allocation can only throw so disconnect it. |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1061 Node* proj = proj_out(TypeFunc::Control); |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1062 Node* catchproj = NULL; |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1063 if (proj != NULL) { |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1064 for (DUIterator_Fast imax, i = proj->fast_outs(imax); i < imax; i++) { |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1065 Node *cn = proj->fast_out(i); |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1066 if (cn->is_Catch()) { |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1067 catchproj = cn->as_Multi()->proj_out(CatchProjNode::fall_through_index); |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1068 break; |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1069 } |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1070 } |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1071 } |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1072 if (catchproj != NULL && catchproj->outcnt() > 0 && |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1073 (catchproj->outcnt() > 1 || |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1074 catchproj->unique_out()->Opcode() != Op_Halt)) { |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1075 assert(catchproj->is_CatchProj(), "must be a CatchProjNode"); |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1076 Node* nproj = catchproj->clone(); |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1077 igvn->register_new_node_with_optimizer(nproj); |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1078 |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1079 Node *frame = new (phase->C, 1) ParmNode( phase->C->start(), TypeFunc::FramePtr ); |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1080 frame = phase->transform(frame); |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1081 // Halt & Catch Fire |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1082 Node *halt = new (phase->C, TypeFunc::Parms) HaltNode( nproj, frame ); |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1083 phase->C->root()->add_req(halt); |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1084 phase->transform(halt); |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1085 |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1086 igvn->replace_node(catchproj, phase->C->top()); |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1087 return this; |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1088 } |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1089 } else { |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1090 // Can't correct it during regular GVN so register for IGVN |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1091 phase->C->record_for_igvn(this); |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1092 } |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1093 } |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1094 return NULL; |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1095 } |
ad8c635e757e
6823453: DeoptimizeALot causes fastdebug server jvm to fail with assert(false,"unscheduable graph")
kvn
parents:
601
diff
changeset
|
1096 |
366
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1097 // Retrieve the length from the AllocateArrayNode. Narrow the type with a |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1098 // CastII, if appropriate. If we are not allowed to create new nodes, and |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1099 // a CastII is appropriate, return NULL. |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1100 Node *AllocateArrayNode::make_ideal_length(const TypeOopPtr* oop_type, PhaseTransform *phase, bool allow_new_nodes) { |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1101 Node *length = in(AllocateNode::ALength); |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1102 assert(length != NULL, "length is not null"); |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1103 |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1104 const TypeInt* length_type = phase->find_int_type(length); |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1105 const TypeAryPtr* ary_type = oop_type->isa_aryptr(); |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1106 |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1107 if (ary_type != NULL && length_type != NULL) { |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1108 const TypeInt* narrow_length_type = ary_type->narrow_size_type(length_type); |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1109 if (narrow_length_type != length_type) { |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1110 // Assert one of: |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1111 // - the narrow_length is 0 |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1112 // - the narrow_length is not wider than length |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1113 assert(narrow_length_type == TypeInt::ZERO || |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1114 (narrow_length_type->_hi <= length_type->_hi && |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1115 narrow_length_type->_lo >= length_type->_lo), |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1116 "narrow type must be narrower than length type"); |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1117 |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1118 // Return NULL if new nodes are not allowed |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1119 if (!allow_new_nodes) return NULL; |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1120 // Create a cast which is control dependent on the initialization to |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1121 // propagate the fact that the array length must be positive. |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1122 length = new (phase->C, 2) CastIINode(length, narrow_length_type); |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1123 length->set_req(0, initialization()->proj_out(0)); |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1124 } |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1125 } |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1126 |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1127 return length; |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1128 } |
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
331
diff
changeset
|
1129 |
0 | 1130 //============================================================================= |
1131 uint LockNode::size_of() const { return sizeof(*this); } | |
1132 | |
1133 // Redundant lock elimination | |
1134 // | |
1135 // There are various patterns of locking where we release and | |
1136 // immediately reacquire a lock in a piece of code where no operations | |
1137 // occur in between that would be observable. In those cases we can | |
1138 // skip releasing and reacquiring the lock without violating any | |
1139 // fairness requirements. Doing this around a loop could cause a lock | |
1140 // to be held for a very long time so we concentrate on non-looping | |
1141 // control flow. We also require that the operations are fully | |
1142 // redundant meaning that we don't introduce new lock operations on | |
1143 // some paths so to be able to eliminate it on others ala PRE. This | |
1144 // would probably require some more extensive graph manipulation to | |
1145 // guarantee that the memory edges were all handled correctly. | |
1146 // | |
1147 // Assuming p is a simple predicate which can't trap in any way and s | |
1148 // is a synchronized method consider this code: | |
1149 // | |
1150 // s(); | |
1151 // if (p) | |
1152 // s(); | |
1153 // else | |
1154 // s(); | |
1155 // s(); | |
1156 // | |
1157 // 1. The unlocks of the first call to s can be eliminated if the | |
1158 // locks inside the then and else branches are eliminated. | |
1159 // | |
1160 // 2. The unlocks of the then and else branches can be eliminated if | |
1161 // the lock of the final call to s is eliminated. | |
1162 // | |
1163 // Either of these cases subsumes the simple case of sequential control flow | |
1164 // | |
1165 // Addtionally we can eliminate versions without the else case: | |
1166 // | |
1167 // s(); | |
1168 // if (p) | |
1169 // s(); | |
1170 // s(); | |
1171 // | |
1172 // 3. In this case we eliminate the unlock of the first s, the lock | |
1173 // and unlock in the then case and the lock in the final s. | |
1174 // | |
1175 // Note also that in all these cases the then/else pieces don't have | |
1176 // to be trivial as long as they begin and end with synchronization | |
1177 // operations. | |
1178 // | |
1179 // s(); | |
1180 // if (p) | |
1181 // s(); | |
1182 // f(); | |
1183 // s(); | |
1184 // s(); | |
1185 // | |
1186 // The code will work properly for this case, leaving in the unlock | |
1187 // before the call to f and the relock after it. | |
1188 // | |
1189 // A potentially interesting case which isn't handled here is when the | |
1190 // locking is partially redundant. | |
1191 // | |
1192 // s(); | |
1193 // if (p) | |
1194 // s(); | |
1195 // | |
1196 // This could be eliminated putting unlocking on the else case and | |
1197 // eliminating the first unlock and the lock in the then side. | |
1198 // Alternatively the unlock could be moved out of the then side so it | |
1199 // was after the merge and the first unlock and second lock | |
1200 // eliminated. This might require less manipulation of the memory | |
1201 // state to get correct. | |
1202 // | |
1203 // Additionally we might allow work between a unlock and lock before | |
1204 // giving up eliminating the locks. The current code disallows any | |
1205 // conditional control flow between these operations. A formulation | |
1206 // similar to partial redundancy elimination computing the | |
1207 // availability of unlocking and the anticipatability of locking at a | |
1208 // program point would allow detection of fully redundant locking with | |
1209 // some amount of work in between. I'm not sure how often I really | |
1210 // think that would occur though. Most of the cases I've seen | |
1211 // indicate it's likely non-trivial work would occur in between. | |
1212 // There may be other more complicated constructs where we could | |
1213 // eliminate locking but I haven't seen any others appear as hot or | |
1214 // interesting. | |
1215 // | |
1216 // Locking and unlocking have a canonical form in ideal that looks | |
1217 // roughly like this: | |
1218 // | |
1219 // <obj> | |
1220 // | \\------+ | |
1221 // | \ \ | |
1222 // | BoxLock \ | |
1223 // | | | \ | |
1224 // | | \ \ | |
1225 // | | FastLock | |
1226 // | | / | |
1227 // | | / | |
1228 // | | | | |
1229 // | |
1230 // Lock | |
1231 // | | |
1232 // Proj #0 | |
1233 // | | |
1234 // MembarAcquire | |
1235 // | | |
1236 // Proj #0 | |
1237 // | |
1238 // MembarRelease | |
1239 // | | |
1240 // Proj #0 | |
1241 // | | |
1242 // Unlock | |
1243 // | | |
1244 // Proj #0 | |
1245 // | |
1246 // | |
1247 // This code proceeds by processing Lock nodes during PhaseIterGVN | |
1248 // and searching back through its control for the proper code | |
1249 // patterns. Once it finds a set of lock and unlock operations to | |
1250 // eliminate they are marked as eliminatable which causes the | |
1251 // expansion of the Lock and Unlock macro nodes to make the operation a NOP | |
1252 // | |
1253 //============================================================================= | |
1254 | |
1255 // | |
1256 // Utility function to skip over uninteresting control nodes. Nodes skipped are: | |
1257 // - copy regions. (These may not have been optimized away yet.) | |
1258 // - eliminated locking nodes | |
1259 // | |
1260 static Node *next_control(Node *ctrl) { | |
1261 if (ctrl == NULL) | |
1262 return NULL; | |
1263 while (1) { | |
1264 if (ctrl->is_Region()) { | |
1265 RegionNode *r = ctrl->as_Region(); | |
1266 Node *n = r->is_copy(); | |
1267 if (n == NULL) | |
1268 break; // hit a region, return it | |
1269 else | |
1270 ctrl = n; | |
1271 } else if (ctrl->is_Proj()) { | |
1272 Node *in0 = ctrl->in(0); | |
1273 if (in0->is_AbstractLock() && in0->as_AbstractLock()->is_eliminated()) { | |
1274 ctrl = in0->in(0); | |
1275 } else { | |
1276 break; | |
1277 } | |
1278 } else { | |
1279 break; // found an interesting control | |
1280 } | |
1281 } | |
1282 return ctrl; | |
1283 } | |
1284 // | |
1285 // Given a control, see if it's the control projection of an Unlock which | |
1286 // operating on the same object as lock. | |
1287 // | |
1288 bool AbstractLockNode::find_matching_unlock(const Node* ctrl, LockNode* lock, | |
1289 GrowableArray<AbstractLockNode*> &lock_ops) { | |
1290 ProjNode *ctrl_proj = (ctrl->is_Proj()) ? ctrl->as_Proj() : NULL; | |
1291 if (ctrl_proj != NULL && ctrl_proj->_con == TypeFunc::Control) { | |
1292 Node *n = ctrl_proj->in(0); | |
1293 if (n != NULL && n->is_Unlock()) { | |
1294 UnlockNode *unlock = n->as_Unlock(); | |
1295 if ((lock->obj_node() == unlock->obj_node()) && | |
1296 (lock->box_node() == unlock->box_node()) && !unlock->is_eliminated()) { | |
1297 lock_ops.append(unlock); | |
1298 return true; | |
1299 } | |
1300 } | |
1301 } | |
1302 return false; | |
1303 } | |
1304 | |
1305 // | |
1306 // Find the lock matching an unlock. Returns null if a safepoint | |
1307 // or complicated control is encountered first. | |
1308 LockNode *AbstractLockNode::find_matching_lock(UnlockNode* unlock) { | |
1309 LockNode *lock_result = NULL; | |
1310 // find the matching lock, or an intervening safepoint | |
1311 Node *ctrl = next_control(unlock->in(0)); | |
1312 while (1) { | |
1313 assert(ctrl != NULL, "invalid control graph"); | |
1314 assert(!ctrl->is_Start(), "missing lock for unlock"); | |
1315 if (ctrl->is_top()) break; // dead control path | |
1316 if (ctrl->is_Proj()) ctrl = ctrl->in(0); | |
1317 if (ctrl->is_SafePoint()) { | |
1318 break; // found a safepoint (may be the lock we are searching for) | |
1319 } else if (ctrl->is_Region()) { | |
1320 // Check for a simple diamond pattern. Punt on anything more complicated | |
1321 if (ctrl->req() == 3 && ctrl->in(1) != NULL && ctrl->in(2) != NULL) { | |
1322 Node *in1 = next_control(ctrl->in(1)); | |
1323 Node *in2 = next_control(ctrl->in(2)); | |
1324 if (((in1->is_IfTrue() && in2->is_IfFalse()) || | |
1325 (in2->is_IfTrue() && in1->is_IfFalse())) && (in1->in(0) == in2->in(0))) { | |
1326 ctrl = next_control(in1->in(0)->in(0)); | |
1327 } else { | |
1328 break; | |
1329 } | |
1330 } else { | |
1331 break; | |
1332 } | |
1333 } else { | |
1334 ctrl = next_control(ctrl->in(0)); // keep searching | |
1335 } | |
1336 } | |
1337 if (ctrl->is_Lock()) { | |
1338 LockNode *lock = ctrl->as_Lock(); | |
1339 if ((lock->obj_node() == unlock->obj_node()) && | |
1340 (lock->box_node() == unlock->box_node())) { | |
1341 lock_result = lock; | |
1342 } | |
1343 } | |
1344 return lock_result; | |
1345 } | |
1346 | |
1347 // This code corresponds to case 3 above. | |
1348 | |
1349 bool AbstractLockNode::find_lock_and_unlock_through_if(Node* node, LockNode* lock, | |
1350 GrowableArray<AbstractLockNode*> &lock_ops) { | |
1351 Node* if_node = node->in(0); | |
1352 bool if_true = node->is_IfTrue(); | |
1353 | |
1354 if (if_node->is_If() && if_node->outcnt() == 2 && (if_true || node->is_IfFalse())) { | |
1355 Node *lock_ctrl = next_control(if_node->in(0)); | |
1356 if (find_matching_unlock(lock_ctrl, lock, lock_ops)) { | |
1357 Node* lock1_node = NULL; | |
1358 ProjNode* proj = if_node->as_If()->proj_out(!if_true); | |
1359 if (if_true) { | |
1360 if (proj->is_IfFalse() && proj->outcnt() == 1) { | |
1361 lock1_node = proj->unique_out(); | |
1362 } | |
1363 } else { | |
1364 if (proj->is_IfTrue() && proj->outcnt() == 1) { | |
1365 lock1_node = proj->unique_out(); | |
1366 } | |
1367 } | |
1368 if (lock1_node != NULL && lock1_node->is_Lock()) { | |
1369 LockNode *lock1 = lock1_node->as_Lock(); | |
1370 if ((lock->obj_node() == lock1->obj_node()) && | |
1371 (lock->box_node() == lock1->box_node()) && !lock1->is_eliminated()) { | |
1372 lock_ops.append(lock1); | |
1373 return true; | |
1374 } | |
1375 } | |
1376 } | |
1377 } | |
1378 | |
1379 lock_ops.trunc_to(0); | |
1380 return false; | |
1381 } | |
1382 | |
1383 bool AbstractLockNode::find_unlocks_for_region(const RegionNode* region, LockNode* lock, | |
1384 GrowableArray<AbstractLockNode*> &lock_ops) { | |
1385 // check each control merging at this point for a matching unlock. | |
1386 // in(0) should be self edge so skip it. | |
1387 for (int i = 1; i < (int)region->req(); i++) { | |
1388 Node *in_node = next_control(region->in(i)); | |
1389 if (in_node != NULL) { | |
1390 if (find_matching_unlock(in_node, lock, lock_ops)) { | |
1391 // found a match so keep on checking. | |
1392 continue; | |
1393 } else if (find_lock_and_unlock_through_if(in_node, lock, lock_ops)) { | |
1394 continue; | |
1395 } | |
1396 | |
1397 // If we fall through to here then it was some kind of node we | |
1398 // don't understand or there wasn't a matching unlock, so give | |
1399 // up trying to merge locks. | |
1400 lock_ops.trunc_to(0); | |
1401 return false; | |
1402 } | |
1403 } | |
1404 return true; | |
1405 | |
1406 } | |
1407 | |
1408 #ifndef PRODUCT | |
1409 // | |
1410 // Create a counter which counts the number of times this lock is acquired | |
1411 // | |
1412 void AbstractLockNode::create_lock_counter(JVMState* state) { | |
1413 _counter = OptoRuntime::new_named_counter(state, NamedCounter::LockCounter); | |
1414 } | |
1415 #endif | |
1416 | |
1417 void AbstractLockNode::set_eliminated() { | |
1418 _eliminate = true; | |
1419 #ifndef PRODUCT | |
1420 if (_counter) { | |
1421 // Update the counter to indicate that this lock was eliminated. | |
1422 // The counter update code will stay around even though the | |
1423 // optimizer will eliminate the lock operation itself. | |
1424 _counter->set_tag(NamedCounter::EliminatedLockCounter); | |
1425 } | |
1426 #endif | |
1427 } | |
1428 | |
1429 //============================================================================= | |
1430 Node *LockNode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
1431 | |
66
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1432 // perform any generic optimizations first (returns 'this' or NULL) |
0 | 1433 Node *result = SafePointNode::Ideal(phase, can_reshape); |
1434 | |
1435 // Now see if we can optimize away this lock. We don't actually | |
1436 // remove the locking here, we simply set the _eliminate flag which | |
1437 // prevents macro expansion from expanding the lock. Since we don't | |
1438 // modify the graph, the value returned from this function is the | |
1439 // one computed above. | |
66
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1440 if (result == NULL && can_reshape && EliminateLocks && !is_eliminated()) { |
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1441 // |
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1442 // If we are locking an unescaped object, the lock/unlock is unnecessary |
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1443 // |
460
424f9bfe6b96
6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents:
420
diff
changeset
|
1444 ConnectionGraph *cgr = phase->C->congraph(); |
66
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1445 PointsToNode::EscapeState es = PointsToNode::GlobalEscape; |
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1446 if (cgr != NULL) |
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1447 es = cgr->escape_state(obj_node(), phase); |
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1448 if (es != PointsToNode::UnknownEscape && es != PointsToNode::GlobalEscape) { |
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1449 // Mark it eliminated to update any counters |
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1450 this->set_eliminated(); |
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1451 return result; |
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1452 } |
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1453 |
0 | 1454 // |
1455 // Try lock coarsening | |
1456 // | |
1457 PhaseIterGVN* iter = phase->is_IterGVN(); | |
1458 if (iter != NULL) { | |
1459 | |
1460 GrowableArray<AbstractLockNode*> lock_ops; | |
1461 | |
1462 Node *ctrl = next_control(in(0)); | |
1463 | |
1464 // now search back for a matching Unlock | |
1465 if (find_matching_unlock(ctrl, this, lock_ops)) { | |
1466 // found an unlock directly preceding this lock. This is the | |
1467 // case of single unlock directly control dependent on a | |
1468 // single lock which is the trivial version of case 1 or 2. | |
1469 } else if (ctrl->is_Region() ) { | |
1470 if (find_unlocks_for_region(ctrl->as_Region(), this, lock_ops)) { | |
1471 // found lock preceded by multiple unlocks along all paths | |
1472 // joining at this point which is case 3 in description above. | |
1473 } | |
1474 } else { | |
1475 // see if this lock comes from either half of an if and the | |
1476 // predecessors merges unlocks and the other half of the if | |
1477 // performs a lock. | |
1478 if (find_lock_and_unlock_through_if(ctrl, this, lock_ops)) { | |
1479 // found unlock splitting to an if with locks on both branches. | |
1480 } | |
1481 } | |
1482 | |
1483 if (lock_ops.length() > 0) { | |
1484 // add ourselves to the list of locks to be eliminated. | |
1485 lock_ops.append(this); | |
1486 | |
1487 #ifndef PRODUCT | |
1488 if (PrintEliminateLocks) { | |
1489 int locks = 0; | |
1490 int unlocks = 0; | |
1491 for (int i = 0; i < lock_ops.length(); i++) { | |
1492 AbstractLockNode* lock = lock_ops.at(i); | |
66
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1493 if (lock->Opcode() == Op_Lock) |
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1494 locks++; |
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1495 else |
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1496 unlocks++; |
0 | 1497 if (Verbose) { |
1498 lock->dump(1); | |
1499 } | |
1500 } | |
1501 tty->print_cr("***Eliminated %d unlocks and %d locks", unlocks, locks); | |
1502 } | |
1503 #endif | |
1504 | |
1505 // for each of the identified locks, mark them | |
1506 // as eliminatable | |
1507 for (int i = 0; i < lock_ops.length(); i++) { | |
1508 AbstractLockNode* lock = lock_ops.at(i); | |
1509 | |
1510 // Mark it eliminated to update any counters | |
1511 lock->set_eliminated(); | |
460
424f9bfe6b96
6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents:
420
diff
changeset
|
1512 lock->set_coarsened(); |
0 | 1513 } |
1514 } else if (result != NULL && ctrl->is_Region() && | |
1515 iter->_worklist.member(ctrl)) { | |
1516 // We weren't able to find any opportunities but the region this | |
1517 // lock is control dependent on hasn't been processed yet so put | |
1518 // this lock back on the worklist so we can check again once any | |
1519 // region simplification has occurred. | |
1520 iter->_worklist.push(this); | |
1521 } | |
1522 } | |
1523 } | |
1524 | |
1525 return result; | |
1526 } | |
1527 | |
1528 //============================================================================= | |
1529 uint UnlockNode::size_of() const { return sizeof(*this); } | |
1530 | |
1531 //============================================================================= | |
1532 Node *UnlockNode::Ideal(PhaseGVN *phase, bool can_reshape) { | |
1533 | |
66
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1534 // perform any generic optimizations first (returns 'this' or NULL) |
0 | 1535 Node * result = SafePointNode::Ideal(phase, can_reshape); |
1536 | |
1537 // Now see if we can optimize away this unlock. We don't actually | |
1538 // remove the unlocking here, we simply set the _eliminate flag which | |
1539 // prevents macro expansion from expanding the unlock. Since we don't | |
1540 // modify the graph, the value returned from this function is the | |
1541 // one computed above. | |
66
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1542 // Escape state is defined after Parse phase. |
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1543 if (result == NULL && can_reshape && EliminateLocks && !is_eliminated()) { |
0 | 1544 // |
66
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1545 // If we are unlocking an unescaped object, the lock/unlock is unnecessary. |
0 | 1546 // |
460
424f9bfe6b96
6775880: EA +DeoptimizeALot: assert(mon_info->owner()->is_locked(),"object must be locked now")
kvn
parents:
420
diff
changeset
|
1547 ConnectionGraph *cgr = phase->C->congraph(); |
66
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1548 PointsToNode::EscapeState es = PointsToNode::GlobalEscape; |
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1549 if (cgr != NULL) |
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1550 es = cgr->escape_state(obj_node(), phase); |
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1551 if (es != PointsToNode::UnknownEscape && es != PointsToNode::GlobalEscape) { |
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1552 // Mark it eliminated to update any counters |
6dbf1a175d6b
6672848: (Escape Analysis) improve lock elimination with EA
kvn
parents:
65
diff
changeset
|
1553 this->set_eliminated(); |
0 | 1554 } |
1555 } | |
1556 return result; | |
1557 } |