342N/A/*
4539N/A * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
342N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
342N/A *
342N/A * This code is free software; you can redistribute it and/or modify it
342N/A * under the terms of the GNU General Public License version 2 only, as
342N/A * published by the Free Software Foundation.
342N/A *
342N/A * This code is distributed in the hope that it will be useful, but WITHOUT
342N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
342N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
342N/A * version 2 for more details (a copy is included in the LICENSE file that
342N/A * accompanied this code).
342N/A *
342N/A * You should have received a copy of the GNU General Public License version
342N/A * 2 along with this work; if not, write to the Free Software Foundation,
342N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
342N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
342N/A *
342N/A */
342N/A
1879N/A#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTG1REFINE_HPP
1879N/A#define SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTG1REFINE_HPP
1879N/A
4539N/A#include "gc_implementation/g1/g1HotCardCache.hpp"
1879N/A#include "memory/allocation.hpp"
1879N/A#include "runtime/thread.hpp"
1879N/A#include "utilities/globalDefinitions.hpp"
1879N/A
342N/A// Forward decl
342N/Aclass ConcurrentG1RefineThread;
4539N/Aclass G1CollectedHeap;
4539N/Aclass G1HotCardCache;
342N/Aclass G1RemSet;
342N/A
3863N/Aclass ConcurrentG1Refine: public CHeapObj<mtGC> {
794N/A ConcurrentG1RefineThread** _threads;
794N/A int _n_threads;
1111N/A int _n_worker_threads;
1111N/A /*
1111N/A * The value of the update buffer queue length falls into one of 3 zones:
1111N/A * green, yellow, red. If the value is in [0, green) nothing is
1111N/A * done, the buffers are left unprocessed to enable the caching effect of the
1111N/A * dirtied cards. In the yellow zone [green, yellow) the concurrent refinement
1111N/A * threads are gradually activated. In [yellow, red) all threads are
1111N/A * running. If the length becomes red (max queue length) the mutators start
1111N/A * processing the buffers.
1111N/A *
1282N/A * There are some interesting cases (when G1UseAdaptiveConcRefinement
1282N/A * is turned off):
1111N/A * 1) green = yellow = red = 0. In this case the mutator will process all
1111N/A * buffers. Except for those that are created by the deferred updates
1111N/A * machinery during a collection.
1111N/A * 2) green = 0. Means no caching. Can be a good way to minimize the
1111N/A * amount of time spent updating rsets during a collection.
1111N/A */
1111N/A int _green_zone;
1111N/A int _yellow_zone;
1111N/A int _red_zone;
1111N/A
1111N/A int _thread_threshold_step;
1111N/A
4539N/A // We delay the refinement of 'hot' cards using the hot card cache.
4539N/A G1HotCardCache _hot_card_cache;
4539N/A
1111N/A // Reset the threshold step value based of the current zone boundaries.
1111N/A void reset_threshold_step();
890N/A
342N/A public:
4539N/A ConcurrentG1Refine(G1CollectedHeap* g1h);
342N/A ~ConcurrentG1Refine();
342N/A
342N/A void init(); // Accomplish some initialization that has to wait.
794N/A void stop();
342N/A
1111N/A void reinitialize_threads();
1111N/A
794N/A // Iterate over the conc refine threads
794N/A void threads_do(ThreadClosure *tc);
342N/A
1111N/A static int thread_num();
1019N/A
1019N/A void print_worker_threads_on(outputStream* st) const;
1111N/A
1111N/A void set_green_zone(int x) { _green_zone = x; }
1111N/A void set_yellow_zone(int x) { _yellow_zone = x; }
1111N/A void set_red_zone(int x) { _red_zone = x; }
1111N/A
1111N/A int green_zone() const { return _green_zone; }
1111N/A int yellow_zone() const { return _yellow_zone; }
1111N/A int red_zone() const { return _red_zone; }
1111N/A
1111N/A int total_thread_num() const { return _n_threads; }
1111N/A int worker_thread_num() const { return _n_worker_threads; }
1111N/A
1111N/A int thread_threshold_step() const { return _thread_threshold_step; }
4539N/A
4539N/A G1HotCardCache* hot_card_cache() { return &_hot_card_cache; }
342N/A};
1879N/A
1879N/A#endif // SHARE_VM_GC_IMPLEMENTATION_G1_CONCURRENTG1REFINE_HPP