hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp
changeset 46505 fd4bc78630b1
parent 46457 641e73c3832a
child 46519 40c9c132f961
equal deleted inserted replaced
46504:38048d4d20e7 46505:fd4bc78630b1
    72 #include "logging/log.hpp"
    72 #include "logging/log.hpp"
    73 #include "memory/allocation.hpp"
    73 #include "memory/allocation.hpp"
    74 #include "memory/iterator.hpp"
    74 #include "memory/iterator.hpp"
    75 #include "memory/resourceArea.hpp"
    75 #include "memory/resourceArea.hpp"
    76 #include "oops/oop.inline.hpp"
    76 #include "oops/oop.inline.hpp"
       
    77 #include "prims/resolvedMethodTable.hpp"
    77 #include "runtime/atomic.hpp"
    78 #include "runtime/atomic.hpp"
    78 #include "runtime/init.hpp"
    79 #include "runtime/init.hpp"
    79 #include "runtime/orderAccess.inline.hpp"
    80 #include "runtime/orderAccess.inline.hpp"
    80 #include "runtime/vmThread.hpp"
    81 #include "runtime/vmThread.hpp"
    81 #include "utilities/globalDefinitions.hpp"
    82 #include "utilities/globalDefinitions.hpp"
  3841       clean_klass(klass);
  3842       clean_klass(klass);
  3842     }
  3843     }
  3843   }
  3844   }
  3844 };
  3845 };
  3845 
  3846 
       
  3847 class G1ResolvedMethodCleaningTask : public StackObj {
       
  3848   BoolObjectClosure* _is_alive;
       
  3849   volatile jint      _resolved_method_task_claimed;
       
  3850 public:
       
  3851   G1ResolvedMethodCleaningTask(BoolObjectClosure* is_alive) :
       
  3852       _is_alive(is_alive), _resolved_method_task_claimed(0) {}
       
  3853 
       
  3854   bool claim_resolved_method_task() {
       
  3855     if (_resolved_method_task_claimed) {
       
  3856       return false;
       
  3857     }
       
  3858     return Atomic::cmpxchg(1, (jint*)&_resolved_method_task_claimed, 0) == 0;
       
  3859   }
       
  3860 
       
  3861   // These aren't big, one thread can do it all.
       
  3862   void work() {
       
  3863     if (claim_resolved_method_task()) {
       
  3864       ResolvedMethodTable::unlink(_is_alive);
       
  3865     }
       
  3866   }
       
  3867 };
       
  3868 
       
  3869 
  3846 // To minimize the remark pause times, the tasks below are done in parallel.
  3870 // To minimize the remark pause times, the tasks below are done in parallel.
  3847 class G1ParallelCleaningTask : public AbstractGangTask {
  3871 class G1ParallelCleaningTask : public AbstractGangTask {
  3848 private:
  3872 private:
  3849   G1StringAndSymbolCleaningTask _string_symbol_task;
  3873   G1StringAndSymbolCleaningTask _string_symbol_task;
  3850   G1CodeCacheUnloadingTask      _code_cache_task;
  3874   G1CodeCacheUnloadingTask      _code_cache_task;
  3851   G1KlassCleaningTask           _klass_cleaning_task;
  3875   G1KlassCleaningTask           _klass_cleaning_task;
       
  3876   G1ResolvedMethodCleaningTask  _resolved_method_cleaning_task;
  3852 
  3877 
  3853 public:
  3878 public:
  3854   // The constructor is run in the VMThread.
  3879   // The constructor is run in the VMThread.
  3855   G1ParallelCleaningTask(BoolObjectClosure* is_alive, uint num_workers, bool unloading_occurred) :
  3880   G1ParallelCleaningTask(BoolObjectClosure* is_alive, uint num_workers, bool unloading_occurred) :
  3856       AbstractGangTask("Parallel Cleaning"),
  3881       AbstractGangTask("Parallel Cleaning"),
  3857       _string_symbol_task(is_alive, true, true, G1StringDedup::is_enabled()),
  3882       _string_symbol_task(is_alive, true, true, G1StringDedup::is_enabled()),
  3858       _code_cache_task(num_workers, is_alive, unloading_occurred),
  3883       _code_cache_task(num_workers, is_alive, unloading_occurred),
  3859       _klass_cleaning_task(is_alive) {
  3884       _klass_cleaning_task(is_alive),
       
  3885       _resolved_method_cleaning_task(is_alive) {
  3860   }
  3886   }
  3861 
  3887 
  3862   // The parallel work done by all worker threads.
  3888   // The parallel work done by all worker threads.
  3863   void work(uint worker_id) {
  3889   void work(uint worker_id) {
  3864     // Do first pass of code cache cleaning.
  3890     // Do first pass of code cache cleaning.
  3867     // Let the threads mark that the first pass is done.
  3893     // Let the threads mark that the first pass is done.
  3868     _code_cache_task.barrier_mark(worker_id);
  3894     _code_cache_task.barrier_mark(worker_id);
  3869 
  3895 
  3870     // Clean the Strings and Symbols.
  3896     // Clean the Strings and Symbols.
  3871     _string_symbol_task.work(worker_id);
  3897     _string_symbol_task.work(worker_id);
       
  3898 
       
  3899     // Clean unreferenced things in the ResolvedMethodTable
       
  3900     _resolved_method_cleaning_task.work();
  3872 
  3901 
  3873     // Wait for all workers to finish the first code cache cleaning pass.
  3902     // Wait for all workers to finish the first code cache cleaning pass.
  3874     _code_cache_task.barrier_wait(worker_id);
  3903     _code_cache_task.barrier_wait(worker_id);
  3875 
  3904 
  3876     // Do the second code cache cleaning work, which realize on
  3905     // Do the second code cache cleaning work, which realize on