concurrentG1Refine.hpp 3.9 KB
Newer Older
1
/*
2
 * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
19 20 21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
22 23 24
 *
 */

25 26 27
#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTG1REFINE_HPP
#define SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTG1REFINE_HPP

28
#include "gc_implementation/g1/g1HotCardCache.hpp"
29 30 31 32
#include "memory/allocation.hpp"
#include "runtime/thread.hpp"
#include "utilities/globalDefinitions.hpp"

33 34
// Forward decl
class ConcurrentG1RefineThread;
35 36
class G1CollectedHeap;
class G1HotCardCache;
37
class G1RemSet;
38
class DirtyCardQueue;
39

Z
zgu 已提交
40
class ConcurrentG1Refine: public CHeapObj<mtGC> {
41
  ConcurrentG1RefineThread** _threads;
42 43
  uint _n_threads;
  uint _n_worker_threads;
44 45 46 47 48 49 50 51 52
 /*
  * The value of the update buffer queue length falls into one of 3 zones:
  * green, yellow, red. If the value is in [0, green) nothing is
  * done, the buffers are left unprocessed to enable the caching effect of the
  * dirtied cards. In the yellow zone [green, yellow) the concurrent refinement
  * threads are gradually activated. In [yellow, red) all threads are
  * running. If the length becomes red (max queue length) the mutators start
  * processing the buffers.
  *
53 54
  * There are some interesting cases (when G1UseAdaptiveConcRefinement
  * is turned off):
55 56 57 58 59 60 61 62 63 64 65 66
  * 1) green = yellow = red = 0. In this case the mutator will process all
  *    buffers. Except for those that are created by the deferred updates
  *    machinery during a collection.
  * 2) green = 0. Means no caching. Can be a good way to minimize the
  *    amount of time spent updating rsets during a collection.
  */
  int _green_zone;
  int _yellow_zone;
  int _red_zone;

  int _thread_threshold_step;

67 68 69
  // We delay the refinement of 'hot' cards using the hot card cache.
  G1HotCardCache _hot_card_cache;

70 71
  // Reset the threshold step value based of the current zone boundaries.
  void reset_threshold_step();
72

73
 public:
74
  ConcurrentG1Refine(G1CollectedHeap* g1h);
75 76 77
  ~ConcurrentG1Refine();

  void init(); // Accomplish some initialization that has to wait.
78
  void stop();
79

80 81
  void reinitialize_threads();

82
  // Iterate over all concurrent refinement threads
83
  void threads_do(ThreadClosure *tc);
84

85 86 87 88 89 90
  // Iterate over all worker refinement threads
  void worker_threads_do(ThreadClosure * tc);

  // The RS sampling thread
  ConcurrentG1RefineThread * sampling_thread() const;

91
  static uint thread_num();
T
tonyp 已提交
92 93

  void print_worker_threads_on(outputStream* st) const;
94 95 96 97 98 99 100 101 102

  void set_green_zone(int x)  { _green_zone = x;  }
  void set_yellow_zone(int x) { _yellow_zone = x; }
  void set_red_zone(int x)    { _red_zone = x;    }

  int green_zone() const      { return _green_zone;  }
  int yellow_zone() const     { return _yellow_zone; }
  int red_zone() const        { return _red_zone;    }

103 104
  uint total_thread_num() const  { return _n_threads;        }
  uint worker_thread_num() const { return _n_worker_threads; }
105 106

  int thread_threshold_step() const { return _thread_threshold_step; }
107 108

  G1HotCardCache* hot_card_cache() { return &_hot_card_cache; }
109
};
110 111

#endif // SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTG1REFINE_HPP