hotspot/src/share/vm/gc_implementation/g1/concurrentG1Refine.hpp
author tonyp
Wed, 25 Jan 2012 12:58:23 -0500
changeset 11584 e1df4d08a1f4
parent 9185 7b717a00a48e
child 13195 be27e1b6a4b9
permissions -rw-r--r--
7127706: G1: re-enable survivors during the initial-mark pause Summary: Re-enable survivors during the initial-mark pause. Afterwards, the concurrent marking threads have to scan them and mark everything reachable from them. The next GC will have to wait for the survivors to be scanned. Reviewed-by: brutisso, johnc
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
/*
8926
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
     2
 * Copyright (c) 2001, 2011, Oracle and/or its affiliates. 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
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5033
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5033
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5033
diff changeset
    21
 * questions.
1374
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
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6247
diff changeset
    25
#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTG1REFINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6247
diff changeset
    26
#define SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTG1REFINE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6247
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6247
diff changeset
    28
#include "memory/allocation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6247
diff changeset
    29
#include "memory/cardTableModRefBS.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6247
diff changeset
    30
#include "runtime/thread.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6247
diff changeset
    31
#include "utilities/globalDefinitions.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6247
diff changeset
    32
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    33
// Forward decl
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    34
class ConcurrentG1RefineThread;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    35
class G1RemSet;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    36
2013
49e915da0905 6700941: G1: allocation spec missing for some G1 classes
apetrusenko
parents: 1374
diff changeset
    37
class ConcurrentG1Refine: public CHeapObj {
2881
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2105
diff changeset
    38
  ConcurrentG1RefineThread** _threads;
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2105
diff changeset
    39
  int _n_threads;
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    40
  int _n_worker_threads;
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    41
 /*
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    42
  * The value of the update buffer queue length falls into one of 3 zones:
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    43
  * green, yellow, red. If the value is in [0, green) nothing is
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    44
  * done, the buffers are left unprocessed to enable the caching effect of the
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    45
  * dirtied cards. In the yellow zone [green, yellow) the concurrent refinement
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    46
  * threads are gradually activated. In [yellow, red) all threads are
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    47
  * running. If the length becomes red (max queue length) the mutators start
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    48
  * processing the buffers.
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    49
  *
5033
55f476a32544 6928059: G1: command line parameter renaming
tonyp
parents: 4481
diff changeset
    50
  * There are some interesting cases (when G1UseAdaptiveConcRefinement
55f476a32544 6928059: G1: command line parameter renaming
tonyp
parents: 4481
diff changeset
    51
  * is turned off):
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    52
  * 1) green = yellow = red = 0. In this case the mutator will process all
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    53
  *    buffers. Except for those that are created by the deferred updates
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    54
  *    machinery during a collection.
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    55
  * 2) green = 0. Means no caching. Can be a good way to minimize the
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    56
  *    amount of time spent updating rsets during a collection.
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    57
  */
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    58
  int _green_zone;
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    59
  int _yellow_zone;
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    60
  int _red_zone;
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    61
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    62
  int _thread_threshold_step;
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    63
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    64
  // Reset the threshold step value based of the current zone boundaries.
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
    65
  void reset_threshold_step();
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    66
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    67
  // The cache for card refinement.
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    68
  bool   _use_cache;
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    69
  bool   _def_use_cache;
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    70
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    71
  size_t _n_periods;    // Used as clearing epoch
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    72
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    73
  // An evicting cache of the number of times each card
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    74
  // is accessed. Reduces, but does not eliminate, the amount
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    75
  // of duplicated processing of dirty cards.
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    76
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    77
  enum SomePrivateConstants {
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    78
    epoch_bits           = 32,
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    79
    card_num_shift       = epoch_bits,
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    80
    epoch_mask           = AllBits,
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    81
    card_num_mask        = AllBits,
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    82
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    83
    // The initial cache size is approximately this fraction
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    84
    // of a maximal cache (i.e. the size needed for all cards
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    85
    // in the heap)
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    86
    InitialCacheFraction = 512
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    87
  };
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    88
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    89
  const static julong card_num_mask_in_place =
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    90
                        (julong) card_num_mask << card_num_shift;
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    91
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    92
  typedef struct {
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    93
    julong _value;      // |  card_num   |  epoch   |
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    94
  } CardEpochCacheEntry;
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    95
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    96
  julong make_epoch_entry(unsigned int card_num, unsigned int epoch) {
8926
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
    97
    assert(0 <= card_num && card_num < _max_cards, "Bounds");
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    98
    assert(0 <= epoch && epoch <= _n_periods, "must be");
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
    99
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   100
    return ((julong) card_num << card_num_shift) | epoch;
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   101
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   102
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   103
  unsigned int extract_epoch(julong v) {
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   104
    return (v & epoch_mask);
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   105
  }
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   106
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   107
  unsigned int extract_card_num(julong v) {
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   108
    return (v & card_num_mask_in_place) >> card_num_shift;
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   109
  }
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   110
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   111
  typedef struct {
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   112
    unsigned char _count;
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   113
    unsigned char _evict_count;
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   114
  } CardCountCacheEntry;
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   115
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   116
  CardCountCacheEntry* _card_counts;
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   117
  CardEpochCacheEntry* _card_epochs;
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   118
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   119
  // The current number of buckets in the card count cache
8926
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   120
  size_t _n_card_counts;
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   121
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   122
  // The number of cards for the entire reserved heap
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   123
  size_t _max_cards;
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   124
8926
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   125
  // The max number of buckets for the card counts and epochs caches.
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   126
  // This is the maximum that the counts and epochs will grow to.
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   127
  // It is specified as a fraction or percentage of _max_cards using
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   128
  // G1MaxHotCardCountSizePercent.
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   129
  size_t _max_n_card_counts;
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   130
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   131
  // Possible sizes of the cache: odd primes that roughly double in size.
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   132
  // (See jvmtiTagMap.cpp).
8926
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   133
  enum {
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   134
    MAX_CC_CACHE_INDEX = 15    // maximum index into the cache size array.
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   135
  };
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   136
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   137
  static size_t _cc_cache_sizes[MAX_CC_CACHE_INDEX];
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   138
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   139
  // The index in _cc_cache_sizes corresponding to the size of
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   140
  // _card_counts.
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   141
  int _cache_size_index;
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   142
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   143
  bool _expand_card_counts;
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   144
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   145
  const jbyte* _ct_bot;
3589
abdd970c243d 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 2882
diff changeset
   146
abdd970c243d 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 2882
diff changeset
   147
  jbyte**      _hot_cache;
abdd970c243d 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 2882
diff changeset
   148
  int          _hot_cache_size;
abdd970c243d 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 2882
diff changeset
   149
  int          _n_hot;
abdd970c243d 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 2882
diff changeset
   150
  int          _hot_cache_idx;
abdd970c243d 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 2882
diff changeset
   151
abdd970c243d 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 2882
diff changeset
   152
  int          _hot_cache_par_chunk_size;
abdd970c243d 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 2882
diff changeset
   153
  volatile int _hot_cache_par_claimed_idx;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   154
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   155
  // Needed to workaround 6817995
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   156
  CardTableModRefBS* _ct_bs;
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   157
  G1CollectedHeap*   _g1h;
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   158
8926
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   159
  // Helper routine for expand_card_count_cache().
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   160
  // The arrays used to hold the card counts and the epochs must have
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   161
  // a 1:1 correspondence. Hence they are allocated and freed together.
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   162
  // Returns true if the allocations of both the counts and epochs
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   163
  // were successful; false otherwise.
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   164
  bool allocate_card_count_cache(size_t n,
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   165
                                 CardCountCacheEntry** counts,
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   166
                                 CardEpochCacheEntry** epochs);
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   167
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   168
  // Expands the arrays that hold the card counts and epochs
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   169
  // to the cache size at index. Returns true if the expansion/
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   170
  // allocation was successful; false otherwise.
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   171
  bool expand_card_count_cache(int index);
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   172
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   173
  // hash a given key (index of card_ptr) with the specified size
8926
717a49db1743 7026932: G1: No need to abort VM when card count cache expansion fails
johnc
parents: 7397
diff changeset
   174
  static unsigned int hash(size_t key, size_t size) {
9185
7b717a00a48e 7036021: G1: build failure on win64 and linux with hs21 in jdk6 build environment
johnc
parents: 8926
diff changeset
   175
    return (unsigned int) (key % size);
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   176
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   177
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   178
  // hash a given key (index of card_ptr)
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   179
  unsigned int hash(size_t key) {
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   180
    return hash(key, _n_card_counts);
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   181
  }
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   182
9185
7b717a00a48e 7036021: G1: build failure on win64 and linux with hs21 in jdk6 build environment
johnc
parents: 8926
diff changeset
   183
  unsigned int ptr_2_card_num(jbyte* card_ptr) {
7b717a00a48e 7036021: G1: build failure on win64 and linux with hs21 in jdk6 build environment
johnc
parents: 8926
diff changeset
   184
    return (unsigned int) (card_ptr - _ct_bot);
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   185
  }
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   186
9185
7b717a00a48e 7036021: G1: build failure on win64 and linux with hs21 in jdk6 build environment
johnc
parents: 8926
diff changeset
   187
  jbyte* card_num_2_ptr(unsigned int card_num) {
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   188
    return (jbyte*) (_ct_bot + card_num);
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   189
  }
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   190
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   191
  // Returns the count of this card after incrementing it.
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   192
  jbyte* add_card_count(jbyte* card_ptr, int* count, bool* defer);
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   193
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   194
  // Returns true if this card is in a young region
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   195
  bool is_young_card(jbyte* card_ptr);
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   196
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   197
 public:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   198
  ConcurrentG1Refine();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   199
  ~ConcurrentG1Refine();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   200
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   201
  void init(); // Accomplish some initialization that has to wait.
2881
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2105
diff changeset
   202
  void stop();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   203
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   204
  void reinitialize_threads();
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   205
2881
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2105
diff changeset
   206
  // Iterate over the conc refine threads
74a1337e4acc 6484957: G1: parallel concurrent refinement
iveresov
parents: 2105
diff changeset
   207
  void threads_do(ThreadClosure *tc);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   208
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   209
  // 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
   210
  // returns NULL.  If it causes an eviction, returns the evicted pointer.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   211
  // Otherwise, its a cache hit, and returns NULL.
3590
a268fa66d7fb 6819077: G1: first GC thread coming late into the GC.
johnc
parents: 3589
diff changeset
   212
  jbyte* cache_insert(jbyte* card_ptr, bool* defer);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   213
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   214
  // Process the cached entries.
6247
00e5cc407d03 6814437: G1: remove the _new_refs array
johnc
parents: 5547
diff changeset
   215
  void clean_up_cache(int worker_i, G1RemSet* g1rs, DirtyCardQueue* into_cset_dcq);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   216
3589
abdd970c243d 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 2882
diff changeset
   217
  // Set up for parallel processing of the cards in the hot cache
abdd970c243d 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 2882
diff changeset
   218
  void clear_hot_cache_claimed_index() {
abdd970c243d 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 2882
diff changeset
   219
    _hot_cache_par_claimed_idx = 0;
abdd970c243d 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 2882
diff changeset
   220
  }
abdd970c243d 6865703: G1: Parallelize hot card cache cleanup
johnc
parents: 2882
diff changeset
   221
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   222
  // Discard entries in the hot cache.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   223
  void clear_hot_cache() {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   224
    _hot_cache_idx = 0; _n_hot = 0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   225
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   226
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   227
  bool hot_cache_is_empty() { return _n_hot == 0; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   228
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   229
  bool use_cache() { return _use_cache; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   230
  void set_use_cache(bool b) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   231
    if (b) _use_cache = _def_use_cache;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   232
    else   _use_cache = false;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   233
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   234
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   235
  void clear_and_record_card_counts();
2882
d508a8bac491 6841831: G1: assert(contains_reference(from),"We just added it!") fires
iveresov
parents: 2881
diff changeset
   236
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   237
  static int thread_num();
4022
2ec87d5043f7 6885041: G1: inconsistent thread dump
tonyp
parents: 3590
diff changeset
   238
2ec87d5043f7 6885041: G1: inconsistent thread dump
tonyp
parents: 3590
diff changeset
   239
  void print_worker_threads_on(outputStream* st) const;
4481
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   240
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   241
  void set_green_zone(int x)  { _green_zone = x;  }
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   242
  void set_yellow_zone(int x) { _yellow_zone = x; }
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   243
  void set_red_zone(int x)    { _red_zone = x;    }
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   244
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   245
  int green_zone() const      { return _green_zone;  }
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   246
  int yellow_zone() const     { return _yellow_zone; }
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   247
  int red_zone() const        { return _red_zone;    }
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   248
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   249
  int total_thread_num() const  { return _n_threads;        }
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   250
  int worker_thread_num() const { return _n_worker_threads; }
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   251
de92ec484f5e 6862387: tune concurrent refinement further
iveresov
parents: 4022
diff changeset
   252
  int thread_threshold_step() const { return _thread_threshold_step; }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   253
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6247
diff changeset
   254
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6247
diff changeset
   255
#endif // SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTG1REFINE_HPP