1 /* |
|
2 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 * or visit www.oracle.com if you need additional information or have any |
|
21 * questions. |
|
22 * |
|
23 */ |
|
24 |
|
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTZFTHREAD_HPP |
|
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTZFTHREAD_HPP |
|
27 |
|
28 #include "gc_implementation/shared/concurrentGCThread.hpp" |
|
29 |
|
30 // The Concurrent ZF Thread. Performs concurrent zero-filling. |
|
31 |
|
32 class ConcurrentZFThread: public ConcurrentGCThread { |
|
33 friend class VMStructs; |
|
34 friend class ZeroFillRegionClosure; |
|
35 |
|
36 private: |
|
37 |
|
38 // Zero fill the heap region. |
|
39 void processHeapRegion(HeapRegion* r); |
|
40 |
|
41 // Stats |
|
42 // Allocation (protected by heap lock). |
|
43 static int _region_allocs; // Number of regions allocated |
|
44 static int _sync_zfs; // Synchronous zero-fills + |
|
45 static int _zf_waits; // Wait for conc zero-fill completion. |
|
46 |
|
47 // Number of regions CFZ thread fills. |
|
48 static int _regions_filled; |
|
49 |
|
50 double _vtime_start; // Initial virtual time. |
|
51 |
|
52 // These are static because the "print_summary_info" method is, and |
|
53 // it currently assumes there is only one ZF thread. We'll change when |
|
54 // we need to. |
|
55 static double _vtime_accum; // Initial virtual time. |
|
56 static double vtime_accum() { return _vtime_accum; } |
|
57 |
|
58 // Offer yield for GC. Returns true if yield occurred. |
|
59 bool offer_yield(); |
|
60 |
|
61 public: |
|
62 // Constructor |
|
63 ConcurrentZFThread(); |
|
64 |
|
65 // Main loop. |
|
66 virtual void run(); |
|
67 |
|
68 // Printing |
|
69 void print_on(outputStream* st) const; |
|
70 void print() const; |
|
71 |
|
72 // Waits until "r" has been zero-filled. Requires caller to hold the |
|
73 // ZF_mon. |
|
74 static void wait_for_ZF_completed(HeapRegion* r); |
|
75 |
|
76 // Get or clear the current unclean region. Should be done |
|
77 // while holding the ZF_needed_mon lock. |
|
78 |
|
79 // shutdown |
|
80 void stop(); |
|
81 |
|
82 // Stats |
|
83 static void note_region_alloc() {_region_allocs++; } |
|
84 static void note_sync_zfs() { _sync_zfs++; } |
|
85 static void note_zf_wait() { _zf_waits++; } |
|
86 static void note_region_filled() { _regions_filled++; } |
|
87 |
|
88 static void print_summary_info(); |
|
89 }; |
|
90 |
|
91 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTZFTHREAD_HPP |
|