ysr@777: /* xdono@1279: * Copyright 2001-2009 Sun Microsystems, Inc. All Rights Reserved. ysr@777: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ysr@777: * ysr@777: * This code is free software; you can redistribute it and/or modify it ysr@777: * under the terms of the GNU General Public License version 2 only, as ysr@777: * published by the Free Software Foundation. ysr@777: * ysr@777: * This code is distributed in the hope that it will be useful, but WITHOUT ysr@777: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ysr@777: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ysr@777: * version 2 for more details (a copy is included in the LICENSE file that ysr@777: * accompanied this code). ysr@777: * ysr@777: * You should have received a copy of the GNU General Public License version ysr@777: * 2 along with this work; if not, write to the Free Software Foundation, ysr@777: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ysr@777: * ysr@777: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, ysr@777: * CA 95054 USA or visit www.sun.com if you need additional information or ysr@777: * have any questions. ysr@777: * ysr@777: */ ysr@777: ysr@777: // The Concurrent ZF Thread. Performs concurrent zero-filling. ysr@777: ysr@777: class ConcurrentZFThread: public ConcurrentGCThread { ysr@777: friend class VMStructs; ysr@777: friend class ZeroFillRegionClosure; ysr@777: ysr@777: private: ysr@777: ysr@777: // Zero fill the heap region. ysr@777: void processHeapRegion(HeapRegion* r); ysr@777: ysr@777: // Stats ysr@777: // Allocation (protected by heap lock). ysr@777: static int _region_allocs; // Number of regions allocated ysr@777: static int _sync_zfs; // Synchronous zero-fills + ysr@777: static int _zf_waits; // Wait for conc zero-fill completion. ysr@777: ysr@777: // Number of regions CFZ thread fills. ysr@777: static int _regions_filled; ysr@777: ysr@777: double _vtime_start; // Initial virtual time. ysr@777: ysr@777: // These are static because the "print_summary_info" method is, and ysr@777: // it currently assumes there is only one ZF thread. We'll change when ysr@777: // we need to. ysr@777: static double _vtime_accum; // Initial virtual time. ysr@777: static double vtime_accum() { return _vtime_accum; } ysr@777: ysr@777: // Offer yield for GC. Returns true if yield occurred. ysr@777: bool offer_yield(); ysr@777: ysr@777: public: ysr@777: // Constructor ysr@777: ConcurrentZFThread(); ysr@777: ysr@777: // Main loop. ysr@777: virtual void run(); ysr@777: ysr@777: // Printing tonyp@1454: void print_on(outputStream* st) const; tonyp@1454: void print() const; ysr@777: ysr@777: // Waits until "r" has been zero-filled. Requires caller to hold the ysr@777: // ZF_mon. ysr@777: static void wait_for_ZF_completed(HeapRegion* r); ysr@777: ysr@777: // Get or clear the current unclean region. Should be done ysr@777: // while holding the ZF_needed_mon lock. ysr@777: ysr@777: // shutdown iveresov@1229: void stop(); ysr@777: ysr@777: // Stats ysr@777: static void note_region_alloc() {_region_allocs++; } ysr@777: static void note_sync_zfs() { _sync_zfs++; } ysr@777: static void note_zf_wait() { _zf_waits++; } ysr@777: static void note_region_filled() { _regions_filled++; } ysr@777: ysr@777: static void print_summary_info(); ysr@777: };