hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.hpp
author iveresov
Mon, 18 May 2009 11:52:46 -0700
changeset 2882 d508a8bac491
parent 2881 74a1337e4acc
child 3589 abdd970c243d
permissions -rw-r--r--
6841831: G1: assert(contains_reference(from),"We just added it!") fires Summary: During parallel rset updating we have to make sure that the worker ids of the refinement threads do not intersect with the worker ids that can be claimed by the mutator threads. Reviewed-by: tonyp
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     1
/*
2105
347008ce7984 6814575: Update copyright year
xdono
parents: 2013
diff changeset
     2
 * Copyright 2001-2009 Sun Microsystems, Inc.  All Rights Reserved.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     4
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     8
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    13
 * accompanied this code).
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    14
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    18
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    21
 * have any questions.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    22
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    23
 */
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    24
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    25
// Forward decl
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    26
class ConcurrentG1RefineThread;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    27
class G1RemSet;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    28
2013
49e915da0905 6700941: G1: allocation spec missing for some G1 classes
apetrusenko
parents: 1374
diff changeset
    29
class ConcurrentG1Refine: public CHeapObj {
2881
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2105
diff changeset
    30
  ConcurrentG1RefineThread** _threads;
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2105
diff changeset
    31
  int _n_threads;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    32
  // The cache for card refinement.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    33
  bool     _use_cache;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    34
  bool     _def_use_cache;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    35
  size_t _n_periods;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    36
  size_t _total_cards;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    37
  size_t _total_travs;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    38
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    39
  unsigned char*  _card_counts;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    40
  unsigned _n_card_counts;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    41
  const jbyte* _ct_bot;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    42
  unsigned* _cur_card_count_histo;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    43
  unsigned* _cum_card_count_histo;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    44
  jbyte**  _hot_cache;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    45
  int      _hot_cache_size;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    46
  int      _n_hot;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    47
  int      _hot_cache_idx;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    48
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    49
  // Returns the count of this card after incrementing it.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    50
  int add_card_count(jbyte* card_ptr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    51
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    52
  void print_card_count_histo_range(unsigned* histo, int from, int to,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    53
                                    float& cum_card_pct,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    54
                                    float& cum_travs_pct);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    55
 public:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    56
  ConcurrentG1Refine();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    57
  ~ConcurrentG1Refine();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    58
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    59
  void init(); // Accomplish some initialization that has to wait.
2881
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2105
diff changeset
    60
  void stop();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    61
2881
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2105
diff changeset
    62
  // Iterate over the conc refine threads
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2105
diff changeset
    63
  void threads_do(ThreadClosure *tc);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    64
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    65
  // If this is the first entry for the slot, writes into the cache and
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    66
  // returns NULL.  If it causes an eviction, returns the evicted pointer.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    67
  // Otherwise, its a cache hit, and returns NULL.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    68
  jbyte* cache_insert(jbyte* card_ptr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    69
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    70
  // Process the cached entries.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    71
  void clean_up_cache(int worker_i, G1RemSet* g1rs);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    72
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    73
  // Discard entries in the hot cache.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    74
  void clear_hot_cache() {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    75
    _hot_cache_idx = 0; _n_hot = 0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    76
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    77
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    78
  bool hot_cache_is_empty() { return _n_hot == 0; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    79
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    80
  bool use_cache() { return _use_cache; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    81
  void set_use_cache(bool b) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    82
    if (b) _use_cache = _def_use_cache;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    83
    else   _use_cache = false;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    84
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    85
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    86
  void clear_and_record_card_counts();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    87
  void print_final_card_counts();
2882
d508a8bac491 6841831: G1: assert(contains_reference(from),"We just added it!") fires
iveresov
parents: 2881
diff changeset
    88
d508a8bac491 6841831: G1: assert(contains_reference(from),"We just added it!") fires
iveresov
parents: 2881
diff changeset
    89
  static size_t thread_num();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    90
};