src/hotspot/share/gc/g1/g1CodeCacheRemSet.hpp
author tschatzl
Wed, 17 Jul 2019 16:33:19 +0200
changeset 55722 5ee183a90e65
parent 53244 9807daeb47c4
permissions -rw-r--r--
8227084: Add timing information for merge heap root preparation Reviewed-by: sangheki, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 49392
diff changeset
     2
 * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
     4
 *
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
     8
 *
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    14
 *
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    18
 *
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    21
 * questions.
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    22
 *
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    23
 */
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    24
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 49392
diff changeset
    25
#ifndef SHARE_GC_G1_G1CODECACHEREMSET_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 49392
diff changeset
    26
#define SHARE_GC_G1_G1CODECACHEREMSET_HPP
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    27
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    28
class CodeBlobClosure;
40905
94ffc131534f 8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents: 30764
diff changeset
    29
class G1CodeRootSetTable;
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    30
class HeapRegion;
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    31
class nmethod;
24099
9c132a88935d 8038930: G1CodeRootSet::test fails with assert(_num_chunks_handed_out == 0) failed: No elements must have been handed out yet
tschatzl
parents: 23451
diff changeset
    32
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    33
// Implements storage for a set of code roots.
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    34
// All methods that modify the set are not thread-safe except if otherwise noted.
49392
2956d0ece7a9 8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents: 47216
diff changeset
    35
class G1CodeRootSet {
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    36
  friend class G1CodeRootSetTest;
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    37
 private:
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    38
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    39
  const static size_t SmallSize = 32;
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    40
  const static size_t Threshold = 24;
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    41
  const static size_t LargeSize = 512;
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    42
40905
94ffc131534f 8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents: 30764
diff changeset
    43
  G1CodeRootSetTable* _table;
94ffc131534f 8164230: Convert TestCodeCacheRemSet_test to GTest
kzhaldyb
parents: 30764
diff changeset
    44
  G1CodeRootSetTable* load_acquire_table();
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    45
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    46
  size_t _length;
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    47
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    48
  void move_to_large();
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    49
  void allocate_small_table();
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    50
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    51
 public:
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    52
  G1CodeRootSet() : _table(NULL), _length(0) {}
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    53
  ~G1CodeRootSet();
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    54
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    55
  static void purge();
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    56
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    57
  static size_t static_mem_size();
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    58
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    59
  void add(nmethod* method);
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    60
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    61
  bool remove(nmethod* method);
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    62
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    63
  // Safe to call without synchronization, but may return false negatives.
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    64
  bool contains(nmethod* method);
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    65
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    66
  void clear();
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    67
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    68
  void nmethods_do(CodeBlobClosure* blk) const;
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    69
26422
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    70
  // Remove all nmethods which no longer contain pointers into our "owner" region
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    71
  void clean(HeapRegion* owner);
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    72
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    73
  bool is_empty() {
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    74
    bool empty = length() == 0;
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    75
    assert(empty == (_table == NULL), "is empty only if table is deallocated");
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    76
    return empty;
4ee5901e205e 8048268: G1 Code Root Migration performs poorly
mgerdin
parents: 25492
diff changeset
    77
  }
23451
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    78
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    79
  // Length in elements
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    80
  size_t length() const { return _length; }
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    81
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    82
  // Memory size in bytes taken by this set.
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    83
  size_t mem_size();
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    84
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    85
};
ed2b8bb28fed 8035406: Improve data structure for Code Cache remembered sets
tschatzl
parents:
diff changeset
    86
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 49392
diff changeset
    87
#endif // SHARE_GC_G1_G1CODECACHEREMSET_HPP