Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/shenandoah/shenandoahHeapRegionSet.hpp
38920 views
/*1* Copyright (c) 2013, 2018, Red Hat, Inc. All rights reserved.2*3* This code is free software; you can redistribute it and/or modify it4* under the terms of the GNU General Public License version 2 only, as5* published by the Free Software Foundation.6*7* This code is distributed in the hope that it will be useful, but WITHOUT8* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or9* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License10* version 2 for more details (a copy is included in the LICENSE file that11* accompanied this code).12*13* You should have received a copy of the GNU General Public License version14* 2 along with this work; if not, write to the Free Software Foundation,15* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.16*17* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA18* or visit www.oracle.com if you need additional information or have any19* questions.20*21*/2223#ifndef SHARE_VM_GC_SHENANDOAH_SHENANDOAHHEAPREGIONSET_HPP24#define SHARE_VM_GC_SHENANDOAH_SHENANDOAHHEAPREGIONSET_HPP2526#include "memory/allocation.hpp"27#include "gc_implementation/shenandoah/shenandoahHeap.hpp"28#include "gc_implementation/shenandoah/shenandoahHeapRegion.hpp"29#include "gc_implementation/shenandoah/shenandoahPadding.hpp"3031class ShenandoahHeapRegionSet;3233class ShenandoahHeapRegionSetIterator : public StackObj {34private:35const ShenandoahHeapRegionSet* _set;36ShenandoahHeap* const _heap;3738shenandoah_padding(0);39volatile jint _current_index;40shenandoah_padding(1);4142// No implicit copying: iterators should be passed by reference to capture the state43ShenandoahHeapRegionSetIterator(const ShenandoahHeapRegionSetIterator& that);44ShenandoahHeapRegionSetIterator& operator=(const ShenandoahHeapRegionSetIterator& o);4546public:47ShenandoahHeapRegionSetIterator(const ShenandoahHeapRegionSet* const set);4849// Reset existing iterator to new set50void reset(const ShenandoahHeapRegionSet* const set);5152// MT version53ShenandoahHeapRegion* claim_next();5455// Single-thread version56ShenandoahHeapRegion* next();57};5859class ShenandoahHeapRegionSet : public CHeapObj<mtGC> {60friend class ShenandoahHeap;61private:62ShenandoahHeap* const _heap;63size_t const _map_size;64size_t const _region_size_bytes_shift;65jbyte* const _set_map;66// Bias set map's base address for fast test if an oop is in set67jbyte* const _biased_set_map;68size_t _region_count;6970public:71ShenandoahHeapRegionSet();72~ShenandoahHeapRegionSet();7374// Add region to set75void add_region(ShenandoahHeapRegion* r);76bool add_region_check_for_duplicates(ShenandoahHeapRegion* r);7778// Remove region from set79void remove_region(ShenandoahHeapRegion* r);8081size_t count() const { return _region_count; }82bool is_empty() const { return _region_count == 0; }8384inline bool is_in(ShenandoahHeapRegion* r) const;85inline bool is_in(size_t region_idx) const;86inline bool is_in(oop p) const;8788void print_on(outputStream* out) const;8990void clear();9192private:93jbyte* biased_map_address() const {94return _biased_set_map;95}96};9798#endif //SHARE_VM_GC_SHENANDOAH_SHENANDOAHHEAPREGIONSET_HPP99100101