comparison src/share/vm/opto/matcher.cpp @ 11198:1e6d5dec4a4e

Merge.
author Christian Humer <christian.humer@gmail.com>
date Mon, 05 Aug 2013 13:20:06 +0200
parents fcf521c3fbc6
children adb9a7d94cb5 94c202aa2646
comparison
equal deleted inserted replaced
11197:3479ab380552 11198:1e6d5dec4a4e
983 // Use one stack to keep both: child's node/state and parent's node/index 983 // Use one stack to keep both: child's node/state and parent's node/index
984 MStack mstack(max_stack * 2 * 2); // C->unique() * 2 * 2 984 MStack mstack(max_stack * 2 * 2); // C->unique() * 2 * 2
985 mstack.push(n, Visit, NULL, -1); // set NULL as parent to indicate root 985 mstack.push(n, Visit, NULL, -1); // set NULL as parent to indicate root
986 986
987 while (mstack.is_nonempty()) { 987 while (mstack.is_nonempty()) {
988 C->check_node_count(NodeLimitFudgeFactor, "too many nodes matching instructions");
989 if (C->failing()) return NULL;
988 n = mstack.node(); // Leave node on stack 990 n = mstack.node(); // Leave node on stack
989 Node_State nstate = mstack.state(); 991 Node_State nstate = mstack.state();
990 if (nstate == Visit) { 992 if (nstate == Visit) {
991 mstack.set_state(Post_Visit); 993 mstack.set_state(Post_Visit);
992 Node *oldn = n; 994 Node *oldn = n;
2301 2303
2302 // Used by the DFA in dfa_xxx.cpp. Check for a following barrier or 2304 // Used by the DFA in dfa_xxx.cpp. Check for a following barrier or
2303 // atomic instruction acting as a store_load barrier without any 2305 // atomic instruction acting as a store_load barrier without any
2304 // intervening volatile load, and thus we don't need a barrier here. 2306 // intervening volatile load, and thus we don't need a barrier here.
2305 // We retain the Node to act as a compiler ordering barrier. 2307 // We retain the Node to act as a compiler ordering barrier.
2306 bool Matcher::post_store_load_barrier(const Node *vmb) { 2308 bool Matcher::post_store_load_barrier(const Node* vmb) {
2307 Compile *C = Compile::current(); 2309 Compile* C = Compile::current();
2308 assert( vmb->is_MemBar(), "" ); 2310 assert(vmb->is_MemBar(), "");
2309 assert( vmb->Opcode() != Op_MemBarAcquire, "" ); 2311 assert(vmb->Opcode() != Op_MemBarAcquire, "");
2310 const MemBarNode *mem = (const MemBarNode*)vmb; 2312 const MemBarNode* membar = vmb->as_MemBar();
2311 2313
2312 // Get the Proj node, ctrl, that can be used to iterate forward 2314 // Get the Ideal Proj node, ctrl, that can be used to iterate forward
2313 Node *ctrl = NULL; 2315 Node* ctrl = NULL;
2314 DUIterator_Fast imax, i = mem->fast_outs(imax); 2316 for (DUIterator_Fast imax, i = membar->fast_outs(imax); i < imax; i++) {
2315 while( true ) { 2317 Node* p = membar->fast_out(i);
2316 ctrl = mem->fast_out(i); // Throw out-of-bounds if proj not found 2318 assert(p->is_Proj(), "only projections here");
2317 assert( ctrl->is_Proj(), "only projections here" ); 2319 if ((p->as_Proj()->_con == TypeFunc::Control) &&
2318 ProjNode *proj = (ProjNode*)ctrl; 2320 !C->node_arena()->contains(p)) { // Unmatched old-space only
2319 if( proj->_con == TypeFunc::Control && 2321 ctrl = p;
2320 !C->node_arena()->contains(ctrl) ) // Unmatched old-space only
2321 break; 2322 break;
2322 i++; 2323 }
2323 } 2324 }
2324 2325 assert((ctrl != NULL), "missing control projection");
2325 for( DUIterator_Fast jmax, j = ctrl->fast_outs(jmax); j < jmax; j++ ) { 2326
2327 for (DUIterator_Fast jmax, j = ctrl->fast_outs(jmax); j < jmax; j++) {
2326 Node *x = ctrl->fast_out(j); 2328 Node *x = ctrl->fast_out(j);
2327 int xop = x->Opcode(); 2329 int xop = x->Opcode();
2328 2330
2329 // We don't need current barrier if we see another or a lock 2331 // We don't need current barrier if we see another or a lock
2330 // before seeing volatile load. 2332 // before seeing volatile load.
2332 // Op_Fastunlock previously appeared in the Op_* list below. 2334 // Op_Fastunlock previously appeared in the Op_* list below.
2333 // With the advent of 1-0 lock operations we're no longer guaranteed 2335 // With the advent of 1-0 lock operations we're no longer guaranteed
2334 // that a monitor exit operation contains a serializing instruction. 2336 // that a monitor exit operation contains a serializing instruction.
2335 2337
2336 if (xop == Op_MemBarVolatile || 2338 if (xop == Op_MemBarVolatile ||
2337 xop == Op_FastLock ||
2338 xop == Op_CompareAndSwapL || 2339 xop == Op_CompareAndSwapL ||
2339 xop == Op_CompareAndSwapP || 2340 xop == Op_CompareAndSwapP ||
2340 xop == Op_CompareAndSwapN || 2341 xop == Op_CompareAndSwapN ||
2341 xop == Op_CompareAndSwapI) 2342 xop == Op_CompareAndSwapI) {
2342 return true; 2343 return true;
2344 }
2345
2346 // Op_FastLock previously appeared in the Op_* list above.
2347 // With biased locking we're no longer guaranteed that a monitor
2348 // enter operation contains a serializing instruction.
2349 if ((xop == Op_FastLock) && !UseBiasedLocking) {
2350 return true;
2351 }
2343 2352
2344 if (x->is_MemBar()) { 2353 if (x->is_MemBar()) {
2345 // We must retain this membar if there is an upcoming volatile 2354 // We must retain this membar if there is an upcoming volatile
2346 // load, which will be preceded by acquire membar. 2355 // load, which will be followed by acquire membar.
2347 if (xop == Op_MemBarAcquire) 2356 if (xop == Op_MemBarAcquire) {
2348 return false; 2357 return false;
2349 // For other kinds of barriers, check by pretending we 2358 } else {
2350 // are them, and seeing if we can be removed. 2359 // For other kinds of barriers, check by pretending we
2351 else 2360 // are them, and seeing if we can be removed.
2352 return post_store_load_barrier((const MemBarNode*)x); 2361 return post_store_load_barrier(x->as_MemBar());
2353 } 2362 }
2354 2363 }
2355 // Delicate code to detect case of an upcoming fastlock block 2364
2356 if( x->is_If() && x->req() > 1 &&
2357 !C->node_arena()->contains(x) ) { // Unmatched old-space only
2358 Node *iff = x;
2359 Node *bol = iff->in(1);
2360 // The iff might be some random subclass of If or bol might be Con-Top
2361 if (!bol->is_Bool()) return false;
2362 assert( bol->req() > 1, "" );
2363 return (bol->in(1)->Opcode() == Op_FastUnlock);
2364 }
2365 // probably not necessary to check for these 2365 // probably not necessary to check for these
2366 if (x->is_Call() || x->is_SafePoint() || x->is_block_proj()) 2366 if (x->is_Call() || x->is_SafePoint() || x->is_block_proj()) {
2367 return false; 2367 return false;
2368 }
2368 } 2369 }
2369 return false; 2370 return false;
2370 } 2371 }
2371 2372
2372 //============================================================================= 2373 //=============================================================================