2445 progress = true;
2446 while (progress) {
2447 progress = false;
2448 for (int i = C->macro_count(); i > 0; i--) {
2449 Node * n = C->macro_node(i-1);
2450 bool success = false;
2451 debug_only(int old_macro_count = C->macro_count(););
2452 switch (n->class_id()) {
2453 case Node::Class_Allocate:
2454 case Node::Class_AllocateArray:
2455 success = eliminate_allocate_node(n->as_Allocate());
2456 break;
2457 case Node::Class_CallStaticJava:
2458 success = eliminate_boxing_node(n->as_CallStaticJava());
2459 break;
2460 case Node::Class_Lock:
2461 case Node::Class_Unlock:
2462 assert(!n->as_AbstractLock()->is_eliminated(), "sanity");
2463 _has_locks = true;
2464 break;
2465 default:
2466 assert(n->Opcode() == Op_LoopLimit ||
2467 n->Opcode() == Op_Opaque1 ||
2468 n->Opcode() == Op_Opaque2 ||
2469 n->Opcode() == Op_Opaque3, "unknown node type in macro list");
2470 }
2471 assert(success == (C->macro_count() < old_macro_count), "elimination reduces macro count");
2472 progress = progress || success;
2473 }
2474 }
2475 }
2476
2477 //------------------------------expand_macro_nodes----------------------
2478 // Returns true if a failure occurred.
2479 bool PhaseMacroExpand::expand_macro_nodes() {
2480 // Last attempt to eliminate macro nodes.
2481 eliminate_macro_nodes();
2482
2483 // Make sure expansion will not cause node limit to be exceeded.
2484 // Worst case is a macro node gets expanded into about 50 nodes.
2518 BoolNode* bol = cmp->unique_out()->as_Bool();
2519 assert((bol->outcnt() == 1) && bol->unique_out()->is_If() &&
2520 (bol->_test._test == BoolTest::ne), "");
2521 IfNode* ifn = bol->unique_out()->as_If();
2522 assert((ifn->outcnt() == 2) &&
2523 ifn->proj_out(1)->is_uncommon_trap_proj(Deoptimization::Reason_rtm_state_change), "");
2524 #endif
2525 Node* repl = n->in(1);
2526 if (!_has_locks) {
2527 // Remove RTM state check if there are no locks in the code.
2528 // Replace input to compare the same value.
2529 repl = (cmp->in(1) == n) ? cmp->in(2) : cmp->in(1);
2530 }
2531 _igvn.replace_node(n, repl);
2532 success = true;
2533 #endif
2534 }
2535 assert(success == (C->macro_count() < old_macro_count), "elimination reduces macro count");
2536 progress = progress || success;
2537 }
2538 }
2539
2540 // expand "macro" nodes
2541 // nodes are removed from the macro list as they are processed
2542 while (C->macro_count() > 0) {
2543 int macro_count = C->macro_count();
2544 Node * n = C->macro_node(macro_count-1);
2545 assert(n->is_macro(), "only macro nodes expected here");
2546 if (_igvn.type(n) == Type::TOP || n->in(0)->is_top() ) {
2547 // node is unreachable, so don't try to expand it
2548 C->remove_macro_node(n);
2549 continue;
2550 }
2551 switch (n->class_id()) {
2552 case Node::Class_Allocate:
2553 expand_allocate(n->as_Allocate());
2554 break;
2555 case Node::Class_AllocateArray:
2556 expand_allocate_array(n->as_AllocateArray());
2557 break;
|
2445 progress = true;
2446 while (progress) {
2447 progress = false;
2448 for (int i = C->macro_count(); i > 0; i--) {
2449 Node * n = C->macro_node(i-1);
2450 bool success = false;
2451 debug_only(int old_macro_count = C->macro_count(););
2452 switch (n->class_id()) {
2453 case Node::Class_Allocate:
2454 case Node::Class_AllocateArray:
2455 success = eliminate_allocate_node(n->as_Allocate());
2456 break;
2457 case Node::Class_CallStaticJava:
2458 success = eliminate_boxing_node(n->as_CallStaticJava());
2459 break;
2460 case Node::Class_Lock:
2461 case Node::Class_Unlock:
2462 assert(!n->as_AbstractLock()->is_eliminated(), "sanity");
2463 _has_locks = true;
2464 break;
2465 case Node::Class_ArrayCopy:
2466 break;
2467 default:
2468 assert(n->Opcode() == Op_LoopLimit ||
2469 n->Opcode() == Op_Opaque1 ||
2470 n->Opcode() == Op_Opaque2 ||
2471 n->Opcode() == Op_Opaque3, "unknown node type in macro list");
2472 }
2473 assert(success == (C->macro_count() < old_macro_count), "elimination reduces macro count");
2474 progress = progress || success;
2475 }
2476 }
2477 }
2478
2479 //------------------------------expand_macro_nodes----------------------
2480 // Returns true if a failure occurred.
2481 bool PhaseMacroExpand::expand_macro_nodes() {
2482 // Last attempt to eliminate macro nodes.
2483 eliminate_macro_nodes();
2484
2485 // Make sure expansion will not cause node limit to be exceeded.
2486 // Worst case is a macro node gets expanded into about 50 nodes.
2520 BoolNode* bol = cmp->unique_out()->as_Bool();
2521 assert((bol->outcnt() == 1) && bol->unique_out()->is_If() &&
2522 (bol->_test._test == BoolTest::ne), "");
2523 IfNode* ifn = bol->unique_out()->as_If();
2524 assert((ifn->outcnt() == 2) &&
2525 ifn->proj_out(1)->is_uncommon_trap_proj(Deoptimization::Reason_rtm_state_change), "");
2526 #endif
2527 Node* repl = n->in(1);
2528 if (!_has_locks) {
2529 // Remove RTM state check if there are no locks in the code.
2530 // Replace input to compare the same value.
2531 repl = (cmp->in(1) == n) ? cmp->in(2) : cmp->in(1);
2532 }
2533 _igvn.replace_node(n, repl);
2534 success = true;
2535 #endif
2536 }
2537 assert(success == (C->macro_count() < old_macro_count), "elimination reduces macro count");
2538 progress = progress || success;
2539 }
2540 }
2541
2542 // expand arraycopy "macro" nodes first
2543 // For ReduceBulkZeroing, we must first process all arraycopy nodes
2544 // before the allocate nodes are expanded.
2545 int macro_idx = C->macro_count() - 1;
2546 while (macro_idx >= 0) {
2547 Node * n = C->macro_node(macro_idx);
2548 assert(n->is_macro(), "only macro nodes expected here");
2549 if (_igvn.type(n) == Type::TOP || n->in(0)->is_top() ) {
2550 // node is unreachable, so don't try to expand it
2551 C->remove_macro_node(n);
2552 } else if (n->is_ArrayCopy()){
2553 int macro_count = C->macro_count();
2554 expand_arraycopy_node(n->as_ArrayCopy());
2555 assert(C->macro_count() < macro_count, "must have deleted a node from macro list");
2556 }
2557 if (C->failing()) return true;
2558 macro_idx --;
2559 }
2560
2561 // expand "macro" nodes
2562 // nodes are removed from the macro list as they are processed
2563 while (C->macro_count() > 0) {
2564 int macro_count = C->macro_count();
2565 Node * n = C->macro_node(macro_count-1);
2566 assert(n->is_macro(), "only macro nodes expected here");
2567 if (_igvn.type(n) == Type::TOP || n->in(0)->is_top() ) {
2568 // node is unreachable, so don't try to expand it
2569 C->remove_macro_node(n);
2570 continue;
2571 }
2572 switch (n->class_id()) {
2573 case Node::Class_Allocate:
2574 expand_allocate(n->as_Allocate());
2575 break;
2576 case Node::Class_AllocateArray:
2577 expand_allocate_array(n->as_AllocateArray());
2578 break;
|