src/share/vm/jfr/leakprofiler/chains/bitset.hpp

Wed, 09 Oct 2019 16:11:58 +0800

author
ddong
date
Wed, 09 Oct 2019 16:11:58 +0800
changeset 9885
8e875c964f41
parent 9858
b985cbb00e68
permissions
-rw-r--r--

8214542: JFR: Old Object Sample event slow on a deep heap in debug builds
Reviewed-by: egahlin, rwestberg

apetushkov@9858 1 /*
apetushkov@9858 2 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
apetushkov@9858 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
apetushkov@9858 4 *
apetushkov@9858 5 * This code is free software; you can redistribute it and/or modify it
apetushkov@9858 6 * under the terms of the GNU General Public License version 2 only, as
apetushkov@9858 7 * published by the Free Software Foundation.
apetushkov@9858 8 *
apetushkov@9858 9 * This code is distributed in the hope that it will be useful, but WITHOUT
apetushkov@9858 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
apetushkov@9858 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
apetushkov@9858 12 * version 2 for more details (a copy is included in the LICENSE file that
apetushkov@9858 13 * accompanied this code).
apetushkov@9858 14 *
apetushkov@9858 15 * You should have received a copy of the GNU General Public License version
apetushkov@9858 16 * 2 along with this work; if not, write to the Free Software Foundation,
apetushkov@9858 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
apetushkov@9858 18 *
apetushkov@9858 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
apetushkov@9858 20 * or visit www.oracle.com if you need additional information or have any
apetushkov@9858 21 * questions.
apetushkov@9858 22 *
apetushkov@9858 23 */
apetushkov@9858 24
apetushkov@9858 25 #ifndef SHARE_VM_JFR_LEAKPROFILER_CHAINS_BITSET_HPP
apetushkov@9858 26 #define SHARE_VM_JFR_LEAKPROFILER_CHAINS_BITSET_HPP
apetushkov@9858 27
apetushkov@9858 28 #include "memory/allocation.hpp"
apetushkov@9858 29 #include "oops/oopsHierarchy.hpp"
apetushkov@9858 30 #include "utilities/bitMap.inline.hpp"
apetushkov@9858 31
apetushkov@9858 32 class JfrVirtualMemory;
apetushkov@9858 33 class MemRegion;
apetushkov@9858 34
apetushkov@9858 35 class BitSet : public CHeapObj<mtTracing> {
apetushkov@9858 36 private:
apetushkov@9858 37 JfrVirtualMemory* _vmm;
apetushkov@9858 38 const HeapWord* const _region_start;
apetushkov@9858 39 BitMap _bits;
apetushkov@9858 40 const size_t _region_size;
apetushkov@9858 41
apetushkov@9858 42 public:
apetushkov@9858 43 BitSet(const MemRegion& covered_region);
apetushkov@9858 44 ~BitSet();
apetushkov@9858 45
apetushkov@9858 46 bool initialize();
apetushkov@9858 47
apetushkov@9858 48 BitMap::idx_t mark_obj(const HeapWord* addr) {
apetushkov@9858 49 const BitMap::idx_t bit = addr_to_bit(addr);
ddong@9885 50 _bits.set_bit(bit);
apetushkov@9858 51 return bit;
apetushkov@9858 52 }
apetushkov@9858 53
apetushkov@9858 54 BitMap::idx_t mark_obj(oop obj) {
apetushkov@9858 55 return mark_obj((HeapWord*)obj);
apetushkov@9858 56 }
apetushkov@9858 57
apetushkov@9858 58 bool is_marked(const HeapWord* addr) const {
apetushkov@9858 59 return is_marked(addr_to_bit(addr));
apetushkov@9858 60 }
apetushkov@9858 61
apetushkov@9858 62 bool is_marked(oop obj) const {
apetushkov@9858 63 return is_marked((HeapWord*)obj);
apetushkov@9858 64 }
apetushkov@9858 65
apetushkov@9858 66 BitMap::idx_t size() const {
apetushkov@9858 67 return _bits.size();
apetushkov@9858 68 }
apetushkov@9858 69
apetushkov@9858 70 BitMap::idx_t addr_to_bit(const HeapWord* addr) const {
apetushkov@9858 71 return pointer_delta(addr, _region_start) >> LogMinObjAlignment;
apetushkov@9858 72 }
apetushkov@9858 73
apetushkov@9858 74 bool is_marked(const BitMap::idx_t bit) const {
apetushkov@9858 75 return _bits.at(bit);
apetushkov@9858 76 }
apetushkov@9858 77 };
apetushkov@9858 78
apetushkov@9858 79 #endif // SHARE_VM_JFR_LEAKPROFILER_CHAINS_BITSET_HPP

mercurial