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

Print this page


   1 /*
   2  * Copyright (c) 2005, 2010, 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  *


 121 
 122   void set_gc_locked() { _gc_locked = true; }
 123   bool gc_locked() const  { return _gc_locked; }
 124 
 125   static void notify_gc_begin(bool full = false);
 126   static void notify_gc_end();
 127 };
 128 
 129 
 130 class VM_GC_HeapInspection: public VM_GC_Operation {
 131  private:
 132   outputStream* _out;
 133   bool _full_gc;
 134   bool _need_prologue;
 135  public:
 136   VM_GC_HeapInspection(outputStream* out, bool request_full_gc,
 137                        bool need_prologue) :
 138     VM_GC_Operation(0 /* total collections,      dummy, ignored */,
 139                     0 /* total full collections, dummy, ignored */,
 140                     request_full_gc) {

 141     _out = out;
 142     _full_gc = request_full_gc;
 143     _need_prologue = need_prologue;
 144   }
 145 
 146   ~VM_GC_HeapInspection() {}
 147   virtual VMOp_Type type() const { return VMOp_GC_HeapInspection; }
 148   virtual bool skip_operation() const;
 149   virtual bool doit_prologue();
 150   virtual void doit();
 151 };
 152 
 153 
 154 class VM_GenCollectForAllocation: public VM_GC_Operation {
 155  private:
 156   HeapWord*   _res;
 157   size_t      _size;                       // size of object to be allocated.
 158   bool        _tlab;                       // alloc is of a tlab.
 159  public:
 160   VM_GenCollectForAllocation(size_t size,
 161                              bool tlab,
 162                              unsigned int gc_count_before)
 163     : VM_GC_Operation(gc_count_before),
 164       _size(size),
 165       _tlab(tlab) {

 166     _res = NULL;
 167   }
 168   ~VM_GenCollectForAllocation()  {}
 169   virtual VMOp_Type type() const { return VMOp_GenCollectForAllocation; }
 170   virtual void doit();
 171   HeapWord* result() const       { return _res; }
 172 };
 173 
 174 
 175 // VM operation to invoke a collection of the heap as a
 176 // GenCollectedHeap heap.
 177 class VM_GenCollectFull: public VM_GC_Operation {
 178  private:
 179   int _max_level;
 180  public:
 181   VM_GenCollectFull(unsigned int gc_count_before,
 182                     unsigned int full_gc_count_before,
 183                     GCCause::Cause gc_cause,
 184                       int max_level)
 185     : VM_GC_Operation(gc_count_before, full_gc_count_before, true /* full */),


   1 /*
   2  * Copyright (c) 2005, 2011, 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  *


 121 
 122   void set_gc_locked() { _gc_locked = true; }
 123   bool gc_locked() const  { return _gc_locked; }
 124 
 125   static void notify_gc_begin(bool full = false);
 126   static void notify_gc_end();
 127 };
 128 
 129 
 130 class VM_GC_HeapInspection: public VM_GC_Operation {
 131  private:
 132   outputStream* _out;
 133   bool _full_gc;
 134   bool _need_prologue;
 135  public:
 136   VM_GC_HeapInspection(outputStream* out, bool request_full_gc,
 137                        bool need_prologue) :
 138     VM_GC_Operation(0 /* total collections,      dummy, ignored */,
 139                     0 /* total full collections, dummy, ignored */,
 140                     request_full_gc) {
 141     _gc_cause = GCCause::_heap_inspection;
 142     _out = out;
 143     _full_gc = request_full_gc;
 144     _need_prologue = need_prologue;
 145   }
 146 
 147   ~VM_GC_HeapInspection() {}
 148   virtual VMOp_Type type() const { return VMOp_GC_HeapInspection; }
 149   virtual bool skip_operation() const;
 150   virtual bool doit_prologue();
 151   virtual void doit();
 152 };
 153 
 154 
 155 class VM_GenCollectForAllocation: public VM_GC_Operation {
 156  private:
 157   HeapWord*   _res;
 158   size_t      _size;                       // size of object to be allocated.
 159   bool        _tlab;                       // alloc is of a tlab.
 160  public:
 161   VM_GenCollectForAllocation(size_t size,
 162                              bool tlab,
 163                              unsigned int gc_count_before)
 164     : VM_GC_Operation(gc_count_before),
 165       _size(size),
 166       _tlab(tlab) {
 167     _gc_cause = GCCause::_allocation_failure;
 168     _res = NULL;
 169   }
 170   ~VM_GenCollectForAllocation()  {}
 171   virtual VMOp_Type type() const { return VMOp_GenCollectForAllocation; }
 172   virtual void doit();
 173   HeapWord* result() const       { return _res; }
 174 };
 175 
 176 
 177 // VM operation to invoke a collection of the heap as a
 178 // GenCollectedHeap heap.
 179 class VM_GenCollectFull: public VM_GC_Operation {
 180  private:
 181   int _max_level;
 182  public:
 183   VM_GenCollectFull(unsigned int gc_count_before,
 184                     unsigned int full_gc_count_before,
 185                     GCCause::Cause gc_cause,
 186                       int max_level)
 187     : VM_GC_Operation(gc_count_before, full_gc_count_before, true /* full */),