hotspot/src/share/vm/compiler/methodLiveness.cpp
changeset 38177 b0c9cb06506b
parent 37248 11a660dbbb8e
child 39219 1b33aa56ed18
equal deleted inserted replaced
38175:4e2bff1a5467 38177:b0c9cb06506b
   129 elapsedTimer MethodLiveness::_time_query;
   129 elapsedTimer MethodLiveness::_time_query;
   130 elapsedTimer MethodLiveness::_time_total;
   130 elapsedTimer MethodLiveness::_time_total;
   131 
   131 
   132 MethodLiveness::MethodLiveness(Arena* arena, ciMethod* method)
   132 MethodLiveness::MethodLiveness(Arena* arena, ciMethod* method)
   133 #ifdef COMPILER1
   133 #ifdef COMPILER1
   134   : _bci_block_start((uintptr_t*)arena->Amalloc((method->code_size() >> LogBitsPerByte) + 1), method->code_size())
   134   : _bci_block_start(arena, method->code_size())
   135 #endif
   135 #endif
   136 {
   136 {
   137   _arena = arena;
   137   _arena = arena;
   138   _method = method;
   138   _method = method;
   139   _bit_map_size_bits = method->max_locals();
   139   _bit_map_size_bits = method->max_locals();
   140   _bit_map_size_words = (_bit_map_size_bits / sizeof(unsigned int)) + 1;
   140 
   141 
   141 
   142 #ifdef COMPILER1
   142 #ifdef COMPILER1
   143   _bci_block_start.clear();
   143   _bci_block_start.clear();
   144 #endif
   144 #endif
   145 }
   145 }
   473   if (entry_bci == InvocationEntryBci) {
   473   if (entry_bci == InvocationEntryBci) {
   474     is_entry = true;
   474     is_entry = true;
   475     bci = 0;
   475     bci = 0;
   476   }
   476   }
   477 
   477 
   478   MethodLivenessResult answer((BitMap::bm_word_t*)NULL,0);
   478   MethodLivenessResult answer;
   479 
   479 
   480   if (_block_count > 0) {
   480   if (_block_count > 0) {
   481     if (TimeLivenessAnalysis) _time_total.start();
   481     if (TimeLivenessAnalysis) _time_total.start();
   482     if (TimeLivenessAnalysis) _time_query.start();
   482     if (TimeLivenessAnalysis) _time_query.start();
   483 
   483 
   572 
   572 
   573 #endif
   573 #endif
   574 
   574 
   575 
   575 
   576 MethodLiveness::BasicBlock::BasicBlock(MethodLiveness *analyzer, int start, int limit) :
   576 MethodLiveness::BasicBlock::BasicBlock(MethodLiveness *analyzer, int start, int limit) :
   577          _gen((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
   577          _gen(analyzer->arena(),            analyzer->bit_map_size_bits()),
   578                          analyzer->bit_map_size_bits()),
   578          _kill(analyzer->arena(),           analyzer->bit_map_size_bits()),
   579          _kill((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
   579          _entry(analyzer->arena(),          analyzer->bit_map_size_bits()),
   580                          analyzer->bit_map_size_bits()),
   580          _normal_exit(analyzer->arena(),    analyzer->bit_map_size_bits()),
   581          _entry((uintptr_t*)analyzer->arena()->Amalloc(BytesPerWord * analyzer->bit_map_size_words()),
   581          _exception_exit(analyzer->arena(), analyzer->bit_map_size_bits()),
   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) {
   582          _last_bci(-1) {
   588   _analyzer = analyzer;
   583   _analyzer = analyzer;
   589   _start_bci = start;
   584   _start_bci = start;
   590   _limit_bci = limit;
   585   _limit_bci = limit;
   591   _normal_predecessors =
   586   _normal_predecessors =
   989       ml->work_list_add(block);
   984       ml->work_list_add(block);
   990     }
   985     }
   991   }
   986   }
   992 }
   987 }
   993 
   988 
   994 bool MethodLiveness::BasicBlock::merge_normal(BitMap other) {
   989 bool MethodLiveness::BasicBlock::merge_normal(const BitMap& other) {
   995   return _normal_exit.set_union_with_result(other);
   990   return _normal_exit.set_union_with_result(other);
   996 }
   991 }
   997 
   992 
   998 bool MethodLiveness::BasicBlock::merge_exception(BitMap other) {
   993 bool MethodLiveness::BasicBlock::merge_exception(const BitMap& other) {
   999   return _exception_exit.set_union_with_result(other);
   994   return _exception_exit.set_union_with_result(other);
  1000 }
   995 }
  1001 
   996 
  1002 MethodLivenessResult MethodLiveness::BasicBlock::get_liveness_at(ciMethod* method, int bci) {
   997 MethodLivenessResult MethodLiveness::BasicBlock::get_liveness_at(ciMethod* method, int bci) {
  1003   MethodLivenessResult answer(NEW_RESOURCE_ARRAY(BitMap::bm_word_t, _analyzer->bit_map_size_words()),
   998   MethodLivenessResult answer(_analyzer->bit_map_size_bits());
  1004                 _analyzer->bit_map_size_bits());
       
  1005   answer.set_is_valid();
   999   answer.set_is_valid();
  1006 
  1000 
  1007 #ifndef ASSERT
  1001 #ifndef ASSERT
  1008   if (bci == start_bci()) {
  1002   if (bci == start_bci()) {
  1009     answer.set_from(_entry);
  1003     answer.set_from(_entry);
  1011   }
  1005   }
  1012 #endif
  1006 #endif
  1013 
  1007 
  1014 #ifdef ASSERT
  1008 #ifdef ASSERT
  1015   ResourceMark rm;
  1009   ResourceMark rm;
  1016   BitMap g(_gen.size()); g.set_from(_gen);
  1010   ResourceBitMap g(_gen.size()); g.set_from(_gen);
  1017   BitMap k(_kill.size()); k.set_from(_kill);
  1011   ResourceBitMap k(_kill.size()); k.set_from(_kill);
  1018 #endif
  1012 #endif
  1019   if (_last_bci != bci || trueInDebug) {
  1013   if (_last_bci != bci || trueInDebug) {
  1020     ciBytecodeStream bytes(method);
  1014     ciBytecodeStream bytes(method);
  1021     bytes.reset_to_bci(bci);
  1015     bytes.reset_to_bci(bci);
  1022     bytes.set_max_bci(limit_bci());
  1016     bytes.set_max_bci(limit_bci());