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

Sun, 13 Apr 2008 17:43:42 -0400

author
coleenp
date
Sun, 13 Apr 2008 17:43:42 -0400
changeset 548
ba764ed4b6f2
parent 435
a61af66fc99e
child 574
c0492d52d55b
permissions
-rw-r--r--

6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold

     1 /*
     2  * Copyright 2005-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 // The following class hierarchy represents
    26 // a set of operations (VM_Operation) related to GC.
    27 //
    28 //  VM_Operation
    29 //      VM_GC_Operation
    30 //          VM_GC_HeapInspection
    31 //          VM_GenCollectForAllocation
    32 //          VM_GenCollectFull
    33 //          VM_GenCollectFullConcurrent
    34 //          VM_ParallelGCFailedAllocation
    35 //          VM_ParallelGCFailedPermanentAllocation
    36 //          VM_ParallelGCSystemGC
    37 //  VM_GC_Operation
    38 //   - implements methods common to all classes in the hierarchy:
    39 //     prevents multiple gc requests and manages lock on heap;
    40 //
    41 //  VM_GC_HeapInspection
    42 //   - prints class histogram on SIGBREAK if PrintClassHistogram
    43 //     is specified; and also the attach "inspectheap" operation
    44 //
    45 //  VM_GenCollectForAllocation
    46 //  VM_ParallelGCFailedAllocation
    47 //  VM_ParallelGCFailedPermanentAllocation
    48 //   - this operation is invoked when allocation is failed;
    49 //     operation performs garbage collection and tries to
    50 //     allocate afterwards;
    51 //
    52 //  VM_GenCollectFull
    53 //  VM_GenCollectFullConcurrent
    54 //  VM_ParallelGCSystemGC
    55 //   - these operations preform full collection of heaps of
    56 //     different kind
    57 //
    59 class VM_GC_Operation: public VM_Operation {
    60  protected:
    61   BasicLock     _pending_list_basic_lock; // for refs pending list notification (PLL)
    62   unsigned int  _gc_count_before;         // gc count before acquiring PLL
    63   unsigned int  _full_gc_count_before;    // full gc count before acquiring PLL
    64   bool          _full;                    // whether a "full" collection
    65   bool          _prologue_succeeded;      // whether doit_prologue succeeded
    66   GCCause::Cause _gc_cause;                // the putative cause for this gc op
    67   bool          _gc_locked;               // will be set if gc was locked
    69   virtual bool skip_operation() const;
    71   // java.lang.ref.Reference support
    72   void acquire_pending_list_lock();
    73   void release_and_notify_pending_list_lock();
    75  public:
    76   VM_GC_Operation(unsigned int gc_count_before,
    77                   unsigned int full_gc_count_before = 0,
    78                   bool full = false) {
    79     _full = full;
    80     _prologue_succeeded = false;
    81     _gc_count_before    = gc_count_before;
    83     // A subclass constructor will likely overwrite the following
    84     _gc_cause           = GCCause::_no_cause_specified;
    86     _gc_locked = false;
    88     if (full) {
    89       _full_gc_count_before = full_gc_count_before;
    90     }
    91   }
    92   ~VM_GC_Operation() {}
    94   // Acquire the reference synchronization lock
    95   virtual bool doit_prologue();
    96   // Do notifyAll (if needed) and release held lock
    97   virtual void doit_epilogue();
    99   virtual bool allow_nested_vm_operations() const  { return true; }
   100   bool prologue_succeeded() const { return _prologue_succeeded; }
   102   void set_gc_locked() { _gc_locked = true; }
   103   bool gc_locked() const  { return _gc_locked; }
   105   static void notify_gc_begin(bool full = false);
   106   static void notify_gc_end();
   107 };
   110 class VM_GC_HeapInspection: public VM_GC_Operation {
   111  private:
   112   outputStream* _out;
   113   bool _full_gc;
   114  public:
   115   VM_GC_HeapInspection(outputStream* out, bool request_full_gc) :
   116     VM_GC_Operation(0 /* total collections,      dummy, ignored */,
   117                     0 /* total full collections, dummy, ignored */,
   118                     request_full_gc) {
   119     _out = out;
   120     _full_gc = request_full_gc;
   121   }
   123   ~VM_GC_HeapInspection() {}
   124   virtual VMOp_Type type() const { return VMOp_GC_HeapInspection; }
   125   virtual bool skip_operation() const;
   126   virtual bool doit_prologue();
   127   virtual void doit();
   128 };
   131 class VM_GenCollectForAllocation: public VM_GC_Operation {
   132  private:
   133   HeapWord*   _res;
   134   size_t      _size;                       // size of object to be allocated.
   135   bool        _tlab;                       // alloc is of a tlab.
   136  public:
   137   VM_GenCollectForAllocation(size_t size,
   138                              bool tlab,
   139                              unsigned int gc_count_before)
   140     : VM_GC_Operation(gc_count_before),
   141       _size(size),
   142       _tlab(tlab) {
   143     _res = NULL;
   144   }
   145   ~VM_GenCollectForAllocation()  {}
   146   virtual VMOp_Type type() const { return VMOp_GenCollectForAllocation; }
   147   virtual void doit();
   148   HeapWord* result() const       { return _res; }
   149 };
   152 // VM operation to invoke a collection of the heap as a
   153 // GenCollectedHeap heap.
   154 class VM_GenCollectFull: public VM_GC_Operation {
   155  private:
   156   int _max_level;
   157  public:
   158   VM_GenCollectFull(unsigned int gc_count_before,
   159                     unsigned int full_gc_count_before,
   160                     GCCause::Cause gc_cause,
   161                       int max_level)
   162     : VM_GC_Operation(gc_count_before, full_gc_count_before, true /* full */),
   163       _max_level(max_level)
   164   { _gc_cause = gc_cause; }
   165   ~VM_GenCollectFull() {}
   166   virtual VMOp_Type type() const { return VMOp_GenCollectFull; }
   167   virtual void doit();
   168 };

mercurial