ysr@777: /* xdono@1014: * 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: // Forward decl ysr@777: class ConcurrentG1RefineThread; ysr@777: class G1RemSet; ysr@777: apetrusenko@984: class ConcurrentG1Refine: public CHeapObj { iveresov@1229: ConcurrentG1RefineThread** _threads; iveresov@1229: int _n_threads; ysr@777: ysr@777: // The cache for card refinement. ysr@777: bool _use_cache; ysr@777: bool _def_use_cache; ysr@777: size_t _n_periods; ysr@777: size_t _total_cards; ysr@777: size_t _total_travs; ysr@777: ysr@777: unsigned char* _card_counts; ysr@777: unsigned _n_card_counts; ysr@777: const jbyte* _ct_bot; ysr@777: unsigned* _cur_card_count_histo; ysr@777: unsigned* _cum_card_count_histo; ysr@777: jbyte** _hot_cache; ysr@777: int _hot_cache_size; ysr@777: int _n_hot; ysr@777: int _hot_cache_idx; ysr@777: ysr@777: // Returns the count of this card after incrementing it. ysr@777: int add_card_count(jbyte* card_ptr); ysr@777: ysr@777: void print_card_count_histo_range(unsigned* histo, int from, int to, ysr@777: float& cum_card_pct, ysr@777: float& cum_travs_pct); ysr@777: public: ysr@777: ConcurrentG1Refine(); ysr@777: ~ConcurrentG1Refine(); ysr@777: ysr@777: void init(); // Accomplish some initialization that has to wait. iveresov@1229: void stop(); ysr@777: iveresov@1229: // Iterate over the conc refine threads iveresov@1229: void threads_do(ThreadClosure *tc); ysr@777: ysr@777: // If this is the first entry for the slot, writes into the cache and ysr@777: // returns NULL. If it causes an eviction, returns the evicted pointer. ysr@777: // Otherwise, its a cache hit, and returns NULL. ysr@777: jbyte* cache_insert(jbyte* card_ptr); ysr@777: ysr@777: // Process the cached entries. ysr@777: void clean_up_cache(int worker_i, G1RemSet* g1rs); ysr@777: ysr@777: // Discard entries in the hot cache. ysr@777: void clear_hot_cache() { ysr@777: _hot_cache_idx = 0; _n_hot = 0; ysr@777: } ysr@777: ysr@777: bool hot_cache_is_empty() { return _n_hot == 0; } ysr@777: ysr@777: bool use_cache() { return _use_cache; } ysr@777: void set_use_cache(bool b) { ysr@777: if (b) _use_cache = _def_use_cache; ysr@777: else _use_cache = false; ysr@777: } ysr@777: ysr@777: void clear_and_record_card_counts(); ysr@777: void print_final_card_counts(); ysr@777: };