< prev index next >

src/share/vm/memory/sharedHeap.hpp

Print this page
rev 7854 : imported patch 8027962-per-phase-timing-measurements-for-strong-roots-processing
rev 7855 : [mq]: 8027962-bengt-suggestions
   1 /*
   2  * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  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  *


  86 //  to a value > 1 before a task that you would like executed in parallel
  87 //  and then to set it to 0 after that task has completed.  A value of
  88 //  0 is a "special" value in set_n_threads() which translates to
  89 //  setting _n_threads to 1.
  90 //
  91 //  Some code uses _n_termination to decide if work should be done in
  92 //  parallel.  The notorious possibly_parallel_oops_do() in threads.cpp
  93 //  is an example of such code.  Look for variable "is_par" for other
  94 //  examples.
  95 //
  96 //  The active_workers is not reset to 0 after a parallel phase.  It's
  97 //  value may be used in later phases and in one instance at least
  98 //  (the parallel remark) it has to be used (the parallel remark depends
  99 //  on the partitioning done in the previous parallel scavenge).
 100 
 101 class SharedHeap : public CollectedHeap {
 102   friend class VMStructs;
 103 
 104   friend class VM_GC_Operation;
 105   friend class VM_CGC_Operation;

















 106 

 107 private:
 108   // For claiming strong_roots tasks.
 109   SubTasksDone* _process_strong_tasks;
 110 
 111 protected:
 112   // There should be only a single instance of "SharedHeap" in a program.
 113   // This is enforced with the protected constructor below, which will also
 114   // set the static pointer "_sh" to that instance.
 115   static SharedHeap* _sh;
 116 
 117   // A gc policy, controls global gc resource issues
 118   CollectorPolicy *_collector_policy;
 119 
 120   // See the discussion below, in the specification of the reader function
 121   // for this variable.
 122   int _strong_roots_parity;
 123 
 124   // If we're doing parallel GC, use this gang of threads.
 125   FlexibleWorkGang* _workers;
 126 


 223  public:
 224   enum ScanningOption {
 225     SO_None                =  0x0,
 226     SO_AllCodeCache        =  0x8,
 227     SO_ScavengeCodeCache   = 0x10
 228   };
 229 
 230   FlexibleWorkGang* workers() const { return _workers; }
 231 
 232   // Invoke the "do_oop" method the closure "roots" on all root locations.
 233   // The "so" argument determines which roots the closure is applied to:
 234   // "SO_None" does none;
 235   // "SO_AllCodeCache" applies the closure to all elements of the CodeCache.
 236   // "SO_ScavengeCodeCache" applies the closure to elements on the scavenge root list in the CodeCache.
 237   void process_roots(bool activate_scope,
 238                      ScanningOption so,
 239                      OopClosure* strong_roots,
 240                      OopClosure* weak_roots,
 241                      CLDClosure* strong_cld_closure,
 242                      CLDClosure* weak_cld_closure,
 243                      CodeBlobClosure* code_roots);

 244   void process_all_roots(bool activate_scope,
 245                          ScanningOption so,
 246                          OopClosure* roots,
 247                          CLDClosure* cld_closure,
 248                          CodeBlobClosure* code_roots);

 249   void process_strong_roots(bool activate_scope,
 250                             ScanningOption so,
 251                             OopClosure* roots,
 252                             CLDClosure* cld_closure,
 253                             CodeBlobClosure* code_roots);

 254 
 255 
 256   // Apply "root_closure" to the JNI weak roots..
 257   void process_weak_roots(OopClosure* root_closure);
 258 
 259   // The functions below are helper functions that a subclass of
 260   // "SharedHeap" can use in the implementation of its virtual
 261   // functions.
 262 
 263 public:
 264 
 265   // Do anything common to GC's.
 266   virtual void gc_prologue(bool full) = 0;
 267   virtual void gc_epilogue(bool full) = 0;
 268 
 269   // Sets the number of parallel threads that will be doing tasks
 270   // (such as process roots) subsequently.
 271   virtual void set_par_threads(uint t);
 272 
 273   int n_termination();
   1 /*
   2  * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  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  *


  86 //  to a value > 1 before a task that you would like executed in parallel
  87 //  and then to set it to 0 after that task has completed.  A value of
  88 //  0 is a "special" value in set_n_threads() which translates to
  89 //  setting _n_threads to 1.
  90 //
  91 //  Some code uses _n_termination to decide if work should be done in
  92 //  parallel.  The notorious possibly_parallel_oops_do() in threads.cpp
  93 //  is an example of such code.  Look for variable "is_par" for other
  94 //  examples.
  95 //
  96 //  The active_workers is not reset to 0 after a parallel phase.  It's
  97 //  value may be used in later phases and in one instance at least
  98 //  (the parallel remark) it has to be used (the parallel remark depends
  99 //  on the partitioning done in the previous parallel scavenge).
 100 
 101 class SharedHeap : public CollectedHeap {
 102   friend class VMStructs;
 103 
 104   friend class VM_GC_Operation;
 105   friend class VM_CGC_Operation;
 106 public:
 107   // The set of potentially parallel tasks in root scanning.
 108   enum SH_process_roots_tasks {
 109     SH_PS_Threads_oops_do,
 110     SH_PS_StringTable_oops_do,
 111     SH_PS_Universe_oops_do,
 112     SH_PS_JNIHandles_oops_do,
 113     SH_PS_ObjectSynchronizer_oops_do,
 114     SH_PS_FlatProfiler_oops_do,
 115     SH_PS_Management_oops_do,
 116     SH_PS_SystemDictionary_oops_do,
 117     SH_PS_ClassLoaderDataGraph_oops_do,
 118     SH_PS_jvmti_oops_do,
 119     SH_PS_CodeCache_oops_do,
 120     // Leave this one last.
 121     SH_PS_NumElements
 122   };
 123 
 124   static const char* ext_roots_task_str(uint task);
 125 private:
 126   // For claiming strong_roots tasks.
 127   SubTasksDone* _process_strong_tasks;
 128 
 129 protected:
 130   // There should be only a single instance of "SharedHeap" in a program.
 131   // This is enforced with the protected constructor below, which will also
 132   // set the static pointer "_sh" to that instance.
 133   static SharedHeap* _sh;
 134 
 135   // A gc policy, controls global gc resource issues
 136   CollectorPolicy *_collector_policy;
 137 
 138   // See the discussion below, in the specification of the reader function
 139   // for this variable.
 140   int _strong_roots_parity;
 141 
 142   // If we're doing parallel GC, use this gang of threads.
 143   FlexibleWorkGang* _workers;
 144 


 241  public:
 242   enum ScanningOption {
 243     SO_None                =  0x0,
 244     SO_AllCodeCache        =  0x8,
 245     SO_ScavengeCodeCache   = 0x10
 246   };
 247 
 248   FlexibleWorkGang* workers() const { return _workers; }
 249 
 250   // Invoke the "do_oop" method the closure "roots" on all root locations.
 251   // The "so" argument determines which roots the closure is applied to:
 252   // "SO_None" does none;
 253   // "SO_AllCodeCache" applies the closure to all elements of the CodeCache.
 254   // "SO_ScavengeCodeCache" applies the closure to elements on the scavenge root list in the CodeCache.
 255   void process_roots(bool activate_scope,
 256                      ScanningOption so,
 257                      OopClosure* strong_roots,
 258                      OopClosure* weak_roots,
 259                      CLDClosure* strong_cld_closure,
 260                      CLDClosure* weak_cld_closure,
 261                      CodeBlobClosure* code_roots,
 262                      PhaseTimeData* phase_durations = NULL);
 263   void process_all_roots(bool activate_scope,
 264                          ScanningOption so,
 265                          OopClosure* roots,
 266                          CLDClosure* cld_closure,
 267                          CodeBlobClosure* code_roots,
 268                          PhaseTimeData* phase_durations = NULL);
 269   void process_strong_roots(bool activate_scope,
 270                             ScanningOption so,
 271                             OopClosure* roots,
 272                             CLDClosure* cld_closure,
 273                             CodeBlobClosure* code_roots,
 274                             PhaseTimeData* phase_durations = NULL);
 275 
 276 
 277   // Apply "root_closure" to the JNI weak roots..
 278   void process_weak_roots(OopClosure* root_closure);
 279 
 280   // The functions below are helper functions that a subclass of
 281   // "SharedHeap" can use in the implementation of its virtual
 282   // functions.
 283 
 284 public:
 285 
 286   // Do anything common to GC's.
 287   virtual void gc_prologue(bool full) = 0;
 288   virtual void gc_epilogue(bool full) = 0;
 289 
 290   // Sets the number of parallel threads that will be doing tasks
 291   // (such as process roots) subsequently.
 292   virtual void set_par_threads(uint t);
 293 
 294   int n_termination();
< prev index next >