index

src/share/vm/gc_implementation/shared/vmGCOperations.hpp

Print this page
rev 8024 : imported patch event1
* * *
imported patch event2


   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  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_VMGCOPERATIONS_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_SHARED_VMGCOPERATIONS_HPP
  27 
  28 #include "gc_interface/collectedHeap.hpp"

  29 #include "memory/heapInspection.hpp"
  30 #include "runtime/handles.hpp"
  31 #include "runtime/jniHandles.hpp"
  32 #include "runtime/synchronizer.hpp"
  33 #include "runtime/vm_operations.hpp"
  34 #include "prims/jvmtiExport.hpp"
  35 
  36 // The following class hierarchy represents
  37 // a set of operations (VM_Operation) related to GC.
  38 //
  39 //  VM_Operation
  40 //      VM_GC_Operation
  41 //          VM_GC_HeapInspection
  42 //          VM_GenCollectFull
  43 //          VM_GenCollectFullConcurrent
  44 //          VM_ParallelGCSystemGC
  45 //          VM_CollectForAllocation
  46 //              VM_GenCollectForAllocation
  47 //              VM_ParallelGCFailedAllocation
  48 //  VM_GC_Operation


 147     _columns = NULL;
 148   }
 149 
 150   ~VM_GC_HeapInspection() {}
 151   virtual VMOp_Type type() const { return VMOp_GC_HeapInspection; }
 152   virtual bool skip_operation() const;
 153   virtual bool doit_prologue();
 154   virtual void doit();
 155   void set_csv_format(bool value) {_csv_format = value;}
 156   void set_print_help(bool value) {_print_help = value;}
 157   void set_print_class_stats(bool value) {_print_class_stats = value;}
 158   void set_columns(const char* value) {_columns = value;}
 159  protected:
 160   bool collect();
 161 };
 162 
 163 class VM_CollectForAllocation : public VM_GC_Operation {
 164  protected:
 165   size_t    _word_size; // Size of object to be allocated (in number of words)
 166   HeapWord* _result;    // Allocation result (NULL if allocation failed)


 167 
 168  public:
 169   VM_CollectForAllocation(size_t word_size, uint gc_count_before, GCCause::Cause cause)
 170     : VM_GC_Operation(gc_count_before, cause), _result(NULL), _word_size(word_size) {}



 171 
 172   HeapWord* result() const {
 173     return _result;
 174   }
 175 };
 176 
 177 class VM_GenCollectForAllocation : public VM_CollectForAllocation {
 178  private:
 179   bool        _tlab;                       // alloc is of a tlab.
 180  public:
 181   VM_GenCollectForAllocation(size_t word_size,
 182                              bool tlab,
 183                              uint gc_count_before)
 184     : VM_CollectForAllocation(word_size, gc_count_before, GCCause::_allocation_failure),

 185       _tlab(tlab) {
 186     assert(word_size != 0, "An allocation should always be requested with this operation.");
 187   }
 188   ~VM_GenCollectForAllocation()  {}
 189   virtual VMOp_Type type() const { return VMOp_GenCollectForAllocation; }
 190   virtual void doit();
 191 };
 192 
 193 // VM operation to invoke a collection of the heap as a
 194 // GenCollectedHeap heap.
 195 class VM_GenCollectFull: public VM_GC_Operation {
 196  private:
 197   int _max_level;
 198  public:
 199   VM_GenCollectFull(uint gc_count_before,
 200                     uint full_gc_count_before,
 201                     GCCause::Cause gc_cause,
 202                     int max_level)
 203     : VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true /* full */),
 204       _max_level(max_level) { }
 205   ~VM_GenCollectFull() {}
 206   virtual VMOp_Type type() const { return VMOp_GenCollectFull; }
 207   virtual void doit();
 208 };
 209 
 210 class VM_CollectForMetadataAllocation: public VM_GC_Operation {
 211  private:
 212   MetaWord*                _result;
 213   size_t                   _size;     // size of object to be allocated
 214   Metaspace::MetadataType  _mdtype;
 215   ClassLoaderData*         _loader_data;


 216  public:
 217   VM_CollectForMetadataAllocation(ClassLoaderData* loader_data,
 218                                   size_t size, Metaspace::MetadataType mdtype,
 219                                   uint gc_count_before,
 220                                   uint full_gc_count_before,
 221                                   GCCause::Cause gc_cause)
 222     : VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true),
 223       _loader_data(loader_data), _size(size), _mdtype(mdtype), _result(NULL) {
 224   }
 225   virtual VMOp_Type type() const { return VMOp_CollectForMetadataAllocation; }
 226   virtual void doit();

 227   MetaWord* result() const       { return _result; }
 228 
 229   bool initiate_concurrent_GC();
 230 };
 231 
 232 class SvcGCMarker : public StackObj {
 233  private:
 234   JvmtiGCMarker _jgcm;
 235  public:
 236   typedef enum { MINOR, FULL, OTHER } reason_type;
 237 
 238   SvcGCMarker(reason_type reason ) {
 239     VM_GC_Operation::notify_gc_begin(reason == FULL);
 240   }
 241 
 242   ~SvcGCMarker() {
 243     VM_GC_Operation::notify_gc_end();
 244   }
 245 };
 246 


   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  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_IMPLEMENTATION_SHARED_VMGCOPERATIONS_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_SHARED_VMGCOPERATIONS_HPP
  27 
  28 #include "gc_interface/collectedHeap.hpp"
  29 #include "gc_implementation/shared/gcId.hpp"
  30 #include "memory/heapInspection.hpp"
  31 #include "runtime/handles.hpp"
  32 #include "runtime/jniHandles.hpp"
  33 #include "runtime/synchronizer.hpp"
  34 #include "runtime/vm_operations.hpp"
  35 #include "prims/jvmtiExport.hpp"
  36 
  37 // The following class hierarchy represents
  38 // a set of operations (VM_Operation) related to GC.
  39 //
  40 //  VM_Operation
  41 //      VM_GC_Operation
  42 //          VM_GC_HeapInspection
  43 //          VM_GenCollectFull
  44 //          VM_GenCollectFullConcurrent
  45 //          VM_ParallelGCSystemGC
  46 //          VM_CollectForAllocation
  47 //              VM_GenCollectForAllocation
  48 //              VM_ParallelGCFailedAllocation
  49 //  VM_GC_Operation


 148     _columns = NULL;
 149   }
 150 
 151   ~VM_GC_HeapInspection() {}
 152   virtual VMOp_Type type() const { return VMOp_GC_HeapInspection; }
 153   virtual bool skip_operation() const;
 154   virtual bool doit_prologue();
 155   virtual void doit();
 156   void set_csv_format(bool value) {_csv_format = value;}
 157   void set_print_help(bool value) {_print_help = value;}
 158   void set_print_class_stats(bool value) {_print_class_stats = value;}
 159   void set_columns(const char* value) {_columns = value;}
 160  protected:
 161   bool collect();
 162 };
 163 
 164 class VM_CollectForAllocation : public VM_GC_Operation {
 165  protected:
 166   size_t                     _word_size;  // Size of object to be allocated (in number of words)
 167   HeapWord*                  _result;     // Allocation result (NULL if allocation failed)
 168   uint                       _gc_attempt; // Collection attempt for this allocation.
 169   GCId                       _gcid;       // Predicted GCId for this operation.
 170 
 171  public:
 172   VM_CollectForAllocation(size_t word_size, uint gc_count_before, GCCause::Cause cause, uint gc_attempt);
 173 
 174   // The epilogue is run by the requesting thread after and if the collection happened.
 175   // It is extended here to trace collections performed due to failed allocations.
 176   void doit_epilogue();
 177 
 178   HeapWord* result() const {
 179     return _result;
 180   }
 181 };
 182 
 183 class VM_GenCollectForAllocation : public VM_CollectForAllocation {
 184  private:
 185   bool        _tlab;                       // alloc is of a tlab.
 186  public:
 187   VM_GenCollectForAllocation(size_t word_size,
 188                              bool tlab,
 189                              uint gc_count_before,
 190                              uint gc_attempt)
 191     : VM_CollectForAllocation(word_size, gc_count_before, GCCause::_allocation_failure, gc_attempt),
 192       _tlab(tlab) {
 193     assert(word_size != 0, "An allocation should always be requested with this operation.");
 194   }
 195   ~VM_GenCollectForAllocation()  {}
 196   virtual VMOp_Type type() const { return VMOp_GenCollectForAllocation; }
 197   virtual void doit();
 198 };
 199 
 200 // VM operation to invoke a collection of the heap as a
 201 // GenCollectedHeap heap.
 202 class VM_GenCollectFull: public VM_GC_Operation {
 203  private:
 204   int _max_level;
 205  public:
 206   VM_GenCollectFull(uint gc_count_before,
 207                     uint full_gc_count_before,
 208                     GCCause::Cause gc_cause,
 209                     int max_level)
 210     : VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true /* full */),
 211       _max_level(max_level) { }
 212   ~VM_GenCollectFull() {}
 213   virtual VMOp_Type type() const { return VMOp_GenCollectFull; }
 214   virtual void doit();
 215 };
 216 
 217 class VM_CollectForMetadataAllocation: public VM_GC_Operation {
 218  private:
 219   MetaWord*                _result;
 220   size_t                   _size;        // size of object to be allocated
 221   Metaspace::MetadataType  _mdtype;
 222   ClassLoaderData*         _loader_data;
 223   uint                     _gc_attempt;  // Collection attempt for this allocation.
 224   GCId                     _gcid;        // Predicted GCId for this operation.
 225  public:
 226   VM_CollectForMetadataAllocation(ClassLoaderData* loader_data,
 227                                   size_t size, Metaspace::MetadataType mdtype,
 228                                   uint gc_count_before,
 229                                   uint full_gc_count_before,
 230                                   GCCause::Cause gc_cause,
 231                                   uint gc_attempt);


 232   virtual VMOp_Type type() const { return VMOp_CollectForMetadataAllocation; }
 233   virtual void doit();
 234   void doit_epilogue();
 235   MetaWord* result() const       { return _result; }
 236 
 237   bool initiate_concurrent_GC();
 238 };
 239 
 240 class SvcGCMarker : public StackObj {
 241  private:
 242   JvmtiGCMarker _jgcm;
 243  public:
 244   typedef enum { MINOR, FULL, OTHER } reason_type;
 245 
 246   SvcGCMarker(reason_type reason ) {
 247     VM_GC_Operation::notify_gc_begin(reason == FULL);
 248   }
 249 
 250   ~SvcGCMarker() {
 251     VM_GC_Operation::notify_gc_end();
 252   }
 253 };
 254 
index