src/share/vm/gc_implementation/parallelScavenge/psPromotionLAB.hpp

Print this page


   1 /*
   2  * Copyright (c) 2002, 2008, 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  *
  23  */
  24 






  25 //
  26 // PSPromotionLAB is a parallel scavenge promotion lab. This class acts very
  27 // much like a MutableSpace. We couldn't embed a MutableSpace, though, as
  28 // it has a considerable number of asserts and invariants that are violated.
  29 //
  30 
  31 class ObjectStartArray;
  32 
  33 class PSPromotionLAB : public CHeapObj {
  34  protected:
  35   static size_t filler_header_size;
  36 
  37   enum LabState {
  38     needs_flush,
  39     flushed,
  40     zero_size
  41   };
  42 
  43   HeapWord* _top;
  44   HeapWord* _bottom;


 123   HeapWord* allocate(size_t size) {
 124     // Cannot test for this now that we're doing promotion failures
 125     // assert(_state != flushed, "Sanity");
 126     assert(_start_array != NULL, "Sanity");
 127     HeapWord* obj = top();
 128     HeapWord* new_top = obj + size;
 129     // The 'new_top>obj' check is needed to detect overflow of obj+size.
 130     if (new_top > obj && new_top <= end()) {
 131       set_top(new_top);
 132       assert(is_object_aligned((intptr_t)obj) && is_object_aligned((intptr_t)new_top),
 133              "checking alignment");
 134       _start_array->allocate_block(obj);
 135       return obj;
 136     }
 137 
 138     return NULL;
 139   }
 140 
 141   debug_only(virtual bool lab_is_valid(MemRegion lab));
 142 };


   1 /*
   2  * Copyright (c) 2002, 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  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_HPP
  26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_HPP
  27 
  28 #include "gc_implementation/parallelScavenge/objectStartArray.hpp"
  29 #include "memory/allocation.hpp"
  30 
  31 //
  32 // PSPromotionLAB is a parallel scavenge promotion lab. This class acts very
  33 // much like a MutableSpace. We couldn't embed a MutableSpace, though, as
  34 // it has a considerable number of asserts and invariants that are violated.
  35 //
  36 
  37 class ObjectStartArray;
  38 
  39 class PSPromotionLAB : public CHeapObj {
  40  protected:
  41   static size_t filler_header_size;
  42 
  43   enum LabState {
  44     needs_flush,
  45     flushed,
  46     zero_size
  47   };
  48 
  49   HeapWord* _top;
  50   HeapWord* _bottom;


 129   HeapWord* allocate(size_t size) {
 130     // Cannot test for this now that we're doing promotion failures
 131     // assert(_state != flushed, "Sanity");
 132     assert(_start_array != NULL, "Sanity");
 133     HeapWord* obj = top();
 134     HeapWord* new_top = obj + size;
 135     // The 'new_top>obj' check is needed to detect overflow of obj+size.
 136     if (new_top > obj && new_top <= end()) {
 137       set_top(new_top);
 138       assert(is_object_aligned((intptr_t)obj) && is_object_aligned((intptr_t)new_top),
 139              "checking alignment");
 140       _start_array->allocate_block(obj);
 141       return obj;
 142     }
 143 
 144     return NULL;
 145   }
 146 
 147   debug_only(virtual bool lab_is_valid(MemRegion lab));
 148 };
 149 
 150 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPROMOTIONLAB_HPP