1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/gc_implementation/g1/concurrentZFThread.hpp Thu Jun 05 15:57:56 2008 -0700 1.3 @@ -0,0 +1,85 @@ 1.4 +/* 1.5 + * Copyright 2001-2007 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.23 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.24 + * have any questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +// The Concurrent ZF Thread. Performs concurrent zero-filling. 1.29 + 1.30 +class ConcurrentZFThread: public ConcurrentGCThread { 1.31 + friend class VMStructs; 1.32 + friend class ZeroFillRegionClosure; 1.33 + 1.34 + private: 1.35 + 1.36 + // Zero fill the heap region. 1.37 + void processHeapRegion(HeapRegion* r); 1.38 + 1.39 + // Stats 1.40 + // Allocation (protected by heap lock). 1.41 + static int _region_allocs; // Number of regions allocated 1.42 + static int _sync_zfs; // Synchronous zero-fills + 1.43 + static int _zf_waits; // Wait for conc zero-fill completion. 1.44 + 1.45 + // Number of regions CFZ thread fills. 1.46 + static int _regions_filled; 1.47 + 1.48 + COTracker _co_tracker; 1.49 + 1.50 + double _vtime_start; // Initial virtual time. 1.51 + 1.52 + // These are static because the "print_summary_info" method is, and 1.53 + // it currently assumes there is only one ZF thread. We'll change when 1.54 + // we need to. 1.55 + static double _vtime_accum; // Initial virtual time. 1.56 + static double vtime_accum() { return _vtime_accum; } 1.57 + 1.58 + // Offer yield for GC. Returns true if yield occurred. 1.59 + bool offer_yield(); 1.60 + 1.61 + public: 1.62 + // Constructor 1.63 + ConcurrentZFThread(); 1.64 + 1.65 + // Main loop. 1.66 + virtual void run(); 1.67 + 1.68 + // Printing 1.69 + void print(); 1.70 + 1.71 + // Waits until "r" has been zero-filled. Requires caller to hold the 1.72 + // ZF_mon. 1.73 + static void wait_for_ZF_completed(HeapRegion* r); 1.74 + 1.75 + // Get or clear the current unclean region. Should be done 1.76 + // while holding the ZF_needed_mon lock. 1.77 + 1.78 + // shutdown 1.79 + static void stop(); 1.80 + 1.81 + // Stats 1.82 + static void note_region_alloc() {_region_allocs++; } 1.83 + static void note_sync_zfs() { _sync_zfs++; } 1.84 + static void note_zf_wait() { _zf_waits++; } 1.85 + static void note_region_filled() { _regions_filled++; } 1.86 + 1.87 + static void print_summary_info(); 1.88 +};