comparison src/share/vm/opto/macro.cpp @ 17780:606acabe7b5c

8031320: Use Intel RTM instructions for locks Summary: Use RTM for inflated locks and stack locks. Reviewed-by: iveresov, twisti, roland, dcubed
author kvn
date Thu, 20 Mar 2014 17:49:27 -0700
parents 55fb97c4c58d
children 62c54fcc0a35
comparison
equal deleted inserted replaced
17778:a48e16541e6b 17780:606acabe7b5c
2435 assert(success == (C->macro_count() < old_macro_count), "elimination reduces macro count"); 2435 assert(success == (C->macro_count() < old_macro_count), "elimination reduces macro count");
2436 progress = progress || success; 2436 progress = progress || success;
2437 } 2437 }
2438 } 2438 }
2439 // Next, attempt to eliminate allocations 2439 // Next, attempt to eliminate allocations
2440 _has_locks = false;
2440 progress = true; 2441 progress = true;
2441 while (progress) { 2442 while (progress) {
2442 progress = false; 2443 progress = false;
2443 for (int i = C->macro_count(); i > 0; i--) { 2444 for (int i = C->macro_count(); i > 0; i--) {
2444 Node * n = C->macro_node(i-1); 2445 Node * n = C->macro_node(i-1);
2453 success = eliminate_boxing_node(n->as_CallStaticJava()); 2454 success = eliminate_boxing_node(n->as_CallStaticJava());
2454 break; 2455 break;
2455 case Node::Class_Lock: 2456 case Node::Class_Lock:
2456 case Node::Class_Unlock: 2457 case Node::Class_Unlock:
2457 assert(!n->as_AbstractLock()->is_eliminated(), "sanity"); 2458 assert(!n->as_AbstractLock()->is_eliminated(), "sanity");
2459 _has_locks = true;
2458 break; 2460 break;
2459 default: 2461 default:
2460 assert(n->Opcode() == Op_LoopLimit || 2462 assert(n->Opcode() == Op_LoopLimit ||
2461 n->Opcode() == Op_Opaque1 || 2463 n->Opcode() == Op_Opaque1 ||
2462 n->Opcode() == Op_Opaque2, "unknown node type in macro list"); 2464 n->Opcode() == Op_Opaque2 ||
2465 n->Opcode() == Op_Opaque3, "unknown node type in macro list");
2463 } 2466 }
2464 assert(success == (C->macro_count() < old_macro_count), "elimination reduces macro count"); 2467 assert(success == (C->macro_count() < old_macro_count), "elimination reduces macro count");
2465 progress = progress || success; 2468 progress = progress || success;
2466 } 2469 }
2467 } 2470 }
2498 _igvn._worklist.push(n); 2501 _igvn._worklist.push(n);
2499 success = true; 2502 success = true;
2500 } else if (n->Opcode() == Op_Opaque1 || n->Opcode() == Op_Opaque2) { 2503 } else if (n->Opcode() == Op_Opaque1 || n->Opcode() == Op_Opaque2) {
2501 _igvn.replace_node(n, n->in(1)); 2504 _igvn.replace_node(n, n->in(1));
2502 success = true; 2505 success = true;
2506 #if INCLUDE_RTM_OPT
2507 } else if ((n->Opcode() == Op_Opaque3) && ((Opaque3Node*)n)->rtm_opt()) {
2508 assert(C->profile_rtm(), "should be used only in rtm deoptimization code");
2509 assert((n->outcnt() == 1) && n->unique_out()->is_Cmp(), "");
2510 Node* cmp = n->unique_out();
2511 #ifdef ASSERT
2512 // Validate graph.
2513 assert((cmp->outcnt() == 1) && cmp->unique_out()->is_Bool(), "");
2514 BoolNode* bol = cmp->unique_out()->as_Bool();
2515 assert((bol->outcnt() == 1) && bol->unique_out()->is_If() &&
2516 (bol->_test._test == BoolTest::ne), "");
2517 IfNode* ifn = bol->unique_out()->as_If();
2518 assert((ifn->outcnt() == 2) &&
2519 ifn->proj_out(1)->is_uncommon_trap_proj(Deoptimization::Reason_rtm_state_change), "");
2520 #endif
2521 Node* repl = n->in(1);
2522 if (!_has_locks) {
2523 // Remove RTM state check if there are no locks in the code.
2524 // Replace input to compare the same value.
2525 repl = (cmp->in(1) == n) ? cmp->in(2) : cmp->in(1);
2526 }
2527 _igvn.replace_node(n, repl);
2528 success = true;
2529 #endif
2503 } 2530 }
2504 assert(success == (C->macro_count() < old_macro_count), "elimination reduces macro count"); 2531 assert(success == (C->macro_count() < old_macro_count), "elimination reduces macro count");
2505 progress = progress || success; 2532 progress = progress || success;
2506 } 2533 }
2507 } 2534 }