src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp

Print this page
rev 4939 : 8033443: Test8000311 fails after latest changes to parallelize string and symbol table unlink
 Summary: When string and symbol table unlink are not performed in parallel, the claim index we check is not updated, and so a guarantee fails. Take this into account when checking the guarantee.
 Reviewed-by: brutisso, jwilhelm


5186 void
5187 G1CollectedHeap::g1_process_weak_roots(OopClosure* root_closure,
5188                                        OopClosure* non_root_closure) {
5189   CodeBlobToOopClosure roots_in_blobs(root_closure, /*do_marking=*/ false);
5190   SharedHeap::process_weak_roots(root_closure, &roots_in_blobs, non_root_closure);
5191 }
5192 
5193 class G1StringSymbolTableUnlinkTask : public AbstractGangTask {
5194 private:
5195   BoolObjectClosure* _is_alive;
5196   int _initial_string_table_size;
5197   int _initial_symbol_table_size;
5198 
5199   bool  _process_strings;
5200   int _strings_processed;
5201   int _strings_removed;
5202 
5203   bool  _process_symbols;
5204   int _symbols_processed;
5205   int _symbols_removed;


5206 public:
5207   G1StringSymbolTableUnlinkTask(BoolObjectClosure* is_alive, bool process_strings, bool process_symbols) :
5208     AbstractGangTask("Par String/Symbol table unlink"), _is_alive(is_alive),

5209     _process_strings(process_strings), _strings_processed(0), _strings_removed(0),
5210     _process_symbols(process_symbols), _symbols_processed(0), _symbols_removed(0) {
5211 
5212     _initial_string_table_size = StringTable::the_table()->table_size();
5213     _initial_symbol_table_size = SymbolTable::the_table()->table_size();
5214     if (process_strings) {
5215       StringTable::clear_parallel_claimed_index();
5216     }
5217     if (process_symbols) {
5218       SymbolTable::clear_parallel_claimed_index();
5219     }
5220   }
5221 
5222   ~G1StringSymbolTableUnlinkTask() {
5223     guarantee(!_process_strings || StringTable::parallel_claimed_index() >= _initial_string_table_size,
5224               err_msg("claim value "INT32_FORMAT" after unlink less than initial string table size "INT32_FORMAT,
5225                       StringTable::parallel_claimed_index(), _initial_string_table_size));
5226     guarantee(!_process_symbols || SymbolTable::parallel_claimed_index() >= _initial_symbol_table_size,
5227               err_msg("claim value "INT32_FORMAT" after unlink less than initial symbol table size "INT32_FORMAT,
5228                       SymbolTable::parallel_claimed_index(), _initial_symbol_table_size));
5229 
5230   }
5231 
5232   void work(uint worker_id) {
5233     if (G1CollectedHeap::use_parallel_gc_threads()) {
5234       int strings_processed = 0;
5235       int strings_removed = 0;
5236       int symbols_processed = 0;
5237       int symbols_removed = 0;
5238       if (_process_strings) {
5239         StringTable::possibly_parallel_unlink(_is_alive, &strings_processed, &strings_removed);
5240         Atomic::add(strings_processed, &_strings_processed);
5241         Atomic::add(strings_removed, &_strings_removed);
5242       }
5243       if (_process_symbols) {
5244         SymbolTable::possibly_parallel_unlink(&symbols_processed, &symbols_removed);
5245         Atomic::add(symbols_processed, &_symbols_processed);
5246         Atomic::add(symbols_removed, &_symbols_removed);
5247       }
5248     } else {
5249       if (_process_strings) {
5250         StringTable::unlink(_is_alive, &_strings_processed, &_strings_removed);
5251       }
5252       if (_process_symbols) {
5253         SymbolTable::unlink(&_symbols_processed, &_symbols_removed);




5186 void
5187 G1CollectedHeap::g1_process_weak_roots(OopClosure* root_closure,
5188                                        OopClosure* non_root_closure) {
5189   CodeBlobToOopClosure roots_in_blobs(root_closure, /*do_marking=*/ false);
5190   SharedHeap::process_weak_roots(root_closure, &roots_in_blobs, non_root_closure);
5191 }
5192 
5193 class G1StringSymbolTableUnlinkTask : public AbstractGangTask {
5194 private:
5195   BoolObjectClosure* _is_alive;
5196   int _initial_string_table_size;
5197   int _initial_symbol_table_size;
5198 
5199   bool  _process_strings;
5200   int _strings_processed;
5201   int _strings_removed;
5202 
5203   bool  _process_symbols;
5204   int _symbols_processed;
5205   int _symbols_removed;
5206 
5207   bool _do_in_parallel;
5208 public:
5209   G1StringSymbolTableUnlinkTask(BoolObjectClosure* is_alive, bool process_strings, bool process_symbols) :
5210     AbstractGangTask("Par String/Symbol table unlink"), _is_alive(is_alive),
5211     _do_in_parallel(G1CollectedHeap::use_parallel_gc_threads()),
5212     _process_strings(process_strings), _strings_processed(0), _strings_removed(0),
5213     _process_symbols(process_symbols), _symbols_processed(0), _symbols_removed(0) {
5214 
5215     _initial_string_table_size = StringTable::the_table()->table_size();
5216     _initial_symbol_table_size = SymbolTable::the_table()->table_size();
5217     if (process_strings) {
5218       StringTable::clear_parallel_claimed_index();
5219     }
5220     if (process_symbols) {
5221       SymbolTable::clear_parallel_claimed_index();
5222     }
5223   }
5224 
5225   ~G1StringSymbolTableUnlinkTask() {
5226     guarantee(!_process_strings || !_do_in_parallel || StringTable::parallel_claimed_index() >= _initial_string_table_size,
5227               err_msg("claim value "INT32_FORMAT" after unlink less than initial string table size "INT32_FORMAT,
5228                       StringTable::parallel_claimed_index(), _initial_string_table_size));
5229     guarantee(!_process_symbols || !_do_in_parallel || SymbolTable::parallel_claimed_index() >= _initial_symbol_table_size,
5230               err_msg("claim value "INT32_FORMAT" after unlink less than initial symbol table size "INT32_FORMAT,
5231                       SymbolTable::parallel_claimed_index(), _initial_symbol_table_size));

5232   }
5233 
5234   void work(uint worker_id) {
5235     if (_do_in_parallel) {
5236       int strings_processed = 0;
5237       int strings_removed = 0;
5238       int symbols_processed = 0;
5239       int symbols_removed = 0;
5240       if (_process_strings) {
5241         StringTable::possibly_parallel_unlink(_is_alive, &strings_processed, &strings_removed);
5242         Atomic::add(strings_processed, &_strings_processed);
5243         Atomic::add(strings_removed, &_strings_removed);
5244       }
5245       if (_process_symbols) {
5246         SymbolTable::possibly_parallel_unlink(&symbols_processed, &symbols_removed);
5247         Atomic::add(symbols_processed, &_symbols_processed);
5248         Atomic::add(symbols_removed, &_symbols_removed);
5249       }
5250     } else {
5251       if (_process_strings) {
5252         StringTable::unlink(_is_alive, &_strings_processed, &_strings_removed);
5253       }
5254       if (_process_symbols) {
5255         SymbolTable::unlink(&_symbols_processed, &_symbols_removed);