src/share/vm/gc_implementation/g1/concurrentG1Refine.hpp

Mon, 09 Mar 2009 13:28:46 -0700

author
xdono
date
Mon, 09 Mar 2009 13:28:46 -0700
changeset 1014
0fbdb4381b99
parent 984
fe3d7c11b4b7
child 1229
315a5d70b295
permissions
-rw-r--r--

6814575: Update copyright year
Summary: Update copyright for files that have been modified in 2009, up to 03/09
Reviewed-by: katleman, tbell, ohair

     1 /*
     2  * Copyright 2001-2009 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 // Forward decl
    26 class ConcurrentG1RefineThread;
    27 class G1RemSet;
    29 // What to do after a yield:
    30 enum PostYieldAction {
    31   PYA_continue,  // Continue the traversal
    32   PYA_restart,   // Restart
    33   PYA_cancel     // It's been completed by somebody else: cancel.
    34 };
    36 class ConcurrentG1Refine: public CHeapObj {
    37   ConcurrentG1RefineThread* _cg1rThread;
    39   volatile jint _pya;
    40   PostYieldAction _last_pya;
    42   static bool _enabled;  // Protected by G1ConcRefine_mon.
    43   unsigned _traversals;
    45   // Number of cards processed during last refinement traversal.
    46   unsigned _first_traversal;
    47   unsigned _last_cards_during;
    49   // The cache for card refinement.
    50   bool     _use_cache;
    51   bool     _def_use_cache;
    52   size_t _n_periods;
    53   size_t _total_cards;
    54   size_t _total_travs;
    56   unsigned char*  _card_counts;
    57   unsigned _n_card_counts;
    58   const jbyte* _ct_bot;
    59   unsigned* _cur_card_count_histo;
    60   unsigned* _cum_card_count_histo;
    61   jbyte**  _hot_cache;
    62   int      _hot_cache_size;
    63   int      _n_hot;
    64   int      _hot_cache_idx;
    66   // Returns the count of this card after incrementing it.
    67   int add_card_count(jbyte* card_ptr);
    69   void print_card_count_histo_range(unsigned* histo, int from, int to,
    70                                     float& cum_card_pct,
    71                                     float& cum_travs_pct);
    72  public:
    73   ConcurrentG1Refine();
    74   ~ConcurrentG1Refine();
    76   void init(); // Accomplish some initialization that has to wait.
    78   // Enabled Conc refinement, waking up thread if necessary.
    79   void enable();
    81   // Returns the number of traversals performed since this refiner was enabled.
    82   unsigned disable();
    84   // Requires G1ConcRefine_mon to be held.
    85   bool enabled() { return _enabled; }
    87   // Returns only when G1 concurrent refinement has been enabled.
    88   void wait_for_ConcurrentG1Refine_enabled();
    90   // Do one concurrent refinement pass over the card table.  Returns "true"
    91   // if heuristics determine that another pass should be done immediately.
    92   bool refine();
    94   // Indicate that an in-progress refinement pass should start over.
    95   void set_pya_restart();
    96   // Indicate that an in-progress refinement pass should quit.
    97   void set_pya_cancel();
    99   // Get the appropriate post-yield action.  Also sets last_pya.
   100   PostYieldAction get_pya();
   102   // The last PYA read by "get_pya".
   103   PostYieldAction get_last_pya();
   105   bool do_traversal();
   107   ConcurrentG1RefineThread* cg1rThread() { return _cg1rThread; }
   109   // If this is the first entry for the slot, writes into the cache and
   110   // returns NULL.  If it causes an eviction, returns the evicted pointer.
   111   // Otherwise, its a cache hit, and returns NULL.
   112   jbyte* cache_insert(jbyte* card_ptr);
   114   // Process the cached entries.
   115   void clean_up_cache(int worker_i, G1RemSet* g1rs);
   117   // Discard entries in the hot cache.
   118   void clear_hot_cache() {
   119     _hot_cache_idx = 0; _n_hot = 0;
   120   }
   122   bool hot_cache_is_empty() { return _n_hot == 0; }
   124   bool use_cache() { return _use_cache; }
   125   void set_use_cache(bool b) {
   126     if (b) _use_cache = _def_use_cache;
   127     else   _use_cache = false;
   128   }
   130   void clear_and_record_card_counts();
   131   void print_final_card_counts();
   132 };

mercurial