Mercurial > hg > truffle
comparison src/share/vm/opto/ifg.cpp @ 10111:8373c19be854
8011621: live_ranges_in_separate_class.patch
Reviewed-by: kvn, roland
Contributed-by: niclas.adlertz@oracle.com
author | neliasso |
---|---|
date | Tue, 16 Apr 2013 10:08:41 +0200 |
parents | b808febcad9a |
children | d1034bd8cefc |
comparison
equal
deleted
inserted
replaced
10109:1c6887c9afaa | 10111:8373c19be854 |
---|---|
284 IndexSet *set = &_adjs[i]; | 284 IndexSet *set = &_adjs[i]; |
285 IndexSetIterator elements(set); | 285 IndexSetIterator elements(set); |
286 uint idx; | 286 uint idx; |
287 uint last = 0; | 287 uint last = 0; |
288 while ((idx = elements.next()) != 0) { | 288 while ((idx = elements.next()) != 0) { |
289 assert( idx != i, "Must have empty diagonal"); | 289 assert(idx != i, "Must have empty diagonal"); |
290 assert( pc->Find_const(idx) == idx, "Must not need Find" ); | 290 assert(pc->_lrg_map.find_const(idx) == idx, "Must not need Find"); |
291 assert( _adjs[idx].member(i), "IFG not square" ); | 291 assert(_adjs[idx].member(i), "IFG not square"); |
292 assert( !(*_yanked)[idx], "No yanked neighbors" ); | 292 assert(!(*_yanked)[idx], "No yanked neighbors"); |
293 assert( last < idx, "not sorted increasing"); | 293 assert(last < idx, "not sorted increasing"); |
294 last = idx; | 294 last = idx; |
295 } | 295 } |
296 assert( !lrgs(i)._degree_valid || | 296 assert(!lrgs(i)._degree_valid || effective_degree(i) == lrgs(i).degree(), "degree is valid but wrong"); |
297 effective_degree(i) == lrgs(i).degree(), "degree is valid but wrong" ); | |
298 } | 297 } |
299 } | 298 } |
300 #endif | 299 #endif |
301 | 300 |
302 //------------------------------interfere_with_live---------------------------- | 301 //------------------------------interfere_with_live---------------------------- |
340 // added to the live-ness set. | 339 // added to the live-ness set. |
341 for( uint j = b->end_idx() + 1; j > 1; j-- ) { | 340 for( uint j = b->end_idx() + 1; j > 1; j-- ) { |
342 Node *n = b->_nodes[j-1]; | 341 Node *n = b->_nodes[j-1]; |
343 | 342 |
344 // Get value being defined | 343 // Get value being defined |
345 uint r = n2lidx(n); | 344 uint r = _lrg_map.live_range_id(n); |
346 | 345 |
347 // Some special values do not allocate | 346 // Some special values do not allocate |
348 if( r ) { | 347 if (r) { |
349 | 348 |
350 // Remove from live-out set | 349 // Remove from live-out set |
351 liveout->remove(r); | 350 liveout->remove(r); |
352 | 351 |
353 // Copies do not define a new value and so do not interfere. | 352 // Copies do not define a new value and so do not interfere. |
354 // Remove the copies source from the liveout set before interfering. | 353 // Remove the copies source from the liveout set before interfering. |
355 uint idx = n->is_Copy(); | 354 uint idx = n->is_Copy(); |
356 if( idx ) liveout->remove( n2lidx(n->in(idx)) ); | 355 if (idx) { |
356 liveout->remove(_lrg_map.live_range_id(n->in(idx))); | |
357 } | |
357 | 358 |
358 // Interfere with everything live | 359 // Interfere with everything live |
359 interfere_with_live( r, liveout ); | 360 interfere_with_live(r, liveout); |
360 } | 361 } |
361 | 362 |
362 // Make all inputs live | 363 // Make all inputs live |
363 if( !n->is_Phi() ) { // Phi function uses come from prior block | 364 if (!n->is_Phi()) { // Phi function uses come from prior block |
364 for( uint k = 1; k < n->req(); k++ ) | 365 for(uint k = 1; k < n->req(); k++) { |
365 liveout->insert( n2lidx(n->in(k)) ); | 366 liveout->insert(_lrg_map.live_range_id(n->in(k))); |
367 } | |
366 } | 368 } |
367 | 369 |
368 // 2-address instructions always have the defined value live | 370 // 2-address instructions always have the defined value live |
369 // on entry to the instruction, even though it is being defined | 371 // on entry to the instruction, even though it is being defined |
370 // by the instruction. We pretend a virtual copy sits just prior | 372 // by the instruction. We pretend a virtual copy sits just prior |
392 Node *tmp = n->in(1); | 394 Node *tmp = n->in(1); |
393 n->set_req( 1, n->in(2) ); | 395 n->set_req( 1, n->in(2) ); |
394 n->set_req( 2, tmp ); | 396 n->set_req( 2, tmp ); |
395 } | 397 } |
396 // Defined value interferes with all inputs | 398 // Defined value interferes with all inputs |
397 uint lidx = n2lidx(n->in(idx)); | 399 uint lidx = _lrg_map.live_range_id(n->in(idx)); |
398 for( uint k = 1; k < n->req(); k++ ) { | 400 for (uint k = 1; k < n->req(); k++) { |
399 uint kidx = n2lidx(n->in(k)); | 401 uint kidx = _lrg_map.live_range_id(n->in(k)); |
400 if( kidx != lidx ) | 402 if (kidx != lidx) { |
401 _ifg->add_edge( r, kidx ); | 403 _ifg->add_edge(r, kidx); |
404 } | |
402 } | 405 } |
403 } | 406 } |
404 } // End of forall instructions in block | 407 } // End of forall instructions in block |
405 } // End of forall blocks | 408 } // End of forall blocks |
406 } | 409 } |
540 uint j; | 543 uint j; |
541 for( j = last_inst + 1; j > 1; j-- ) { | 544 for( j = last_inst + 1; j > 1; j-- ) { |
542 Node *n = b->_nodes[j - 1]; | 545 Node *n = b->_nodes[j - 1]; |
543 | 546 |
544 // Get value being defined | 547 // Get value being defined |
545 uint r = n2lidx(n); | 548 uint r = _lrg_map.live_range_id(n); |
546 | 549 |
547 // Some special values do not allocate | 550 // Some special values do not allocate |
548 if( r ) { | 551 if(r) { |
549 // A DEF normally costs block frequency; rematerialized values are | 552 // A DEF normally costs block frequency; rematerialized values are |
550 // removed from the DEF sight, so LOWER costs here. | 553 // removed from the DEF sight, so LOWER costs here. |
551 lrgs(r)._cost += n->rematerialize() ? 0 : b->_freq; | 554 lrgs(r)._cost += n->rematerialize() ? 0 : b->_freq; |
552 | 555 |
553 // If it is not live, then this instruction is dead. Probably caused | 556 // If it is not live, then this instruction is dead. Probably caused |
554 // by spilling and rematerialization. Who cares why, yank this baby. | 557 // by spilling and rematerialization. Who cares why, yank this baby. |
555 if( !liveout.member(r) && n->Opcode() != Op_SafePoint ) { | 558 if( !liveout.member(r) && n->Opcode() != Op_SafePoint ) { |
556 Node *def = n->in(0); | 559 Node *def = n->in(0); |
557 if( !n->is_Proj() || | 560 if( !n->is_Proj() || |
558 // Could also be a flags-projection of a dead ADD or such. | 561 // Could also be a flags-projection of a dead ADD or such. |
559 (n2lidx(def) && !liveout.member(n2lidx(def)) ) ) { | 562 (_lrg_map.live_range_id(def) && !liveout.member(_lrg_map.live_range_id(def)))) { |
560 b->_nodes.remove(j - 1); | 563 b->_nodes.remove(j - 1); |
561 if( lrgs(r)._def == n ) lrgs(r)._def = 0; | 564 if (lrgs(r)._def == n) { |
565 lrgs(r)._def = 0; | |
566 } | |
562 n->disconnect_inputs(NULL, C); | 567 n->disconnect_inputs(NULL, C); |
563 _cfg._bbs.map(n->_idx,NULL); | 568 _cfg._bbs.map(n->_idx,NULL); |
564 n->replace_by(C->top()); | 569 n->replace_by(C->top()); |
565 // Since yanking a Node from block, high pressure moves up one | 570 // Since yanking a Node from block, high pressure moves up one |
566 hrp_index[0]--; | 571 hrp_index[0]--; |
568 continue; | 573 continue; |
569 } | 574 } |
570 | 575 |
571 // Fat-projections kill many registers which cannot be used to | 576 // Fat-projections kill many registers which cannot be used to |
572 // hold live ranges. | 577 // hold live ranges. |
573 if( lrgs(r)._fat_proj ) { | 578 if (lrgs(r)._fat_proj) { |
574 // Count the int-only registers | 579 // Count the int-only registers |
575 RegMask itmp = lrgs(r).mask(); | 580 RegMask itmp = lrgs(r).mask(); |
576 itmp.AND(*Matcher::idealreg2regmask[Op_RegI]); | 581 itmp.AND(*Matcher::idealreg2regmask[Op_RegI]); |
577 int iregs = itmp.Size(); | 582 int iregs = itmp.Size(); |
578 if( pressure[0]+iregs > b->_reg_pressure ) | 583 if( pressure[0]+iregs > b->_reg_pressure ) |
634 } | 639 } |
635 | 640 |
636 // Copies do not define a new value and so do not interfere. | 641 // Copies do not define a new value and so do not interfere. |
637 // Remove the copies source from the liveout set before interfering. | 642 // Remove the copies source from the liveout set before interfering. |
638 uint idx = n->is_Copy(); | 643 uint idx = n->is_Copy(); |
639 if( idx ) { | 644 if (idx) { |
640 uint x = n2lidx(n->in(idx)); | 645 uint x = _lrg_map.live_range_id(n->in(idx)); |
641 if( liveout.remove( x ) ) { | 646 if (liveout.remove(x)) { |
642 lrgs(x)._area -= cost; | 647 lrgs(x)._area -= cost; |
643 // Adjust register pressure. | 648 // Adjust register pressure. |
644 lower_pressure( &lrgs(x), j-1, b, pressure, hrp_index ); | 649 lower_pressure(&lrgs(x), j-1, b, pressure, hrp_index); |
645 assert( pressure[0] == count_int_pressure (&liveout), "" ); | 650 assert( pressure[0] == count_int_pressure (&liveout), "" ); |
646 assert( pressure[1] == count_float_pressure(&liveout), "" ); | 651 assert( pressure[1] == count_float_pressure(&liveout), "" ); |
647 } | 652 } |
648 } | 653 } |
649 } // End of if live or not | 654 } // End of if live or not |
725 // they also def flags; if that flag def is unused the | 730 // they also def flags; if that flag def is unused the |
726 // allocator sees a flag-setting instruction with no use of | 731 // allocator sees a flag-setting instruction with no use of |
727 // the flags and assumes it's dead. This keeps the (useless) | 732 // the flags and assumes it's dead. This keeps the (useless) |
728 // flag-setting behavior alive while also keeping the (useful) | 733 // flag-setting behavior alive while also keeping the (useful) |
729 // memory update effect. | 734 // memory update effect. |
730 for( uint k = ((n->Opcode() == Op_SCMemProj) ? 0:1); k < n->req(); k++ ) { | 735 for (uint k = ((n->Opcode() == Op_SCMemProj) ? 0:1); k < n->req(); k++) { |
731 Node *def = n->in(k); | 736 Node *def = n->in(k); |
732 uint x = n2lidx(def); | 737 uint x = _lrg_map.live_range_id(def); |
733 if( !x ) continue; | 738 if (!x) { |
739 continue; | |
740 } | |
734 LRG &lrg = lrgs(x); | 741 LRG &lrg = lrgs(x); |
735 // No use-side cost for spilling debug info | 742 // No use-side cost for spilling debug info |
736 if( k < debug_start ) | 743 if (k < debug_start) { |
737 // A USE costs twice block frequency (once for the Load, once | 744 // A USE costs twice block frequency (once for the Load, once |
738 // for a Load-delay). Rematerialized uses only cost once. | 745 // for a Load-delay). Rematerialized uses only cost once. |
739 lrg._cost += (def->rematerialize() ? b->_freq : (b->_freq + b->_freq)); | 746 lrg._cost += (def->rematerialize() ? b->_freq : (b->_freq + b->_freq)); |
747 } | |
740 // It is live now | 748 // It is live now |
741 if( liveout.insert( x ) ) { | 749 if (liveout.insert(x)) { |
742 // Newly live things assumed live from here to top of block | 750 // Newly live things assumed live from here to top of block |
743 lrg._area += cost; | 751 lrg._area += cost; |
744 // Adjust register pressure | 752 // Adjust register pressure |
745 if (lrg.mask().is_UP() && lrg.mask_size()) { | 753 if (lrg.mask().is_UP() && lrg.mask_size()) { |
746 if (lrg._is_float || lrg._is_vector) { | 754 if (lrg._is_float || lrg._is_vector) { |