src/hotspot/share/jfr/leakprofiler/chains/bitset.inline.hpp
author coleenp
Wed, 13 Nov 2019 08:23:23 -0500
changeset 59056 15936b142f86
parent 58014 aba258cd7df8
permissions -rw-r--r--
8233913: Remove implicit conversion from Method* to methodHandle Summary: Fix call sites to use existing THREAD local or pass down THREAD local for shallower callsites. Make linkResolver methods return Method* for caller to handleize if needed. Reviewed-by: iklam, thartmann, hseigel
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
58014
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
     1
/*
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
     4
 *
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
     7
 * published by the Free Software Foundation.
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
     8
 *
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    13
 * accompanied this code).
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    14
 *
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    18
 *
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    21
 * questions.
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    22
 *
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    23
 */
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    24
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    25
#ifndef SHARE_JFR_LEAKPROFILER_CHAINS_BITSET_INLINE_HPP
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    26
#define SHARE_JFR_LEAKPROFILER_CHAINS_BITSET_INLINE_HPP
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    27
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    28
#include "jfr/leakprofiler/chains/bitset.hpp"
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    29
#include "jfr/recorder/storage/jfrVirtualMemory.hpp"
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    30
#include "memory/memRegion.hpp"
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    31
#include "utilities/bitMap.inline.hpp"
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    32
#include "utilities/hashtable.inline.hpp"
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    33
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    34
inline BitSet::BitMapFragmentTable::Entry* BitSet::BitMapFragmentTable::bucket(int i) const {
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    35
  return (Entry*)BasicHashtable<mtTracing>::bucket(i);
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    36
}
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    37
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    38
inline BitSet::BitMapFragmentTable::Entry* BitSet::BitMapFragmentTable::new_entry(unsigned int hash,
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    39
                                                                                  uintptr_t key,
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    40
                                                                                  CHeapBitMap* value) {
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    41
  Entry* entry = (Entry*)BasicHashtable<mtTracing>::new_entry(hash);
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    42
  entry->_key = key;
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    43
  entry->_value = value;
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    44
  return entry;
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    45
}
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    46
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    47
inline void BitSet::BitMapFragmentTable::add(uintptr_t key, CHeapBitMap* value) {
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    48
  unsigned hash = hash_segment(key);
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    49
  Entry* entry = new_entry(hash, key, value);
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    50
  BasicHashtable<mtTracing>::add_entry(hash_to_index(hash), entry);
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    51
}
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    52
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    53
inline CHeapBitMap** BitSet::BitMapFragmentTable::lookup(uintptr_t key) {
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    54
  unsigned hash = hash_segment(key);
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    55
  int index = hash_to_index(hash);
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    56
  for (Entry* e = bucket(index); e != NULL; e = e->next()) {
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    57
    if (e->hash() == hash && e->_key == key) {
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    58
      return &(e->_value);
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    59
    }
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    60
  }
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    61
  return NULL;
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    62
}
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    63
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    64
inline BitMap::idx_t BitSet::addr_to_bit(uintptr_t addr) const {
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    65
  return (addr & _bitmap_granularity_mask) >> LogMinObjAlignmentInBytes;
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    66
}
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    67
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    68
inline CHeapBitMap* BitSet::get_fragment_bits(uintptr_t addr) {
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    69
  uintptr_t granule = addr >> _bitmap_granularity_shift;
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    70
  if (granule == _last_fragment_granule) {
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    71
    return _last_fragment_bits;
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    72
  }
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    73
  CHeapBitMap* bits = NULL;
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    74
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    75
  CHeapBitMap** found = _bitmap_fragments.lookup(granule);
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    76
  if (found != NULL) {
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    77
    bits = *found;
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    78
  } else {
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    79
    BitMapFragment* fragment = new BitMapFragment(granule, _fragment_list);
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    80
    bits = fragment->bits();
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    81
    _fragment_list = fragment;
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    82
    if (_bitmap_fragments.number_of_entries() * 100 / _bitmap_fragments.table_size() > 25) {
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    83
      _bitmap_fragments.resize(_bitmap_fragments.table_size() * 2);
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    84
    }
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    85
    _bitmap_fragments.add(granule, bits);
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    86
  }
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    87
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    88
  _last_fragment_bits = bits;
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    89
  _last_fragment_granule = granule;
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    90
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    91
  return bits;
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    92
}
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    93
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    94
inline void BitSet::mark_obj(uintptr_t addr) {
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    95
  CHeapBitMap* bits = get_fragment_bits(addr);
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    96
  const BitMap::idx_t bit = addr_to_bit(addr);
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    97
  bits->set_bit(bit);
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    98
}
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
    99
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
   100
inline bool BitSet::is_marked(uintptr_t addr) {
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
   101
  CHeapBitMap* bits = get_fragment_bits(addr);
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
   102
  const BitMap::idx_t bit = addr_to_bit(addr);
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
   103
  return bits->at(bit);
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
   104
}
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
   105
aba258cd7df8 8229189: Improve JFR leak profiler tracing to deal with discontiguous heaps
eosterlund
parents:
diff changeset
   106
#endif // SHARE_JFR_LEAKPROFILER_CHAINS_BITSET_INLINE_HPP