src/hotspot/share/opto/output.cpp
changeset 58516 d376d86b0a01
parent 57952 5021d91ba9bd
child 58679 9c3209ff7550
equal deleted inserted replaced
58515:8f849d3ec1e5 58516:d376d86b0a01
    29 #include "code/debugInfo.hpp"
    29 #include "code/debugInfo.hpp"
    30 #include "code/debugInfoRec.hpp"
    30 #include "code/debugInfoRec.hpp"
    31 #include "compiler/compileBroker.hpp"
    31 #include "compiler/compileBroker.hpp"
    32 #include "compiler/compilerDirectives.hpp"
    32 #include "compiler/compilerDirectives.hpp"
    33 #include "compiler/oopMap.hpp"
    33 #include "compiler/oopMap.hpp"
       
    34 #include "gc/shared/barrierSet.hpp"
       
    35 #include "gc/shared/c2/barrierSetC2.hpp"
    34 #include "memory/allocation.inline.hpp"
    36 #include "memory/allocation.inline.hpp"
    35 #include "opto/ad.hpp"
    37 #include "opto/ad.hpp"
    36 #include "opto/callnode.hpp"
    38 #include "opto/callnode.hpp"
    37 #include "opto/cfgnode.hpp"
    39 #include "opto/cfgnode.hpp"
    38 #include "opto/locknode.hpp"
    40 #include "opto/locknode.hpp"
   112         _cfg->map_node_to_block(epilog, block);
   114         _cfg->map_node_to_block(epilog, block);
   113       }
   115       }
   114     }
   116     }
   115   }
   117   }
   116 
   118 
       
   119   // Keeper of sizing aspects
       
   120   BufferSizingData buf_sizes = BufferSizingData();
       
   121 
       
   122   // Initialize code buffer
       
   123   estimate_buffer_size(buf_sizes._const);
       
   124   if (failing()) return;
       
   125 
       
   126   // Pre-compute the length of blocks and replace
       
   127   // long branches with short if machine supports it.
       
   128   // Must be done before ScheduleAndBundle due to SPARC delay slots
   117   uint* blk_starts = NEW_RESOURCE_ARRAY(uint, _cfg->number_of_blocks() + 1);
   129   uint* blk_starts = NEW_RESOURCE_ARRAY(uint, _cfg->number_of_blocks() + 1);
   118   blk_starts[0] = 0;
   130   blk_starts[0] = 0;
   119 
   131   shorten_branches(blk_starts, buf_sizes);
   120   // Initialize code buffer and process short branches.
   132 
   121   CodeBuffer* cb = init_buffer(blk_starts);
   133   ScheduleAndBundle();
   122 
   134   if (failing()) {
       
   135     return;
       
   136   }
       
   137 
       
   138   // Late barrier analysis must be done after schedule and bundle
       
   139   // Otherwise liveness based spilling will fail
       
   140   BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
       
   141   bs->late_barrier_analysis();
       
   142 
       
   143   // Complete sizing of codebuffer
       
   144   CodeBuffer* cb = init_buffer(buf_sizes);
   123   if (cb == NULL || failing()) {
   145   if (cb == NULL || failing()) {
   124     return;
       
   125   }
       
   126 
       
   127   ScheduleAndBundle();
       
   128 
       
   129 #ifndef PRODUCT
       
   130   if (trace_opto_output()) {
       
   131     tty->print("\n---- After ScheduleAndBundle ----\n");
       
   132     for (uint i = 0; i < _cfg->number_of_blocks(); i++) {
       
   133       tty->print("\nBB#%03d:\n", i);
       
   134       Block* block = _cfg->get_block(i);
       
   135       for (uint j = 0; j < block->number_of_nodes(); j++) {
       
   136         Node* n = block->get_node(j);
       
   137         OptoReg::Name reg = _regalloc->get_reg_first(n);
       
   138         tty->print(" %-6s ", reg >= 0 && reg < REG_COUNT ? Matcher::regName[reg] : "");
       
   139         n->dump();
       
   140       }
       
   141     }
       
   142   }
       
   143 #endif
       
   144 
       
   145   if (failing()) {
       
   146     return;
   146     return;
   147   }
   147   }
   148 
   148 
   149   BuildOopMaps();
   149   BuildOopMaps();
   150 
   150 
   221   } // if( MaxLoopPad < OptoLoopAlignment-1 )
   221   } // if( MaxLoopPad < OptoLoopAlignment-1 )
   222 }
   222 }
   223 
   223 
   224 // The architecture description provides short branch variants for some long
   224 // The architecture description provides short branch variants for some long
   225 // branch instructions. Replace eligible long branches with short branches.
   225 // branch instructions. Replace eligible long branches with short branches.
   226 void Compile::shorten_branches(uint* blk_starts, int& code_size, int& reloc_size, int& stub_size) {
   226 void Compile::shorten_branches(uint* blk_starts, BufferSizingData& buf_sizes) {
   227   // Compute size of each block, method size, and relocation information size
   227   // Compute size of each block, method size, and relocation information size
   228   uint nblocks  = _cfg->number_of_blocks();
   228   uint nblocks  = _cfg->number_of_blocks();
   229 
   229 
   230   uint*      jmp_offset = NEW_RESOURCE_ARRAY(uint,nblocks);
   230   uint*      jmp_offset = NEW_RESOURCE_ARRAY(uint,nblocks);
   231   uint*      jmp_size   = NEW_RESOURCE_ARRAY(uint,nblocks);
   231   uint*      jmp_size   = NEW_RESOURCE_ARRAY(uint,nblocks);
   239   DEBUG_ONLY( uint *jmp_rule = NEW_RESOURCE_ARRAY(uint,nblocks); )
   239   DEBUG_ONLY( uint *jmp_rule = NEW_RESOURCE_ARRAY(uint,nblocks); )
   240 
   240 
   241   bool has_short_branch_candidate = false;
   241   bool has_short_branch_candidate = false;
   242 
   242 
   243   // Initialize the sizes to 0
   243   // Initialize the sizes to 0
   244   code_size  = 0;          // Size in bytes of generated code
   244   int code_size  = 0;          // Size in bytes of generated code
   245   stub_size  = 0;          // Size in bytes of all stub entries
   245   int stub_size  = 0;          // Size in bytes of all stub entries
   246   // Size in bytes of all relocation entries, including those in local stubs.
   246   // Size in bytes of all relocation entries, including those in local stubs.
   247   // Start with 2-bytes of reloc info for the unvalidated entry point
   247   // Start with 2-bytes of reloc info for the unvalidated entry point
   248   reloc_size = 1;          // Number of relocation entries
   248   int reloc_size = 1;          // Number of relocation entries
   249 
   249 
   250   // Make three passes.  The first computes pessimistic blk_starts,
   250   // Make three passes.  The first computes pessimistic blk_starts,
   251   // relative jmp_offset and reloc_size information.  The second performs
   251   // relative jmp_offset and reloc_size information.  The second performs
   252   // short branch substitution using the pessimistic sizing.  The
   252   // short branch substitution using the pessimistic sizing.  The
   253   // third inserts nops where needed.
   253   // third inserts nops where needed.
   477   // Adjust reloc_size to number of record of relocation info
   477   // Adjust reloc_size to number of record of relocation info
   478   // Min is 2 bytes, max is probably 6 or 8, with a tax up to 25% for
   478   // Min is 2 bytes, max is probably 6 or 8, with a tax up to 25% for
   479   // a relocation index.
   479   // a relocation index.
   480   // The CodeBuffer will expand the locs array if this estimate is too low.
   480   // The CodeBuffer will expand the locs array if this estimate is too low.
   481   reloc_size *= 10 / sizeof(relocInfo);
   481   reloc_size *= 10 / sizeof(relocInfo);
       
   482 
       
   483   buf_sizes._reloc = reloc_size;
       
   484   buf_sizes._code  = code_size;
       
   485   buf_sizes._stub  = stub_size;
   482 }
   486 }
   483 
   487 
   484 //------------------------------FillLocArray-----------------------------------
   488 //------------------------------FillLocArray-----------------------------------
   485 // Create a bit of debug info and append it to the array.  The mapping is from
   489 // Create a bit of debug info and append it to the array.  The mapping is from
   486 // Java local or expression stack to constant, register or stack-slot.  For
   490 // Java local or expression stack to constant, register or stack-slot.  For
   488 // entry has been taken care of and caller should skip it).
   492 // entry has been taken care of and caller should skip it).
   489 static LocationValue *new_loc_value( PhaseRegAlloc *ra, OptoReg::Name regnum, Location::Type l_type ) {
   493 static LocationValue *new_loc_value( PhaseRegAlloc *ra, OptoReg::Name regnum, Location::Type l_type ) {
   490   // This should never have accepted Bad before
   494   // This should never have accepted Bad before
   491   assert(OptoReg::is_valid(regnum), "location must be valid");
   495   assert(OptoReg::is_valid(regnum), "location must be valid");
   492   return (OptoReg::is_reg(regnum))
   496   return (OptoReg::is_reg(regnum))
   493     ? new LocationValue(Location::new_reg_loc(l_type, OptoReg::as_VMReg(regnum)) )
   497          ? new LocationValue(Location::new_reg_loc(l_type, OptoReg::as_VMReg(regnum)) )
   494     : new LocationValue(Location::new_stk_loc(l_type,  ra->reg2offset(regnum)));
   498          : new LocationValue(Location::new_stk_loc(l_type,  ra->reg2offset(regnum)));
   495 }
   499 }
   496 
   500 
   497 
   501 
   498 ObjectValue*
   502 ObjectValue*
   499 Compile::sv_for_node_id(GrowableArray<ScopeValue*> *objs, int id) {
   503 Compile::sv_for_node_id(GrowableArray<ScopeValue*> *objs, int id) {
   608       array->append(new_loc_value( _regalloc, OptoReg::add(regnum,1), Location::normal ));
   612       array->append(new_loc_value( _regalloc, OptoReg::add(regnum,1), Location::normal ));
   609       array->append(new_loc_value( _regalloc,              regnum   , Location::normal ));
   613       array->append(new_loc_value( _regalloc,              regnum   , Location::normal ));
   610     }
   614     }
   611 #endif //_LP64
   615 #endif //_LP64
   612     else if( (t->base() == Type::FloatBot || t->base() == Type::FloatCon) &&
   616     else if( (t->base() == Type::FloatBot || t->base() == Type::FloatCon) &&
   613                OptoReg::is_reg(regnum) ) {
   617              OptoReg::is_reg(regnum) ) {
   614       array->append(new_loc_value( _regalloc, regnum, Matcher::float_in_double()
   618       array->append(new_loc_value( _regalloc, regnum, Matcher::float_in_double()
   615                                    ? Location::float_in_dbl : Location::normal ));
   619                                                       ? Location::float_in_dbl : Location::normal ));
   616     } else if( t->base() == Type::Int && OptoReg::is_reg(regnum) ) {
   620     } else if( t->base() == Type::Int && OptoReg::is_reg(regnum) ) {
   617       array->append(new_loc_value( _regalloc, regnum, Matcher::int_in_long
   621       array->append(new_loc_value( _regalloc, regnum, Matcher::int_in_long
   618                                    ? Location::int_in_long : Location::normal ));
   622                                                       ? Location::int_in_long : Location::normal ));
   619     } else if( t->base() == Type::NarrowOop ) {
   623     } else if( t->base() == Type::NarrowOop ) {
   620       array->append(new_loc_value( _regalloc, regnum, Location::narrowoop ));
   624       array->append(new_loc_value( _regalloc, regnum, Location::narrowoop ));
   621     } else {
   625     } else {
   622       array->append(new_loc_value( _regalloc, regnum, _regalloc->is_oop(local) ? Location::oop : Location::normal ));
   626       array->append(new_loc_value( _regalloc, regnum, _regalloc->is_oop(local) ? Location::oop : Location::normal ));
   623     }
   627     }
   624     return;
   628     return;
   625   }
   629   }
   626 
   630 
   627   // No register.  It must be constant data.
   631   // No register.  It must be constant data.
   628   switch (t->base()) {
   632   switch (t->base()) {
   629   case Type::Half:              // Second half of a double
   633     case Type::Half:              // Second half of a double
   630     ShouldNotReachHere();       // Caller should skip 2nd halves
   634       ShouldNotReachHere();       // Caller should skip 2nd halves
   631     break;
   635       break;
   632   case Type::AnyPtr:
   636     case Type::AnyPtr:
   633     array->append(new ConstantOopWriteValue(NULL));
       
   634     break;
       
   635   case Type::AryPtr:
       
   636   case Type::InstPtr:          // fall through
       
   637     array->append(new ConstantOopWriteValue(t->isa_oopptr()->const_oop()->constant_encoding()));
       
   638     break;
       
   639   case Type::NarrowOop:
       
   640     if (t == TypeNarrowOop::NULL_PTR) {
       
   641       array->append(new ConstantOopWriteValue(NULL));
   637       array->append(new ConstantOopWriteValue(NULL));
   642     } else {
   638       break;
   643       array->append(new ConstantOopWriteValue(t->make_ptr()->isa_oopptr()->const_oop()->constant_encoding()));
   639     case Type::AryPtr:
   644     }
   640     case Type::InstPtr:          // fall through
   645     break;
   641       array->append(new ConstantOopWriteValue(t->isa_oopptr()->const_oop()->constant_encoding()));
   646   case Type::Int:
   642       break;
   647     array->append(new ConstantIntValue(t->is_int()->get_con()));
   643     case Type::NarrowOop:
   648     break;
   644       if (t == TypeNarrowOop::NULL_PTR) {
   649   case Type::RawPtr:
   645         array->append(new ConstantOopWriteValue(NULL));
   650     // A return address (T_ADDRESS).
   646       } else {
   651     assert((intptr_t)t->is_ptr()->get_con() < (intptr_t)0x10000, "must be a valid BCI");
   647         array->append(new ConstantOopWriteValue(t->make_ptr()->isa_oopptr()->const_oop()->constant_encoding()));
       
   648       }
       
   649       break;
       
   650     case Type::Int:
       
   651       array->append(new ConstantIntValue(t->is_int()->get_con()));
       
   652       break;
       
   653     case Type::RawPtr:
       
   654       // A return address (T_ADDRESS).
       
   655       assert((intptr_t)t->is_ptr()->get_con() < (intptr_t)0x10000, "must be a valid BCI");
   652 #ifdef _LP64
   656 #ifdef _LP64
   653     // Must be restored to the full-width 64-bit stack slot.
   657       // Must be restored to the full-width 64-bit stack slot.
   654     array->append(new ConstantLongValue(t->is_ptr()->get_con()));
   658       array->append(new ConstantLongValue(t->is_ptr()->get_con()));
   655 #else
   659 #else
   656     array->append(new ConstantIntValue(t->is_ptr()->get_con()));
   660       array->append(new ConstantIntValue(t->is_ptr()->get_con()));
   657 #endif
   661 #endif
   658     break;
   662       break;
   659   case Type::FloatCon: {
   663     case Type::FloatCon: {
   660     float f = t->is_float_constant()->getf();
   664       float f = t->is_float_constant()->getf();
   661     array->append(new ConstantIntValue(jint_cast(f)));
   665       array->append(new ConstantIntValue(jint_cast(f)));
   662     break;
   666       break;
   663   }
   667     }
   664   case Type::DoubleCon: {
   668     case Type::DoubleCon: {
   665     jdouble d = t->is_double_constant()->getd();
   669       jdouble d = t->is_double_constant()->getd();
   666 #ifdef _LP64
   670 #ifdef _LP64
   667     array->append(new ConstantIntValue((jint)0));
   671       array->append(new ConstantIntValue((jint)0));
   668     array->append(new ConstantDoubleValue(d));
   672       array->append(new ConstantDoubleValue(d));
   669 #else
   673 #else
   670     // Repack the double as two jints.
   674       // Repack the double as two jints.
   671     // The convention the interpreter uses is that the second local
   675     // The convention the interpreter uses is that the second local
   672     // holds the first raw word of the native double representation.
   676     // holds the first raw word of the native double representation.
   673     // This is actually reasonable, since locals and stack arrays
   677     // This is actually reasonable, since locals and stack arrays
   674     // grow downwards in all implementations.
   678     // grow downwards in all implementations.
   675     // (If, on some machine, the interpreter's Java locals or stack
   679     // (If, on some machine, the interpreter's Java locals or stack
   677     jlong_accessor acc;
   681     jlong_accessor acc;
   678     acc.long_value = jlong_cast(d);
   682     acc.long_value = jlong_cast(d);
   679     array->append(new ConstantIntValue(acc.words[1]));
   683     array->append(new ConstantIntValue(acc.words[1]));
   680     array->append(new ConstantIntValue(acc.words[0]));
   684     array->append(new ConstantIntValue(acc.words[0]));
   681 #endif
   685 #endif
   682     break;
   686       break;
   683   }
   687     }
   684   case Type::Long: {
   688     case Type::Long: {
   685     jlong d = t->is_long()->get_con();
   689       jlong d = t->is_long()->get_con();
   686 #ifdef _LP64
   690 #ifdef _LP64
   687     array->append(new ConstantIntValue((jint)0));
   691       array->append(new ConstantIntValue((jint)0));
   688     array->append(new ConstantLongValue(d));
   692       array->append(new ConstantLongValue(d));
   689 #else
   693 #else
   690     // Repack the long as two jints.
   694       // Repack the long as two jints.
   691     // The convention the interpreter uses is that the second local
   695     // The convention the interpreter uses is that the second local
   692     // holds the first raw word of the native double representation.
   696     // holds the first raw word of the native double representation.
   693     // This is actually reasonable, since locals and stack arrays
   697     // This is actually reasonable, since locals and stack arrays
   694     // grow downwards in all implementations.
   698     // grow downwards in all implementations.
   695     // (If, on some machine, the interpreter's Java locals or stack
   699     // (If, on some machine, the interpreter's Java locals or stack
   697     jlong_accessor acc;
   701     jlong_accessor acc;
   698     acc.long_value = d;
   702     acc.long_value = d;
   699     array->append(new ConstantIntValue(acc.words[1]));
   703     array->append(new ConstantIntValue(acc.words[1]));
   700     array->append(new ConstantIntValue(acc.words[0]));
   704     array->append(new ConstantIntValue(acc.words[0]));
   701 #endif
   705 #endif
   702     break;
   706       break;
   703   }
   707     }
   704   case Type::Top:               // Add an illegal value here
   708     case Type::Top:               // Add an illegal value here
   705     array->append(new LocationValue(Location()));
   709       array->append(new LocationValue(Location()));
   706     break;
   710       break;
   707   default:
   711     default:
   708     ShouldNotReachHere();
   712       ShouldNotReachHere();
   709     break;
   713       break;
   710   }
   714   }
   711 }
   715 }
   712 
   716 
   713 // Determine if this node starts a bundle
   717 // Determine if this node starts a bundle
   714 bool Compile::starts_bundle(const Node *n) const {
   718 bool Compile::starts_bundle(const Node *n) const {
   869 
   873 
   870 
   874 
   871 
   875 
   872 // A simplified version of Process_OopMap_Node, to handle non-safepoints.
   876 // A simplified version of Process_OopMap_Node, to handle non-safepoints.
   873 class NonSafepointEmitter {
   877 class NonSafepointEmitter {
   874   Compile*  C;
   878     Compile*  C;
   875   JVMState* _pending_jvms;
   879     JVMState* _pending_jvms;
   876   int       _pending_offset;
   880     int       _pending_offset;
   877 
   881 
   878   void emit_non_safepoint();
   882     void emit_non_safepoint();
   879 
   883 
   880  public:
   884  public:
   881   NonSafepointEmitter(Compile* compile) {
   885     NonSafepointEmitter(Compile* compile) {
   882     this->C = compile;
   886       this->C = compile;
   883     _pending_jvms = NULL;
   887       _pending_jvms = NULL;
   884     _pending_offset = 0;
   888       _pending_offset = 0;
   885   }
   889     }
   886 
   890 
   887   void observe_instruction(Node* n, int pc_offset) {
   891     void observe_instruction(Node* n, int pc_offset) {
   888     if (!C->debug_info()->recording_non_safepoints())  return;
   892       if (!C->debug_info()->recording_non_safepoints())  return;
   889 
   893 
   890     Node_Notes* nn = C->node_notes_at(n->_idx);
   894       Node_Notes* nn = C->node_notes_at(n->_idx);
   891     if (nn == NULL || nn->jvms() == NULL)  return;
   895       if (nn == NULL || nn->jvms() == NULL)  return;
   892     if (_pending_jvms != NULL &&
       
   893         _pending_jvms->same_calls_as(nn->jvms())) {
       
   894       // Repeated JVMS?  Stretch it up here.
       
   895       _pending_offset = pc_offset;
       
   896     } else {
       
   897       if (_pending_jvms != NULL &&
   896       if (_pending_jvms != NULL &&
       
   897           _pending_jvms->same_calls_as(nn->jvms())) {
       
   898         // Repeated JVMS?  Stretch it up here.
       
   899         _pending_offset = pc_offset;
       
   900       } else {
       
   901         if (_pending_jvms != NULL &&
       
   902             _pending_offset < pc_offset) {
       
   903           emit_non_safepoint();
       
   904         }
       
   905         _pending_jvms = NULL;
       
   906         if (pc_offset > C->debug_info()->last_pc_offset()) {
       
   907           // This is the only way _pending_jvms can become non-NULL:
       
   908           _pending_jvms = nn->jvms();
       
   909           _pending_offset = pc_offset;
       
   910         }
       
   911       }
       
   912     }
       
   913 
       
   914     // Stay out of the way of real safepoints:
       
   915     void observe_safepoint(JVMState* jvms, int pc_offset) {
       
   916       if (_pending_jvms != NULL &&
       
   917           !_pending_jvms->same_calls_as(jvms) &&
   898           _pending_offset < pc_offset) {
   918           _pending_offset < pc_offset) {
   899         emit_non_safepoint();
   919         emit_non_safepoint();
   900       }
   920       }
   901       _pending_jvms = NULL;
   921       _pending_jvms = NULL;
   902       if (pc_offset > C->debug_info()->last_pc_offset()) {
   922     }
   903         // This is the only way _pending_jvms can become non-NULL:
   923 
   904         _pending_jvms = nn->jvms();
   924     void flush_at_end() {
   905         _pending_offset = pc_offset;
   925       if (_pending_jvms != NULL) {
   906       }
   926         emit_non_safepoint();
   907     }
   927       }
   908   }
   928       _pending_jvms = NULL;
   909 
   929     }
   910   // Stay out of the way of real safepoints:
       
   911   void observe_safepoint(JVMState* jvms, int pc_offset) {
       
   912     if (_pending_jvms != NULL &&
       
   913         !_pending_jvms->same_calls_as(jvms) &&
       
   914         _pending_offset < pc_offset) {
       
   915       emit_non_safepoint();
       
   916     }
       
   917     _pending_jvms = NULL;
       
   918   }
       
   919 
       
   920   void flush_at_end() {
       
   921     if (_pending_jvms != NULL) {
       
   922       emit_non_safepoint();
       
   923     }
       
   924     _pending_jvms = NULL;
       
   925   }
       
   926 };
   930 };
   927 
   931 
   928 void NonSafepointEmitter::emit_non_safepoint() {
   932 void NonSafepointEmitter::emit_non_safepoint() {
   929   JVMState* youngest_jvms = _pending_jvms;
   933   JVMState* youngest_jvms = _pending_jvms;
   930   int       pc_offset     = _pending_offset;
   934   int       pc_offset     = _pending_offset;
   950   // Mark the end of the scope set.
   954   // Mark the end of the scope set.
   951   debug_info->end_non_safepoint(pc_offset);
   955   debug_info->end_non_safepoint(pc_offset);
   952 }
   956 }
   953 
   957 
   954 //------------------------------init_buffer------------------------------------
   958 //------------------------------init_buffer------------------------------------
   955 CodeBuffer* Compile::init_buffer(uint* blk_starts) {
   959 void Compile::estimate_buffer_size(int& const_req) {
   956 
   960 
   957   // Set the initially allocated size
   961   // Set the initially allocated size
   958   int  code_req   = initial_code_capacity;
   962   const_req = initial_const_capacity;
   959   int  locs_req   = initial_locs_capacity;
   963 
   960   int  stub_req   = initial_stub_capacity;
       
   961   int  const_req  = initial_const_capacity;
       
   962 
       
   963   int  pad_req    = NativeCall::instruction_size;
       
   964   // The extra spacing after the code is necessary on some platforms.
   964   // The extra spacing after the code is necessary on some platforms.
   965   // Sometimes we need to patch in a jump after the last instruction,
   965   // Sometimes we need to patch in a jump after the last instruction,
   966   // if the nmethod has been deoptimized.  (See 4932387, 4894843.)
   966   // if the nmethod has been deoptimized.  (See 4932387, 4894843.)
   967 
   967 
   968   // Compute the byte offset where we can store the deopt pc.
   968   // Compute the byte offset where we can store the deopt pc.
   970     _orig_pc_slot_offset_in_bytes = _regalloc->reg2offset(OptoReg::stack2reg(_orig_pc_slot));
   970     _orig_pc_slot_offset_in_bytes = _regalloc->reg2offset(OptoReg::stack2reg(_orig_pc_slot));
   971   }
   971   }
   972 
   972 
   973   // Compute prolog code size
   973   // Compute prolog code size
   974   _method_size = 0;
   974   _method_size = 0;
   975   _frame_slots = OptoReg::reg2stack(_matcher->_old_SP)+_regalloc->_framesize;
   975   _frame_slots = OptoReg::reg2stack(_matcher->_old_SP) + _regalloc->_framesize;
   976 #if defined(IA64) && !defined(AIX)
   976 #if defined(IA64) && !defined(AIX)
   977   if (save_argument_registers()) {
   977   if (save_argument_registers()) {
   978     // 4815101: this is a stub with implicit and unknown precision fp args.
   978     // 4815101: this is a stub with implicit and unknown precision fp args.
   979     // The usual spill mechanism can only generate stfd's in this case, which
   979     // The usual spill mechanism can only generate stfd's in this case, which
   980     // doesn't work if the fp reg to spill contains a single-precision denorm.
   980     // doesn't work if the fp reg to spill contains a single-precision denorm.
  1019   }
  1019   }
  1020 
  1020 
  1021   // Initialize the space for the BufferBlob used to find and verify
  1021   // Initialize the space for the BufferBlob used to find and verify
  1022   // instruction size in MachNode::emit_size()
  1022   // instruction size in MachNode::emit_size()
  1023   init_scratch_buffer_blob(const_req);
  1023   init_scratch_buffer_blob(const_req);
  1024   if (failing())  return NULL; // Out of memory
  1024 }
  1025 
  1025 
  1026   // Pre-compute the length of blocks and replace
  1026 CodeBuffer* Compile::init_buffer(BufferSizingData& buf_sizes) {
  1027   // long branches with short if machine supports it.
  1027 
  1028   shorten_branches(blk_starts, code_req, locs_req, stub_req);
  1028   int stub_req  = buf_sizes._stub;
       
  1029   int code_req  = buf_sizes._code;
       
  1030   int const_req = buf_sizes._const;
       
  1031 
       
  1032   int pad_req   = NativeCall::instruction_size;
       
  1033 
       
  1034   BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
       
  1035   stub_req += bs->estimate_stub_size();
  1029 
  1036 
  1030   // nmethod and CodeBuffer count stubs & constants as part of method's code.
  1037   // nmethod and CodeBuffer count stubs & constants as part of method's code.
  1031   // class HandlerImpl is platform-specific and defined in the *.ad files.
  1038   // class HandlerImpl is platform-specific and defined in the *.ad files.
  1032   int exception_handler_req = HandlerImpl::size_exception_handler() + MAX_stubs_size; // add marginal slop for handler
  1039   int exception_handler_req = HandlerImpl::size_exception_handler() + MAX_stubs_size; // add marginal slop for handler
  1033   int deopt_handler_req     = HandlerImpl::size_deopt_handler()     + MAX_stubs_size; // add marginal slop for handler
  1040   int deopt_handler_req     = HandlerImpl::size_deopt_handler()     + MAX_stubs_size; // add marginal slop for handler
  1036 
  1043 
  1037   if (StressCodeBuffers)
  1044   if (StressCodeBuffers)
  1038     code_req = const_req = stub_req = exception_handler_req = deopt_handler_req = 0x10;  // force expansion
  1045     code_req = const_req = stub_req = exception_handler_req = deopt_handler_req = 0x10;  // force expansion
  1039 
  1046 
  1040   int total_req =
  1047   int total_req =
  1041     const_req +
  1048           const_req +
  1042     code_req +
  1049           code_req +
  1043     pad_req +
  1050           pad_req +
  1044     stub_req +
  1051           stub_req +
  1045     exception_handler_req +
  1052           exception_handler_req +
  1046     deopt_handler_req;               // deopt handler
  1053           deopt_handler_req;               // deopt handler
  1047 
  1054 
  1048   if (has_method_handle_invokes())
  1055   if (has_method_handle_invokes())
  1049     total_req += deopt_handler_req;  // deopt MH handler
  1056     total_req += deopt_handler_req;  // deopt MH handler
  1050 
  1057 
  1051   CodeBuffer* cb = code_buffer();
  1058   CodeBuffer* cb = code_buffer();
  1052   cb->initialize(total_req, locs_req);
  1059   cb->initialize(total_req, buf_sizes._reloc);
  1053 
  1060 
  1054   // Have we run out of code space?
  1061   // Have we run out of code space?
  1055   if ((cb->blob() == NULL) || (!CompileBroker::should_compile_new_jobs())) {
  1062   if ((cb->blob() == NULL) || (!CompileBroker::should_compile_new_jobs())) {
  1056     C->record_failure("CodeCache is full");
  1063     C->record_failure("CodeCache is full");
  1057     return NULL;
  1064     return NULL;
  1266           non_safepoints.observe_safepoint(mach->as_MachSafePoint()->jvms(),
  1273           non_safepoints.observe_safepoint(mach->as_MachSafePoint()->jvms(),
  1267                                            current_offset);
  1274                                            current_offset);
  1268           Process_OopMap_Node(mach, current_offset);
  1275           Process_OopMap_Node(mach, current_offset);
  1269         } // End if safepoint
  1276         } // End if safepoint
  1270 
  1277 
  1271         // If this is a null check, then add the start of the previous instruction to the list
  1278           // If this is a null check, then add the start of the previous instruction to the list
  1272         else if( mach->is_MachNullCheck() ) {
  1279         else if( mach->is_MachNullCheck() ) {
  1273           inct_starts[inct_cnt++] = previous_offset;
  1280           inct_starts[inct_cnt++] = previous_offset;
  1274         }
  1281         }
  1275 
  1282 
  1276         // If this is a branch, then fill in the label with the target BB's label
  1283           // If this is a branch, then fill in the label with the target BB's label
  1277         else if (mach->is_MachBranch()) {
  1284         else if (mach->is_MachBranch()) {
  1278           // This requires the TRUE branch target be in succs[0]
  1285           // This requires the TRUE branch target be in succs[0]
  1279           uint block_num = block->non_connector_successor(0)->_pre_order;
  1286           uint block_num = block->non_connector_successor(0)->_pre_order;
  1280 
  1287 
  1281           // Try to replace long branch if delay slot is not used,
  1288           // Try to replace long branch if delay slot is not used,
  1282           // it is mostly for back branches since forward branch's
  1289           // it is mostly for back branches since forward branch's
  1283           // distance is not updated yet.
  1290           // distance is not updated yet.
  1284           bool delay_slot_is_used = valid_bundle_info(n) &&
  1291           bool delay_slot_is_used = valid_bundle_info(n) &&
  1285                                     node_bundling(n)->use_unconditional_delay();
  1292                                     node_bundling(n)->use_unconditional_delay();
  1286           if (!delay_slot_is_used && mach->may_be_short_branch()) {
  1293           if (!delay_slot_is_used && mach->may_be_short_branch()) {
  1287            assert(delay_slot == NULL, "not expecting delay slot node");
  1294             assert(delay_slot == NULL, "not expecting delay slot node");
  1288            int br_size = n->size(_regalloc);
  1295             int br_size = n->size(_regalloc);
  1289             int offset = blk_starts[block_num] - current_offset;
  1296             int offset = blk_starts[block_num] - current_offset;
  1290             if (block_num >= i) {
  1297             if (block_num >= i) {
  1291               // Current and following block's offset are not
  1298               // Current and following block's offset are not
  1292               // finalized yet, adjust distance by the difference
  1299               // finalized yet, adjust distance by the difference
  1293               // between calculated and final offsets of current block.
  1300               // between calculated and final offsets of current block.
  1341               }
  1348               }
  1342             }
  1349             }
  1343           }
  1350           }
  1344         }
  1351         }
  1345 #ifdef ASSERT
  1352 #ifdef ASSERT
  1346         // Check that oop-store precedes the card-mark
  1353           // Check that oop-store precedes the card-mark
  1347         else if (mach->ideal_Opcode() == Op_StoreCM) {
  1354         else if (mach->ideal_Opcode() == Op_StoreCM) {
  1348           uint storeCM_idx = j;
  1355           uint storeCM_idx = j;
  1349           int count = 0;
  1356           int count = 0;
  1350           for (uint prec = mach->req(); prec < mach->len(); prec++) {
  1357           for (uint prec = mach->req(); prec < mach->len(); prec++) {
  1351             Node *oop_store = mach->in(prec);  // Precedence edge
  1358             Node *oop_store = mach->in(prec);  // Precedence edge
  1511         assert(false, "Displacement too large for short jmp");
  1518         assert(false, "Displacement too large for short jmp");
  1512       }
  1519       }
  1513     }
  1520     }
  1514   }
  1521   }
  1515 #endif
  1522 #endif
       
  1523 
       
  1524   BarrierSetC2* bs = BarrierSet::barrier_set()->barrier_set_c2();
       
  1525   bs->emit_stubs(*cb);
       
  1526   if (failing())  return;
  1516 
  1527 
  1517 #ifndef PRODUCT
  1528 #ifndef PRODUCT
  1518   // Information on the size of the method, without the extraneous code
  1529   // Information on the size of the method, without the extraneous code
  1519   Scheduling::increment_method_size(cb->insts_size());
  1530   Scheduling::increment_method_size(cb->insts_size());
  1520 #endif
  1531 #endif
  1686 #endif
  1697 #endif
  1687 
  1698 
  1688 // Initializer for class Scheduling
  1699 // Initializer for class Scheduling
  1689 
  1700 
  1690 Scheduling::Scheduling(Arena *arena, Compile &compile)
  1701 Scheduling::Scheduling(Arena *arena, Compile &compile)
  1691   : _arena(arena),
  1702         : _arena(arena),
  1692     _cfg(compile.cfg()),
  1703           _cfg(compile.cfg()),
  1693     _regalloc(compile.regalloc()),
  1704           _regalloc(compile.regalloc()),
  1694     _scheduled(arena),
  1705           _scheduled(arena),
  1695     _available(arena),
  1706           _available(arena),
  1696     _reg_node(arena),
  1707           _reg_node(arena),
  1697     _pinch_free_list(arena),
  1708           _pinch_free_list(arena),
  1698     _next_node(NULL),
  1709           _next_node(NULL),
  1699     _bundle_instr_count(0),
  1710           _bundle_instr_count(0),
  1700     _bundle_cycle_number(0),
  1711           _bundle_cycle_number(0),
  1701     _bundle_use(0, 0, resource_count, &_bundle_use_elements[0])
  1712           _bundle_use(0, 0, resource_count, &_bundle_use_elements[0])
  1702 #ifndef PRODUCT
  1713 #ifndef PRODUCT
  1703   , _branches(0)
  1714         , _branches(0)
  1704   , _unconditional_delays(0)
  1715         , _unconditional_delays(0)
  1705 #endif
  1716 #endif
  1706 {
  1717 {
  1707   // Create a MachNopNode
  1718   // Create a MachNopNode
  1708   _nop = new MachNopNode();
  1719   _nop = new MachNopNode();
  1709 
  1720 
  1780   // Clear the bundling information
  1791   // Clear the bundling information
  1781   _bundle_instr_count = 0;
  1792   _bundle_instr_count = 0;
  1782   _bundle_use.reset();
  1793   _bundle_use.reset();
  1783 
  1794 
  1784   memcpy(_bundle_use_elements,
  1795   memcpy(_bundle_use_elements,
  1785     Pipeline_Use::elaborated_elements,
  1796          Pipeline_Use::elaborated_elements,
  1786     sizeof(Pipeline_Use::elaborated_elements));
  1797          sizeof(Pipeline_Use::elaborated_elements));
  1787 }
  1798 }
  1788 
  1799 
  1789 // Perform instruction scheduling and bundling over the sequence of
  1800 // Perform instruction scheduling and bundling over the sequence of
  1790 // instructions in backwards order.
  1801 // instructions in backwards order.
  1791 void Compile::ScheduleAndBundle() {
  1802 void Compile::ScheduleAndBundle() {
  1808   Scheduling scheduling(Thread::current()->resource_area(), *this);
  1819   Scheduling scheduling(Thread::current()->resource_area(), *this);
  1809 
  1820 
  1810   // Walk backwards over each basic block, computing the needed alignment
  1821   // Walk backwards over each basic block, computing the needed alignment
  1811   // Walk over all the basic blocks
  1822   // Walk over all the basic blocks
  1812   scheduling.DoScheduling();
  1823   scheduling.DoScheduling();
       
  1824 
       
  1825 #ifndef PRODUCT
       
  1826   if (trace_opto_output()) {
       
  1827     tty->print("\n---- After ScheduleAndBundle ----\n");
       
  1828     for (uint i = 0; i < _cfg->number_of_blocks(); i++) {
       
  1829       tty->print("\nBB#%03d:\n", i);
       
  1830       Block* block = _cfg->get_block(i);
       
  1831       for (uint j = 0; j < block->number_of_nodes(); j++) {
       
  1832         Node* n = block->get_node(j);
       
  1833         OptoReg::Name reg = _regalloc->get_reg_first(n);
       
  1834         tty->print(" %-6s ", reg >= 0 && reg < REG_COUNT ? Matcher::regName[reg] : "");
       
  1835         n->dump();
       
  1836       }
       
  1837     }
       
  1838   }
       
  1839 #endif
  1813 }
  1840 }
  1814 
  1841 
  1815 // Compute the latency of all the instructions.  This is fairly simple,
  1842 // Compute the latency of all the instructions.  This is fairly simple,
  1816 // because we already have a legal ordering.  Walk over the instructions
  1843 // because we already have a legal ordering.  Walk over the instructions
  1817 // from first to last, and compute the latency of the instruction based
  1844 // from first to last, and compute the latency of the instruction based
  1876   // If the node cannot be scheduled this cycle, skip it
  1903   // If the node cannot be scheduled this cycle, skip it
  1877   if (_current_latency[n_idx] > _bundle_cycle_number) {
  1904   if (_current_latency[n_idx] > _bundle_cycle_number) {
  1878 #ifndef PRODUCT
  1905 #ifndef PRODUCT
  1879     if (_cfg->C->trace_opto_output())
  1906     if (_cfg->C->trace_opto_output())
  1880       tty->print("#     NodeFitsInBundle [%4d]: FALSE; latency %4d > %d\n",
  1907       tty->print("#     NodeFitsInBundle [%4d]: FALSE; latency %4d > %d\n",
  1881         n->_idx, _current_latency[n_idx], _bundle_cycle_number);
  1908                  n->_idx, _current_latency[n_idx], _bundle_cycle_number);
  1882 #endif
  1909 #endif
  1883     return (false);
  1910     return (false);
  1884   }
  1911   }
  1885 
  1912 
  1886   const Pipeline *node_pipeline = n->pipeline();
  1913   const Pipeline *node_pipeline = n->pipeline();
  1893 
  1920 
  1894   if (_bundle_instr_count + instruction_count > Pipeline::_max_instrs_per_cycle) {
  1921   if (_bundle_instr_count + instruction_count > Pipeline::_max_instrs_per_cycle) {
  1895 #ifndef PRODUCT
  1922 #ifndef PRODUCT
  1896     if (_cfg->C->trace_opto_output())
  1923     if (_cfg->C->trace_opto_output())
  1897       tty->print("#     NodeFitsInBundle [%4d]: FALSE; too many instructions: %d > %d\n",
  1924       tty->print("#     NodeFitsInBundle [%4d]: FALSE; too many instructions: %d > %d\n",
  1898         n->_idx, _bundle_instr_count + instruction_count, Pipeline::_max_instrs_per_cycle);
  1925                  n->_idx, _bundle_instr_count + instruction_count, Pipeline::_max_instrs_per_cycle);
  1899 #endif
  1926 #endif
  1900     return (false);
  1927     return (false);
  1901   }
  1928   }
  1902 
  1929 
  1903   // Don't allow non-machine nodes to be handled this way
  1930   // Don't allow non-machine nodes to be handled this way
  2101         const Pipeline *avail_pipeline = d->pipeline();
  2128         const Pipeline *avail_pipeline = d->pipeline();
  2102 
  2129 
  2103         // Don't allow safepoints in the branch shadow, that will
  2130         // Don't allow safepoints in the branch shadow, that will
  2104         // cause a number of difficulties
  2131         // cause a number of difficulties
  2105         if ( avail_pipeline->instructionCount() == 1 &&
  2132         if ( avail_pipeline->instructionCount() == 1 &&
  2106             !avail_pipeline->hasMultipleBundles() &&
  2133              !avail_pipeline->hasMultipleBundles() &&
  2107             !avail_pipeline->hasBranchDelay() &&
  2134              !avail_pipeline->hasBranchDelay() &&
  2108             Pipeline::instr_has_unit_size() &&
  2135              Pipeline::instr_has_unit_size() &&
  2109             d->size(_regalloc) == Pipeline::instr_unit_size() &&
  2136              d->size(_regalloc) == Pipeline::instr_unit_size() &&
  2110             NodeFitsInBundle(d) &&
  2137              NodeFitsInBundle(d) &&
  2111             !node_bundling(d)->used_in_delay()) {
  2138              !node_bundling(d)->used_in_delay()) {
  2112 
  2139 
  2113           if (d->is_Mach() && !d->is_MachSafePoint()) {
  2140           if (d->is_Mach() && !d->is_MachSafePoint()) {
  2114             // A node that fits in the delay slot was found, so we need to
  2141             // A node that fits in the delay slot was found, so we need to
  2115             // set the appropriate bits in the bundle pipeline information so
  2142             // set the appropriate bits in the bundle pipeline information so
  2116             // that it correctly indicates resource usage.  Later, when we
  2143             // that it correctly indicates resource usage.  Later, when we
  2151 
  2178 
  2152     // See if the instruction in the delay slot requires a
  2179     // See if the instruction in the delay slot requires a
  2153     // step of the bundles
  2180     // step of the bundles
  2154     if (!NodeFitsInBundle(n)) {
  2181     if (!NodeFitsInBundle(n)) {
  2155 #ifndef PRODUCT
  2182 #ifndef PRODUCT
  2156         if (_cfg->C->trace_opto_output())
  2183       if (_cfg->C->trace_opto_output())
  2157           tty->print("#  *** STEP(branch won't fit) ***\n");
  2184         tty->print("#  *** STEP(branch won't fit) ***\n");
  2158 #endif
  2185 #endif
  2159         // Update the state information
  2186       // Update the state information
  2160         _bundle_instr_count = 0;
  2187       _bundle_instr_count = 0;
  2161         _bundle_cycle_number += 1;
  2188       _bundle_cycle_number += 1;
  2162         _bundle_use.step(1);
  2189       _bundle_use.step(1);
  2163     }
  2190     }
  2164   }
  2191   }
  2165 
  2192 
  2166   // Get the number of instructions
  2193   // Get the number of instructions
  2167   uint instruction_count = node_pipeline->instructionCount();
  2194   uint instruction_count = node_pipeline->instructionCount();
  2203 
  2230 
  2204       else if (instruction_count + _bundle_instr_count > Pipeline::_max_instrs_per_cycle) {
  2231       else if (instruction_count + _bundle_instr_count > Pipeline::_max_instrs_per_cycle) {
  2205 #ifndef PRODUCT
  2232 #ifndef PRODUCT
  2206         if (_cfg->C->trace_opto_output())
  2233         if (_cfg->C->trace_opto_output())
  2207           tty->print("#  *** STEP(%d >= %d instructions) ***\n",
  2234           tty->print("#  *** STEP(%d >= %d instructions) ***\n",
  2208             instruction_count + _bundle_instr_count,
  2235                      instruction_count + _bundle_instr_count,
  2209             Pipeline::_max_instrs_per_cycle);
  2236                      Pipeline::_max_instrs_per_cycle);
  2210 #endif
  2237 #endif
  2211         step(1);
  2238         step(1);
  2212       }
  2239       }
  2213     }
  2240     }
  2214 
  2241 
  2410            last->as_Mach()->ideal_Opcode() == Op_Con) {
  2437            last->as_Mach()->ideal_Opcode() == Op_Con) {
  2411       last = bb->get_node(--_bb_end);
  2438       last = bb->get_node(--_bb_end);
  2412     }
  2439     }
  2413     assert(!last->is_Mach() || last->as_Mach()->ideal_Opcode() != Op_Con, "");
  2440     assert(!last->is_Mach() || last->as_Mach()->ideal_Opcode() != Op_Con, "");
  2414     if( last->is_Catch() ||
  2441     if( last->is_Catch() ||
  2415        (last->is_Mach() && last->as_Mach()->ideal_Opcode() == Op_Halt) ) {
  2442         (last->is_Mach() && last->as_Mach()->ideal_Opcode() == Op_Halt) ) {
  2416       // There might be a prior call.  Skip it.
  2443       // There might be a prior call.  Skip it.
  2417       while (_bb_start < _bb_end && bb->get_node(--_bb_end)->is_MachProj());
  2444       while (_bb_start < _bb_end && bb->get_node(--_bb_end)->is_MachProj());
  2418     } else if( last->is_MachNullCheck() ) {
  2445     } else if( last->is_MachNullCheck() ) {
  2419       // Backup so the last null-checked memory instruction is
  2446       // Backup so the last null-checked memory instruction is
  2420       // outside the schedulable range. Skip over the nullcheck,
  2447       // outside the schedulable range. Skip over the nullcheck,
  2480         }
  2507         }
  2481       }
  2508       }
  2482     }
  2509     }
  2483 #endif
  2510 #endif
  2484 #ifdef ASSERT
  2511 #ifdef ASSERT
  2485   verify_good_schedule(bb,"after block local scheduling");
  2512     verify_good_schedule(bb,"after block local scheduling");
  2486 #endif
  2513 #endif
  2487   }
  2514   }
  2488 
  2515 
  2489 #ifndef PRODUCT
  2516 #ifndef PRODUCT
  2490   if (_cfg->C->trace_opto_output())
  2517   if (_cfg->C->trace_opto_output())
  2828 // wired into the graph because the register is never
  2855 // wired into the graph because the register is never
  2829 // used or def'ed in the block.
  2856 // used or def'ed in the block.
  2830 //
  2857 //
  2831 void Scheduling::garbage_collect_pinch_nodes() {
  2858 void Scheduling::garbage_collect_pinch_nodes() {
  2832 #ifndef PRODUCT
  2859 #ifndef PRODUCT
  2833     if (_cfg->C->trace_opto_output()) tty->print("Reclaimed pinch nodes:");
  2860   if (_cfg->C->trace_opto_output()) tty->print("Reclaimed pinch nodes:");
  2834 #endif
  2861 #endif
  2835     int trace_cnt = 0;
  2862   int trace_cnt = 0;
  2836     for (uint k = 0; k < _reg_node.Size(); k++) {
  2863   for (uint k = 0; k < _reg_node.Size(); k++) {
  2837       Node* pinch = _reg_node[k];
  2864     Node* pinch = _reg_node[k];
  2838       if ((pinch != NULL) && pinch->Opcode() == Op_Node &&
  2865     if ((pinch != NULL) && pinch->Opcode() == Op_Node &&
  2839           // no predecence input edges
  2866         // no predecence input edges
  2840           (pinch->req() == pinch->len() || pinch->in(pinch->req()) == NULL) ) {
  2867         (pinch->req() == pinch->len() || pinch->in(pinch->req()) == NULL) ) {
  2841         cleanup_pinch(pinch);
  2868       cleanup_pinch(pinch);
  2842         _pinch_free_list.push(pinch);
  2869       _pinch_free_list.push(pinch);
  2843         _reg_node.map(k, NULL);
  2870       _reg_node.map(k, NULL);
  2844 #ifndef PRODUCT
  2871 #ifndef PRODUCT
  2845         if (_cfg->C->trace_opto_output()) {
  2872       if (_cfg->C->trace_opto_output()) {
  2846           trace_cnt++;
  2873         trace_cnt++;
  2847           if (trace_cnt > 40) {
  2874         if (trace_cnt > 40) {
  2848             tty->print("\n");
  2875           tty->print("\n");
  2849             trace_cnt = 0;
  2876           trace_cnt = 0;
  2850           }
  2877         }
  2851           tty->print(" %d", pinch->_idx);
  2878         tty->print(" %d", pinch->_idx);
  2852         }
  2879       }
  2853 #endif
  2880 #endif
  2854       }
  2881     }
  2855     }
  2882   }
  2856 #ifndef PRODUCT
  2883 #ifndef PRODUCT
  2857     if (_cfg->C->trace_opto_output()) tty->print("\n");
  2884   if (_cfg->C->trace_opto_output()) tty->print("\n");
  2858 #endif
  2885 #endif
  2859 }
  2886 }
  2860 
  2887 
  2861 // Clean up a pinch node for reuse.
  2888 // Clean up a pinch node for reuse.
  2862 void Scheduling::cleanup_pinch( Node *pinch ) {
  2889 void Scheduling::cleanup_pinch( Node *pinch ) {
  2889 
  2916 
  2890 // Print Scheduling Statistics
  2917 // Print Scheduling Statistics
  2891 void Scheduling::print_statistics() {
  2918 void Scheduling::print_statistics() {
  2892   // Print the size added by nops for bundling
  2919   // Print the size added by nops for bundling
  2893   tty->print("Nops added %d bytes to total of %d bytes",
  2920   tty->print("Nops added %d bytes to total of %d bytes",
  2894     _total_nop_size, _total_method_size);
  2921              _total_nop_size, _total_method_size);
  2895   if (_total_method_size > 0)
  2922   if (_total_method_size > 0)
  2896     tty->print(", for %.2f%%",
  2923     tty->print(", for %.2f%%",
  2897       ((double)_total_nop_size) / ((double) _total_method_size) * 100.0);
  2924                ((double)_total_nop_size) / ((double) _total_method_size) * 100.0);
  2898   tty->print("\n");
  2925   tty->print("\n");
  2899 
  2926 
  2900   // Print the number of branch shadows filled
  2927   // Print the number of branch shadows filled
  2901   if (Pipeline::_branch_has_delay_slot) {
  2928   if (Pipeline::_branch_has_delay_slot) {
  2902     tty->print("Of %d branches, %d had unconditional delay slots filled",
  2929     tty->print("Of %d branches, %d had unconditional delay slots filled",
  2903       _total_branches, _total_unconditional_delays);
  2930                _total_branches, _total_unconditional_delays);
  2904     if (_total_branches > 0)
  2931     if (_total_branches > 0)
  2905       tty->print(", for %.2f%%",
  2932       tty->print(", for %.2f%%",
  2906         ((double)_total_unconditional_delays) / ((double)_total_branches) * 100.0);
  2933                  ((double)_total_unconditional_delays) / ((double)_total_branches) * 100.0);
  2907     tty->print("\n");
  2934     tty->print("\n");
  2908   }
  2935   }
  2909 
  2936 
  2910   uint total_instructions = 0, total_bundles = 0;
  2937   uint total_instructions = 0, total_bundles = 0;
  2911 
  2938 
  2915     total_bundles      += bundle_count;
  2942     total_bundles      += bundle_count;
  2916   }
  2943   }
  2917 
  2944 
  2918   if (total_bundles > 0)
  2945   if (total_bundles > 0)
  2919     tty->print("Average ILP (excluding nops) is %.2f\n",
  2946     tty->print("Average ILP (excluding nops) is %.2f\n",
  2920       ((double)total_instructions) / ((double)total_bundles));
  2947                ((double)total_instructions) / ((double)total_bundles));
  2921 }
  2948 }
  2922 #endif
  2949 #endif