< prev index next >

src/share/vm/compiler/methodLiveness.cpp

Print this page
rev 9019 : [mq]: format.patch


  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "ci/ciMethod.hpp"
  27 #include "ci/ciMethodBlocks.hpp"
  28 #include "ci/ciStreams.hpp"
  29 #include "compiler/methodLiveness.hpp"
  30 #include "interpreter/bytecode.hpp"
  31 #include "interpreter/bytecodes.hpp"
  32 #include "memory/allocation.inline.hpp"
  33 #include "utilities/bitMap.inline.hpp"
  34 
  35 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
  36 
  37 // The MethodLiveness class performs a simple liveness analysis on a method
  38 // in order to decide which locals are live (that is, will be used again) at
  39 // a particular bytecode index (bci).
  40 //
  41 // The algorithm goes:
  42 //
  43 // 1. Break the method into a set of basic blocks.  For each basic block we
  44 //    also keep track of its set of predecessors through normal control flow
  45 //    and predecessors through exceptional control flow.
  46 //
  47 // 2. For each basic block, compute two sets, gen (the set of values used before
  48 //    they are defined) and kill (the set of values defined before they are used)
  49 //    in the basic block.  A basic block "needs" the locals in its gen set to
  50 //    perform its computation.  A basic block "provides" values for the locals in
  51 //    its kill set, allowing a need from a successor to be ignored.
  52 //
  53 // 3. Liveness information (the set of locals which are needed) is pushed backwards through
  54 //    the program, from blocks to their predecessors.  We compute and store liveness
  55 //    information for the normal/exceptional exit paths for each basic block.  When
  56 //    this process reaches a fixed point, we are done.


 523 #endif
 524 
 525   return answer;
 526 }
 527 
 528 
 529 #ifndef PRODUCT
 530 
 531 void MethodLiveness::print_times() {
 532   tty->print_cr ("Accumulated liveness analysis times/statistics:");
 533   tty->print_cr ("-----------------------------------------------");
 534   tty->print_cr ("  Total         : %3.3f sec.", _time_total.seconds());
 535   tty->print_cr ("    Build graph : %3.3f sec. (%2.2f%%)", _time_build_graph.seconds(),
 536                  _time_build_graph.seconds() * 100 / _time_total.seconds());
 537   tty->print_cr ("    Gen / Kill  : %3.3f sec. (%2.2f%%)", _time_gen_kill.seconds(),
 538                  _time_gen_kill.seconds() * 100 / _time_total.seconds());
 539   tty->print_cr ("    Dataflow    : %3.3f sec. (%2.2f%%)", _time_flow.seconds(),
 540                  _time_flow.seconds() * 100 / _time_total.seconds());
 541   tty->print_cr ("    Query       : %3.3f sec. (%2.2f%%)", _time_query.seconds(),
 542                  _time_query.seconds() * 100 / _time_total.seconds());
 543   tty->print_cr ("  #bytes   : %8d (%3.0f bytes per sec)",
 544                  _total_bytes,
 545                  _total_bytes / _time_total.seconds());
 546   tty->print_cr ("  #methods : %8d (%3.0f methods per sec)",
 547                  _total_methods,
 548                  _total_methods / _time_total.seconds());
 549   tty->print_cr ("    avg locals : %3.3f    max locals : %3d",
 550                  (float)_total_method_locals / _total_methods,
 551                  _max_method_locals);
 552   tty->print_cr ("    avg blocks : %3.3f    max blocks : %3d",
 553                  (float)_total_blocks / _total_methods,
 554                  _max_method_blocks);
 555   tty->print_cr ("    avg bytes  : %3.3f",
 556                  (float)_total_bytes / _total_methods);
 557   tty->print_cr ("  #blocks  : %8d",
 558                  _total_blocks);
 559   tty->print_cr ("    avg normal predecessors    : %3.3f  max normal predecessors    : %3d",
 560                  (float)_total_edges / _total_blocks,
 561                  _max_block_edges);
 562   tty->print_cr ("    avg exception predecessors : %3.3f  max exception predecessors : %3d",
 563                  (float)_total_exc_edges / _total_blocks,
 564                  _max_block_exc_edges);
 565   tty->print_cr ("    avg visits                 : %3.3f",
 566                  (float)_total_visits / _total_blocks);
 567   tty->print_cr ("  #locals queried : %8d    #live : %8d   %%live : %2.2f%%",
 568                  _total_locals_queried,
 569                  _total_live_locals_queried,
 570                  100.0 * _total_live_locals_queried / _total_locals_queried);
 571 }
 572 
 573 #endif
 574 
 575 
 576 MethodLiveness::BasicBlock::BasicBlock(MethodLiveness *analyzer, int start, int limit) :
 577          _gen((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
 578                          analyzer->bit_map_size_bits()),
 579          _kill((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
 580                          analyzer->bit_map_size_bits()),
 581          _entry((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
 582                          analyzer->bit_map_size_bits()),
 583          _normal_exit((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
 584                          analyzer->bit_map_size_bits()),
 585          _exception_exit((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
 586                          analyzer->bit_map_size_bits()),
 587          _last_bci(-1) {




  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "ci/ciMethod.hpp"
  27 #include "ci/ciMethodBlocks.hpp"
  28 #include "ci/ciStreams.hpp"
  29 #include "compiler/methodLiveness.hpp"
  30 #include "interpreter/bytecode.hpp"
  31 #include "interpreter/bytecodes.hpp"
  32 #include "memory/allocation.inline.hpp"
  33 #include "utilities/bitMap.inline.hpp"
  34 


  35 // The MethodLiveness class performs a simple liveness analysis on a method
  36 // in order to decide which locals are live (that is, will be used again) at
  37 // a particular bytecode index (bci).
  38 //
  39 // The algorithm goes:
  40 //
  41 // 1. Break the method into a set of basic blocks.  For each basic block we
  42 //    also keep track of its set of predecessors through normal control flow
  43 //    and predecessors through exceptional control flow.
  44 //
  45 // 2. For each basic block, compute two sets, gen (the set of values used before
  46 //    they are defined) and kill (the set of values defined before they are used)
  47 //    in the basic block.  A basic block "needs" the locals in its gen set to
  48 //    perform its computation.  A basic block "provides" values for the locals in
  49 //    its kill set, allowing a need from a successor to be ignored.
  50 //
  51 // 3. Liveness information (the set of locals which are needed) is pushed backwards through
  52 //    the program, from blocks to their predecessors.  We compute and store liveness
  53 //    information for the normal/exceptional exit paths for each basic block.  When
  54 //    this process reaches a fixed point, we are done.


 521 #endif
 522 
 523   return answer;
 524 }
 525 
 526 
 527 #ifndef PRODUCT
 528 
 529 void MethodLiveness::print_times() {
 530   tty->print_cr ("Accumulated liveness analysis times/statistics:");
 531   tty->print_cr ("-----------------------------------------------");
 532   tty->print_cr ("  Total         : %3.3f sec.", _time_total.seconds());
 533   tty->print_cr ("    Build graph : %3.3f sec. (%2.2f%%)", _time_build_graph.seconds(),
 534                  _time_build_graph.seconds() * 100 / _time_total.seconds());
 535   tty->print_cr ("    Gen / Kill  : %3.3f sec. (%2.2f%%)", _time_gen_kill.seconds(),
 536                  _time_gen_kill.seconds() * 100 / _time_total.seconds());
 537   tty->print_cr ("    Dataflow    : %3.3f sec. (%2.2f%%)", _time_flow.seconds(),
 538                  _time_flow.seconds() * 100 / _time_total.seconds());
 539   tty->print_cr ("    Query       : %3.3f sec. (%2.2f%%)", _time_query.seconds(),
 540                  _time_query.seconds() * 100 / _time_total.seconds());
 541   tty->print_cr ("  #bytes   : %8ld (%3.0f bytes per sec)",
 542                  _total_bytes,
 543                  _total_bytes / _time_total.seconds());
 544   tty->print_cr ("  #methods : %8d (%3.0f methods per sec)",
 545                  _total_methods,
 546                  _total_methods / _time_total.seconds());
 547   tty->print_cr ("    avg locals : %3.3f    max locals : %3d",
 548                  (float)_total_method_locals / _total_methods,
 549                  _max_method_locals);
 550   tty->print_cr ("    avg blocks : %3.3f    max blocks : %3d",
 551                  (float)_total_blocks / _total_methods,
 552                  _max_method_blocks);
 553   tty->print_cr ("    avg bytes  : %3.3f",
 554                  (float)_total_bytes / _total_methods);
 555   tty->print_cr ("  #blocks  : %8ld",
 556                  _total_blocks);
 557   tty->print_cr ("    avg normal predecessors    : %3.3f  max normal predecessors    : %3d",
 558                  (float)_total_edges / _total_blocks,
 559                  _max_block_edges);
 560   tty->print_cr ("    avg exception predecessors : %3.3f  max exception predecessors : %3d",
 561                  (float)_total_exc_edges / _total_blocks,
 562                  _max_block_exc_edges);
 563   tty->print_cr ("    avg visits                 : %3.3f",
 564                  (float)_total_visits / _total_blocks);
 565   tty->print_cr ("  #locals queried : %8ld    #live : %8ld   %%live : %2.2f%%",
 566                  _total_locals_queried,
 567                  _total_live_locals_queried,
 568                  100.0 * _total_live_locals_queried / _total_locals_queried);
 569 }
 570 
 571 #endif
 572 
 573 
 574 MethodLiveness::BasicBlock::BasicBlock(MethodLiveness *analyzer, int start, int limit) :
 575          _gen((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
 576                          analyzer->bit_map_size_bits()),
 577          _kill((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
 578                          analyzer->bit_map_size_bits()),
 579          _entry((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
 580                          analyzer->bit_map_size_bits()),
 581          _normal_exit((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
 582                          analyzer->bit_map_size_bits()),
 583          _exception_exit((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
 584                          analyzer->bit_map_size_bits()),
 585          _last_bci(-1) {


< prev index next >