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

Sat, 19 Jul 2008 17:38:22 -0400

author
coleenp
date
Sat, 19 Jul 2008 17:38:22 -0400
changeset 672
1fdb98a17101
parent 435
a61af66fc99e
child 698
12eea04c8b06
permissions
-rw-r--r--

6716785: implicit null checks not triggering with CompressedOops
Summary: allocate alignment-sized page(s) below java heap so that memory accesses at heap_base+1page give signal and cause an implicit null check
Reviewed-by: kvn, jmasa, phh, jcoomes

     1 /*
     2  * Copyright 2001-2006 Sun Microsystems, Inc.  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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 class PSMarkSweepDecorator;
    27 class PSOldGen : public CHeapObj {
    28   friend class VMStructs;
    29   friend class PSPromotionManager; // Uses the cas_allocate methods
    30   friend class ParallelScavengeHeap;
    31   friend class AdjoiningGenerations;
    33  protected:
    34   MemRegion                _reserved;          // Used for simple containment tests
    35   PSVirtualSpace*          _virtual_space;     // Controls mapping and unmapping of virtual mem
    36   ObjectStartArray         _start_array;       // Keeps track of where objects start in a 512b block
    37   MutableSpace*            _object_space;      // Where all the objects live
    38   PSMarkSweepDecorator*    _object_mark_sweep; // The mark sweep view of _object_space
    39   const char* const        _name;              // Name of this generation.
    41   // Performance Counters
    42   PSGenerationCounters*    _gen_counters;
    43   SpaceCounters*           _space_counters;
    45   // Sizing information, in bytes, set in constructor
    46   const size_t _init_gen_size;
    47   const size_t _min_gen_size;
    48   const size_t _max_gen_size;
    50   // Used when initializing the _name field.
    51   static inline const char* select_name();
    53   HeapWord* allocate_noexpand(size_t word_size, bool is_tlab) {
    54     // We assume the heap lock is held here.
    55     assert(!is_tlab, "Does not support TLAB allocation");
    56     assert_locked_or_safepoint(Heap_lock);
    57     HeapWord* res = object_space()->allocate(word_size);
    58     if (res != NULL) {
    59       _start_array.allocate_block(res);
    60     }
    61     return res;
    62   }
    64   // Support for MT garbage collection. CAS allocation is lower overhead than grabbing
    65   // and releasing the heap lock, which is held during gc's anyway. This method is not
    66   // safe for use at the same time as allocate_noexpand()!
    67   HeapWord* cas_allocate_noexpand(size_t word_size) {
    68     assert(SafepointSynchronize::is_at_safepoint(), "Must only be called at safepoint")
    69     HeapWord* res = object_space()->cas_allocate(word_size);
    70     if (res != NULL) {
    71       _start_array.allocate_block(res);
    72     }
    73     return res;
    74   }
    76   // Support for MT garbage collection. See above comment.
    77   HeapWord* cas_allocate(size_t word_size) {
    78     HeapWord* res = cas_allocate_noexpand(word_size);
    79     return (res == NULL) ? expand_and_cas_allocate(word_size) : res;
    80   }
    82   HeapWord* expand_and_allocate(size_t word_size, bool is_tlab);
    83   HeapWord* expand_and_cas_allocate(size_t word_size);
    84   void expand(size_t bytes);
    85   bool expand_by(size_t bytes);
    86   bool expand_to_reserved();
    88   void shrink(size_t bytes);
    90   void post_resize();
    92  public:
    93   // Initialize the generation.
    94   PSOldGen(ReservedSpace rs, size_t alignment,
    95            size_t initial_size, size_t min_size, size_t max_size,
    96            const char* perf_data_name, int level);
    98   PSOldGen(size_t initial_size, size_t min_size, size_t max_size,
    99            const char* perf_data_name, int level);
   101   void initialize(ReservedSpace rs, size_t alignment,
   102                   const char* perf_data_name, int level);
   103   void initialize_virtual_space(ReservedSpace rs, size_t alignment);
   104   void initialize_work(const char* perf_data_name, int level);
   106   MemRegion reserved() const                { return _reserved; }
   107   virtual size_t max_gen_size()             { return _max_gen_size; }
   108   size_t min_gen_size()                     { return _min_gen_size; }
   110   // Returns limit on the maximum size of the generation.  This
   111   // is the same as _max_gen_size for PSOldGen but need not be
   112   // for a derived class.
   113   virtual size_t gen_size_limit();
   115   bool is_in(const void* p) const           {
   116     return _virtual_space->contains((void *)p);
   117   }
   119   bool is_in_reserved(const void* p) const {
   120     return reserved().contains(p);
   121   }
   123   MutableSpace*         object_space() const      { return _object_space; }
   124   PSMarkSweepDecorator* object_mark_sweep() const { return _object_mark_sweep; }
   125   ObjectStartArray*     start_array()             { return &_start_array; }
   126   PSVirtualSpace*       virtual_space() const     { return _virtual_space;}
   128   // Has the generation been successfully allocated?
   129   bool is_allocated();
   131   // MarkSweep methods
   132   virtual void precompact();
   133   void adjust_pointers();
   134   void compact();
   136   // Parallel old
   137   virtual void move_and_update(ParCompactionManager* cm);
   139   // Size info
   140   size_t capacity_in_bytes() const        { return object_space()->capacity_in_bytes(); }
   141   size_t used_in_bytes() const            { return object_space()->used_in_bytes(); }
   142   size_t free_in_bytes() const            { return object_space()->free_in_bytes(); }
   144   size_t capacity_in_words() const        { return object_space()->capacity_in_words(); }
   145   size_t used_in_words() const            { return object_space()->used_in_words(); }
   146   size_t free_in_words() const            { return object_space()->free_in_words(); }
   148   // Includes uncommitted memory
   149   size_t contiguous_available() const;
   151   bool is_maximal_no_gc() const {
   152     return virtual_space()->uncommitted_size() == 0;
   153   }
   155   // Calculating new sizes
   156   void resize(size_t desired_free_space);
   158   // Allocation. We report all successful allocations to the size policy
   159   // Note that the perm gen does not use this method, and should not!
   160   HeapWord* allocate(size_t word_size, bool is_tlab);
   162   // Iteration.
   163   void oop_iterate(OopClosure* cl) { object_space()->oop_iterate(cl); }
   164   void object_iterate(ObjectClosure* cl) { object_space()->object_iterate(cl); }
   166   // Debugging - do not use for time critical operations
   167   virtual void print() const;
   168   virtual void print_on(outputStream* st) const;
   169   void print_used_change(size_t prev_used) const;
   171   void verify(bool allow_dirty);
   172   void verify_object_start_array();
   174   // These should not used
   175   virtual void reset_after_change();
   177   // These should not used
   178   virtual size_t available_for_expansion();
   179   virtual size_t available_for_contraction();
   181   void space_invariants() PRODUCT_RETURN;
   183   // Performace Counter support
   184   void update_counters();
   186   // Printing support
   187   virtual const char* name() const { return _name; }
   188 };

mercurial