Path: blob/master/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.hpp
40957 views
/*1* Copyright (c) 2016, 2020, Red Hat, Inc. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_GC_SHENANDOAH_SHENANDOAHCOLLECTIONSET_HPP25#define SHARE_GC_SHENANDOAH_SHENANDOAHCOLLECTIONSET_HPP2627#include "memory/allocation.hpp"28#include "memory/virtualspace.hpp"29#include "gc/shenandoah/shenandoahHeap.hpp"30#include "gc/shenandoah/shenandoahHeapRegion.hpp"31#include "gc/shenandoah/shenandoahPadding.hpp"3233class ShenandoahCollectionSet : public CHeapObj<mtGC> {34friend class ShenandoahHeap;35private:36size_t const _map_size;37size_t const _region_size_bytes_shift;38ReservedSpace _map_space;39char* const _cset_map;40// Bias cset map's base address for fast test if an oop is in cset41char* const _biased_cset_map;4243ShenandoahHeap* const _heap;4445size_t _garbage;46size_t _used;47size_t _region_count;4849shenandoah_padding(0);50volatile size_t _current_index;51shenandoah_padding(1);5253public:54ShenandoahCollectionSet(ShenandoahHeap* heap, ReservedSpace space, char* heap_base);5556// Add region to collection set57void add_region(ShenandoahHeapRegion* r);5859// MT version60ShenandoahHeapRegion* claim_next();6162// Single-thread version63ShenandoahHeapRegion* next();6465size_t count() const { return _region_count; }66bool is_empty() const { return _region_count == 0; }6768void clear_current_index() {69_current_index = 0;70}7172inline bool is_in(ShenandoahHeapRegion* r) const;73inline bool is_in(size_t region_idx) const;74inline bool is_in(oop obj) const;75inline bool is_in_loc(void* loc) const;7677void print_on(outputStream* out) const;7879size_t used() const { return _used; }80size_t garbage() const { return _garbage; }81void clear();8283private:84char* map_address() const {85return _cset_map;86}87char* biased_map_address() const {88return _biased_cset_map;89}90};9192#endif // SHARE_GC_SHENANDOAH_SHENANDOAHCOLLECTIONSET_HPP939495