src/share/vm/memory/sharedHeap.hpp

changeset 6992
2c6ef90f030a
parent 6978
30c99d8e0f02
child 7535
7ae4e26cb1e0
child 7659
38d6febe66af
     1.1 --- a/src/share/vm/memory/sharedHeap.hpp	Tue Jul 01 09:03:55 2014 +0200
     1.2 +++ b/src/share/vm/memory/sharedHeap.hpp	Mon Jul 07 10:12:40 2014 +0200
     1.3 @@ -69,14 +69,10 @@
     1.4  //    number of active GC workers.  CompactibleFreeListSpace and Space
     1.5  //    have SequentialSubTasksDone's.
     1.6  // Example of using SubTasksDone and SequentialSubTasksDone
     1.7 -// G1CollectedHeap::g1_process_strong_roots() calls
     1.8 -//  process_strong_roots(false, // no scoping; this is parallel code
     1.9 -//                       is_scavenging, so,
    1.10 -//                       &buf_scan_non_heap_roots,
    1.11 -//                       &eager_scan_code_roots);
    1.12 -//  which delegates to SharedHeap::process_strong_roots() and uses
    1.13 +// G1CollectedHeap::g1_process_roots()
    1.14 +//  to SharedHeap::process_roots() and uses
    1.15  //  SubTasksDone* _process_strong_tasks to claim tasks.
    1.16 -//  process_strong_roots() calls
    1.17 +//  process_roots() calls
    1.18  //      rem_set()->younger_refs_iterate()
    1.19  //  to scan the card table and which eventually calls down into
    1.20  //  CardTableModRefBS::par_non_clean_card_iterate_work().  This method
    1.21 @@ -182,12 +178,12 @@
    1.22    // task.  (This also means that a parallel thread may only call
    1.23    // process_strong_roots once.)
    1.24    //
    1.25 -  // For calls to process_strong_roots by sequential code, the parity is
    1.26 +  // For calls to process_roots by sequential code, the parity is
    1.27    // updated automatically.
    1.28    //
    1.29    // The idea is that objects representing fine-grained tasks, such as
    1.30    // threads, will contain a "parity" field.  A task will is claimed in the
    1.31 -  // current "process_strong_roots" call only if its parity field is the
    1.32 +  // current "process_roots" call only if its parity field is the
    1.33    // same as the "strong_roots_parity"; task claiming is accomplished by
    1.34    // updating the parity field to the strong_roots_parity with a CAS.
    1.35    //
    1.36 @@ -198,27 +194,44 @@
    1.37    //   c) to never return a distinguished value (zero) with which such
    1.38    //      task-claiming variables may be initialized, to indicate "never
    1.39    //      claimed".
    1.40 - private:
    1.41 -  void change_strong_roots_parity();
    1.42   public:
    1.43    int strong_roots_parity() { return _strong_roots_parity; }
    1.44  
    1.45 -  // Call these in sequential code around process_strong_roots.
    1.46 +  // Call these in sequential code around process_roots.
    1.47    // strong_roots_prologue calls change_strong_roots_parity, if
    1.48    // parallel tasks are enabled.
    1.49    class StrongRootsScope : public MarkingCodeBlobClosure::MarkScope {
    1.50 -  public:
    1.51 -    StrongRootsScope(SharedHeap* outer, bool activate = true);
    1.52 +    // Used to implement the Thread work barrier.
    1.53 +    static Monitor* _lock;
    1.54 +
    1.55 +    SharedHeap*   _sh;
    1.56 +    volatile jint _n_workers_done_with_threads;
    1.57 +
    1.58 +   public:
    1.59 +    StrongRootsScope(SharedHeap* heap, bool activate = true);
    1.60      ~StrongRootsScope();
    1.61 +
    1.62 +    // Mark that this thread is done with the Threads work.
    1.63 +    void mark_worker_done_with_threads(uint n_workers);
    1.64 +    // Wait until all n_workers are done with the Threads work.
    1.65 +    void wait_until_all_workers_done_with_threads(uint n_workers);
    1.66    };
    1.67    friend class StrongRootsScope;
    1.68  
    1.69 +  // The current active StrongRootScope
    1.70 +  StrongRootsScope* _strong_roots_scope;
    1.71 +
    1.72 +  StrongRootsScope* active_strong_roots_scope() const;
    1.73 +
    1.74 + private:
    1.75 +  void register_strong_roots_scope(StrongRootsScope* scope);
    1.76 +  void unregister_strong_roots_scope(StrongRootsScope* scope);
    1.77 +  void change_strong_roots_parity();
    1.78 +
    1.79 + public:
    1.80    enum ScanningOption {
    1.81 -    SO_None                = 0x0,
    1.82 -    SO_AllClasses          = 0x1,
    1.83 -    SO_SystemClasses       = 0x2,
    1.84 -    SO_Strings             = 0x4,
    1.85 -    SO_AllCodeCache        = 0x8,
    1.86 +    SO_None                =  0x0,
    1.87 +    SO_AllCodeCache        =  0x8,
    1.88      SO_ScavengeCodeCache   = 0x10
    1.89    };
    1.90  
    1.91 @@ -227,15 +240,26 @@
    1.92    // Invoke the "do_oop" method the closure "roots" on all root locations.
    1.93    // The "so" argument determines which roots the closure is applied to:
    1.94    // "SO_None" does none;
    1.95 -  // "SO_AllClasses" applies the closure to all entries in the SystemDictionary;
    1.96 -  // "SO_SystemClasses" to all the "system" classes and loaders;
    1.97 -  // "SO_Strings" applies the closure to all entries in StringTable;
    1.98    // "SO_AllCodeCache" applies the closure to all elements of the CodeCache.
    1.99    // "SO_ScavengeCodeCache" applies the closure to elements on the scavenge root list in the CodeCache.
   1.100 +  void process_roots(bool activate_scope,
   1.101 +                     ScanningOption so,
   1.102 +                     OopClosure* strong_roots,
   1.103 +                     OopClosure* weak_roots,
   1.104 +                     CLDClosure* strong_cld_closure,
   1.105 +                     CLDClosure* weak_cld_closure,
   1.106 +                     CodeBlobClosure* code_roots);
   1.107 +  void process_all_roots(bool activate_scope,
   1.108 +                         ScanningOption so,
   1.109 +                         OopClosure* roots,
   1.110 +                         CLDClosure* cld_closure,
   1.111 +                         CodeBlobClosure* code_roots);
   1.112    void process_strong_roots(bool activate_scope,
   1.113                              ScanningOption so,
   1.114                              OopClosure* roots,
   1.115 -                            KlassClosure* klass_closure);
   1.116 +                            CLDClosure* cld_closure,
   1.117 +                            CodeBlobClosure* code_roots);
   1.118 +
   1.119  
   1.120    // Apply "root_closure" to the JNI weak roots..
   1.121    void process_weak_roots(OopClosure* root_closure);
   1.122 @@ -251,7 +275,7 @@
   1.123    virtual void gc_epilogue(bool full) = 0;
   1.124  
   1.125    // Sets the number of parallel threads that will be doing tasks
   1.126 -  // (such as process strong roots) subsequently.
   1.127 +  // (such as process roots) subsequently.
   1.128    virtual void set_par_threads(uint t);
   1.129  
   1.130    int n_termination();

mercurial