hotspot/src/share/vm/gc/g1/sparsePRT.hpp
author tschatzl
Tue, 10 May 2016 16:40:09 +0200
changeset 38269 d18cab031e64
parent 30764 fec48bf5a827
child 38271 4425ba8ed50f
permissions -rw-r--r--
8155721: Sparse remset wastes half of entry memory Summary: Only allocate as much SparsePRTEntry memory as required, not for the theoretical maximum. Reviewed-by: mgerdin, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     1
/*
38269
d18cab031e64 8155721: Sparse remset wastes half of entry memory
tschatzl
parents: 30764
diff changeset
     2
 * Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     4
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     8
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    13
 * accompanied this code).
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    14
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4902
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4902
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4902
diff changeset
    21
 * questions.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    22
 *
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    23
 */
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    24
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 24464
diff changeset
    25
#ifndef SHARE_VM_GC_G1_SPARSEPRT_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 24464
diff changeset
    26
#define SHARE_VM_GC_G1_SPARSEPRT_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    27
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 24464
diff changeset
    28
#include "gc/g1/g1CollectedHeap.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 24464
diff changeset
    29
#include "gc/g1/heapRegion.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 24464
diff changeset
    30
#include "gc/shared/cardTableModRefBS.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    31
#include "memory/allocation.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    32
#include "runtime/mutex.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    33
#include "utilities/globalDefinitions.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    34
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    35
// Sparse remembered set for a heap region (the "owning" region).  Maps
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    36
// indices of other regions to short sequences of cards in the other region
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    37
// that might contain pointers into the owner region.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    38
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    39
// These tables only expand while they are accessed in parallel --
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    40
// deletions may be done in single-threaded code.  This allows us to allow
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    41
// unsynchronized reads/iterations, as long as expansions caused by
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    42
// insertions only enqueue old versions for deletions, but do not delete
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    43
// old versions synchronously.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    44
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8072
diff changeset
    45
class SparsePRTEntry: public CHeapObj<mtGC> {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    46
public:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    47
  enum SomePublicConstants {
4902
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
    48
    NullEntry     = -1,
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
    49
    UnrollFactor  =  4
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    50
  };
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    51
private:
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
    52
  RegionIdx_t _region_ind;
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
    53
  int         _next_index;
4902
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
    54
  CardIdx_t   _cards[1];
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
    55
  // WARNING: Don't put any data members beyond this line. Card array has, in fact, variable length.
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
    56
  // It should always be the last data member.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    57
public:
4902
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
    58
  // Returns the size of the entry, used for entry allocation.
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
    59
  static size_t size() { return sizeof(SparsePRTEntry) + sizeof(CardIdx_t) * (cards_num() - 1); }
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
    60
  // Returns the size of the card array.
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
    61
  static int cards_num() {
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
    62
    // The number of cards should be a multiple of 4, because that's our current
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
    63
    // unrolling factor.
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
    64
    static const int s = MAX2<int>(G1RSetSparseRegionEntries & ~(UnrollFactor - 1), UnrollFactor);
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
    65
    return s;
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
    66
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    67
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    68
  // Set the region_ind to the given value, and delete all cards.
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
    69
  inline void init(RegionIdx_t region_ind);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    70
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
    71
  RegionIdx_t r_ind() const { return _region_ind; }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    72
  bool valid_entry() const { return r_ind() >= 0; }
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
    73
  void set_r_ind(RegionIdx_t rind) { _region_ind = rind; }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    74
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
    75
  int next_index() const { return _next_index; }
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
    76
  int* next_index_addr() { return &_next_index; }
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
    77
  void set_next_index(int ni) { _next_index = ni; }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    78
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    79
  // Returns "true" iff the entry contains the given card index.
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
    80
  inline bool contains_card(CardIdx_t card_index) const;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    81
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    82
  // Returns the number of non-NULL card entries.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    83
  inline int num_valid_cards() const;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    84
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    85
  // Requires that the entry not contain the given card index.  If there is
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    86
  // space available, add the given card index to the entry and return
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    87
  // "true"; otherwise, return "false" to indicate that the entry is full.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    88
  enum AddCardResult {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    89
    overflow,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    90
    found,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    91
    added
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    92
  };
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
    93
  inline AddCardResult add_card(CardIdx_t card_index);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    94
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    95
  // Copy the current entry's cards into "cards".
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
    96
  inline void copy_cards(CardIdx_t* cards) const;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    97
  // Copy the current entry's cards into the "_card" array of "e."
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    98
  inline void copy_cards(SparsePRTEntry* e) const;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    99
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   100
  inline CardIdx_t card(int i) const { return _cards[i]; }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   101
};
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   102
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   103
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 8072
diff changeset
   104
class RSHashTable : public CHeapObj<mtGC> {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   105
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   106
  friend class RSHashTableIter;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   107
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   108
  enum SomePrivateConstants {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   109
    NullEntry = -1
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   110
  };
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   111
38269
d18cab031e64 8155721: Sparse remset wastes half of entry memory
tschatzl
parents: 30764
diff changeset
   112
  // Inverse maximum hash table occupancy used.
d18cab031e64 8155721: Sparse remset wastes half of entry memory
tschatzl
parents: 30764
diff changeset
   113
  static float TableOccupancyFactor;
d18cab031e64 8155721: Sparse remset wastes half of entry memory
tschatzl
parents: 30764
diff changeset
   114
d18cab031e64 8155721: Sparse remset wastes half of entry memory
tschatzl
parents: 30764
diff changeset
   115
  size_t _num_entries;
d18cab031e64 8155721: Sparse remset wastes half of entry memory
tschatzl
parents: 30764
diff changeset
   116
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   117
  size_t _capacity;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   118
  size_t _capacity_mask;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   119
  size_t _occupied_entries;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   120
  size_t _occupied_cards;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   121
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   122
  SparsePRTEntry* _entries;
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   123
  int* _buckets;
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   124
  int  _free_region;
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   125
  int  _free_list;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   126
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   127
  // Requires that the caller hold a lock preventing parallel modifying
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   128
  // operations, and that the the table be less than completely full.  If
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   129
  // an entry for "region_ind" is already in the table, finds it and
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   130
  // returns its address; otherwise allocates, initializes, inserts and
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   131
  // returns a new entry for "region_ind".
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   132
  SparsePRTEntry* entry_for_region_ind_create(RegionIdx_t region_ind);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   133
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   134
  // Returns the index of the next free entry in "_entries".
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   135
  int alloc_entry();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   136
  // Declares the entry "fi" to be free.  (It must have already been
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   137
  // deleted from any bucket lists.
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   138
  void free_entry(int fi);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   139
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   140
public:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   141
  RSHashTable(size_t capacity);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   142
  ~RSHashTable();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   143
38269
d18cab031e64 8155721: Sparse remset wastes half of entry memory
tschatzl
parents: 30764
diff changeset
   144
  bool should_expand() const { return _occupied_entries == _num_entries; }
d18cab031e64 8155721: Sparse remset wastes half of entry memory
tschatzl
parents: 30764
diff changeset
   145
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   146
  // Attempts to ensure that the given card_index in the given region is in
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   147
  // the sparse table.  If successful (because the card was already
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 22234
diff changeset
   148
  // present, or because it was successfully added) returns "true".
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   149
  // Otherwise, returns "false" to indicate that the addition would
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   150
  // overflow the entry for the region.  The caller must transfer these
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   151
  // entries to a larger-capacity representation.
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   152
  bool add_card(RegionIdx_t region_id, CardIdx_t card_index);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   153
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   154
  bool get_cards(RegionIdx_t region_id, CardIdx_t* cards);
4902
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
   155
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   156
  bool delete_entry(RegionIdx_t region_id);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   157
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   158
  bool contains_card(RegionIdx_t region_id, CardIdx_t card_index) const;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   159
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   160
  void add_entry(SparsePRTEntry* e);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   161
24464
901aa0dcba08 8042474: Clean up duplicated code in RSHashTable
brutisso
parents: 23543
diff changeset
   162
  SparsePRTEntry* get_entry(RegionIdx_t region_id) const;
4902
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
   163
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   164
  void clear();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   165
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   166
  size_t capacity() const      { return _capacity;       }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   167
  size_t capacity_mask() const { return _capacity_mask;  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   168
  size_t occupied_entries() const { return _occupied_entries; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   169
  size_t occupied_cards() const   { return _occupied_cards;   }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   170
  size_t mem_size() const;
38269
d18cab031e64 8155721: Sparse remset wastes half of entry memory
tschatzl
parents: 30764
diff changeset
   171
  // The number of SparsePRTEntry instances available.
d18cab031e64 8155721: Sparse remset wastes half of entry memory
tschatzl
parents: 30764
diff changeset
   172
  size_t num_entries() const { return _num_entries; }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   173
38269
d18cab031e64 8155721: Sparse remset wastes half of entry memory
tschatzl
parents: 30764
diff changeset
   174
  SparsePRTEntry* entry(int i) const {
d18cab031e64 8155721: Sparse remset wastes half of entry memory
tschatzl
parents: 30764
diff changeset
   175
    assert(i >= 0 && (size_t)i < _num_entries, "precondition");
d18cab031e64 8155721: Sparse remset wastes half of entry memory
tschatzl
parents: 30764
diff changeset
   176
    return (SparsePRTEntry*)((char*)_entries + SparsePRTEntry::size() * i);
d18cab031e64 8155721: Sparse remset wastes half of entry memory
tschatzl
parents: 30764
diff changeset
   177
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   178
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   179
  void print();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   180
};
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   181
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   182
// ValueObj because will be embedded in HRRS iterator.
2013
49e915da0905 6700941: G1: allocation spec missing for some G1 classes
apetrusenko
parents: 1374
diff changeset
   183
class RSHashTableIter VALUE_OBJ_CLASS_SPEC {
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   184
  int _tbl_ind;         // [-1, 0.._rsht->_capacity)
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   185
  int _bl_ind;          // [-1, 0.._rsht->_capacity)
4902
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
   186
  short _card_ind;      // [0..SparsePRTEntry::cards_num())
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   187
  RSHashTable* _rsht;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   188
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   189
  // If the bucket list pointed to by _bl_ind contains a card, sets
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   190
  // _bl_ind to the index of that entry, and returns the card.
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   191
  // Otherwise, returns SparseEntry::NullEntry.
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   192
  CardIdx_t find_first_card_in_list();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   193
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   194
  // Computes the proper card index for the card whose offset in the
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   195
  // current region (as indicated by _bl_ind) is "ci".
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   196
  // This is subject to errors when there is iteration concurrent with
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   197
  // modification, but these errors should be benign.
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   198
  size_t compute_card_ind(CardIdx_t ci);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   199
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   200
public:
17108
cf72dcf9a8f2 8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents: 13963
diff changeset
   201
  RSHashTableIter(RSHashTable* rsht) :
cf72dcf9a8f2 8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents: 13963
diff changeset
   202
    _tbl_ind(RSHashTable::NullEntry), // So that first increment gets to 0.
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   203
    _bl_ind(RSHashTable::NullEntry),
4902
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
   204
    _card_ind((SparsePRTEntry::cards_num() - 1)),
17108
cf72dcf9a8f2 8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents: 13963
diff changeset
   205
    _rsht(rsht) {}
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   206
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   207
  bool has_next(size_t& card_index);
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   208
};
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   209
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 22234
diff changeset
   210
// Concurrent access to a SparsePRT must be serialized by some external mutex.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   211
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   212
class SparsePRTIter;
8072
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   213
class SparsePRTCleanupTask;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   214
2013
49e915da0905 6700941: G1: allocation spec missing for some G1 classes
apetrusenko
parents: 1374
diff changeset
   215
class SparsePRT VALUE_OBJ_CLASS_SPEC {
8072
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   216
  friend class SparsePRTCleanupTask;
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   217
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   218
  //  Iterations are done on the _cur hash table, since they only need to
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   219
  //  see entries visible at the start of a collection pause.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   220
  //  All other operations are done using the _next hash table.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   221
  RSHashTable* _cur;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   222
  RSHashTable* _next;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   223
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   224
  HeapRegion* _hr;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   225
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   226
  enum SomeAdditionalPrivateConstants {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   227
    InitialCapacity = 16
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   228
  };
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   229
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   230
  void expand();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   231
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   232
  bool _expanded;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   233
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   234
  bool expanded() { return _expanded; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   235
  void set_expanded(bool b) { _expanded = b; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   236
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   237
  SparsePRT* _next_expanded;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   238
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   239
  SparsePRT* next_expanded() { return _next_expanded; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   240
  void set_next_expanded(SparsePRT* nxt) { _next_expanded = nxt; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   241
8072
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   242
  bool should_be_on_expanded_list();
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   243
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   244
  static SparsePRT* _head_expanded_list;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   245
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   246
public:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   247
  SparsePRT(HeapRegion* hr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   248
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   249
  ~SparsePRT();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   250
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   251
  size_t occupied() const { return _next->occupied_cards(); }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   252
  size_t mem_size() const;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   253
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   254
  // Attempts to ensure that the given card_index in the given region is in
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   255
  // the sparse table.  If successful (because the card was already
22551
9bf46d16dcc6 8025856: Fix typos in the GC code
jwilhelm
parents: 22234
diff changeset
   256
  // present, or because it was successfully added) returns "true".
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   257
  // Otherwise, returns "false" to indicate that the addition would
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   258
  // overflow the entry for the region.  The caller must transfer these
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   259
  // entries to a larger-capacity representation.
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   260
  bool add_card(RegionIdx_t region_id, CardIdx_t card_index);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   261
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   262
  // If the table hold an entry for "region_ind",  Copies its
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   263
  // cards into "cards", which must be an array of length at least
4902
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
   264
  // "SparePRTEntry::cards_num()", and returns "true"; otherwise,
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
   265
  // returns "false".
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   266
  bool get_cards(RegionIdx_t region_ind, CardIdx_t* cards);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   267
4902
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
   268
  // Return the pointer to the entry associated with the given region.
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
   269
  SparsePRTEntry* get_entry(RegionIdx_t region_ind);
991aaddb5165 6923991: G1: improve scalability of RSet scanning
iveresov
parents: 4100
diff changeset
   270
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   271
  // If there is an entry for "region_ind", removes it and return "true";
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   272
  // otherwise returns "false."
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   273
  bool delete_entry(RegionIdx_t region_ind);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   274
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   275
  // Clear the table, and reinitialize to initial capacity.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   276
  void clear();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   277
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   278
  // Ensure that "_cur" and "_next" point to the same table.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   279
  void cleanup();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   280
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   281
  // Clean up all tables on the expanded list.  Called single threaded.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   282
  static void cleanup_all();
2143
61babb9fbd6f 6810698: G1: two small bugs in the sparse remembered sets
tonyp
parents: 2013
diff changeset
   283
  RSHashTable* cur() const { return _cur; }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   284
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   285
  static void add_to_expanded_list(SparsePRT* sprt);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   286
  static SparsePRT* get_from_expanded_list();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   287
8072
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   288
  // The purpose of these three methods is to help the GC workers
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   289
  // during the cleanup pause to recreate the expanded list, purging
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   290
  // any tables from it that belong to regions that are freed during
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   291
  // cleanup (if we don't purge those tables, there is a race that
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   292
  // causes various crashes; see CR 7014261).
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   293
  //
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   294
  // We chose to recreate the expanded list, instead of purging
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   295
  // entries from it by iterating over it, to avoid this serial phase
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   296
  // at the end of the cleanup pause.
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   297
  //
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   298
  // The three methods below work as follows:
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   299
  // * reset_for_cleanup_tasks() : Nulls the expanded list head at the
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   300
  //   start of the cleanup pause.
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   301
  // * do_cleanup_work() : Called by the cleanup workers for every
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   302
  //   region that is not free / is being freed by the cleanup
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   303
  //   pause. It creates a list of expanded tables whose head / tail
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   304
  //   are on the thread-local SparsePRTCleanupTask object.
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   305
  // * finish_cleanup_task() : Called by the cleanup workers after
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   306
  //   they complete their cleanup task. It adds the local list into
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   307
  //   the global expanded list. It assumes that the
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   308
  //   ParGCRareEvent_lock is being held to ensure MT-safety.
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   309
  static void reset_for_cleanup_tasks();
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   310
  void do_cleanup_work(SparsePRTCleanupTask* sprt_cleanup_task);
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   311
  static void finish_cleanup_task(SparsePRTCleanupTask* sprt_cleanup_task);
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   312
2996
1097030e5ec3 6843694: G1: assert(index < _vs.committed_size(),"bad index"), g1BlockOffsetTable.inline.hpp:55
johnc
parents: 2154
diff changeset
   313
  bool contains_card(RegionIdx_t region_id, CardIdx_t card_index) const {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   314
    return _next->contains_card(region_id, card_index);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   315
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   316
};
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   317
6981
ecfe524b1fa7 6992189: G1: inconsistent base used in sparse rem set iterator
tonyp
parents: 5547
diff changeset
   318
class SparsePRTIter: public RSHashTableIter {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   319
public:
17108
cf72dcf9a8f2 8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents: 13963
diff changeset
   320
  SparsePRTIter(const SparsePRT* sprt) :
cf72dcf9a8f2 8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents: 13963
diff changeset
   321
    RSHashTableIter(sprt->cur()) {}
cf72dcf9a8f2 8011724: G1: Stack allocate instances of HeapRegionRemSetIterator
johnc
parents: 13963
diff changeset
   322
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   323
  bool has_next(size_t& card_index) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   324
    return RSHashTableIter::has_next(card_index);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   325
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   326
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
   327
8072
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   328
// This allows each worker during a cleanup pause to create a
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   329
// thread-local list of sparse tables that have been expanded and need
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   330
// to be processed at the beginning of the next GC pause. This lists
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   331
// are concatenated into the single expanded list at the end of the
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   332
// cleanup pause.
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   333
class SparsePRTCleanupTask VALUE_OBJ_CLASS_SPEC {
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   334
private:
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   335
  SparsePRT* _head;
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   336
  SparsePRT* _tail;
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   337
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   338
public:
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   339
  SparsePRTCleanupTask() : _head(NULL), _tail(NULL) { }
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   340
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   341
  void add(SparsePRT* sprt);
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   342
  SparsePRT* head() { return _head; }
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   343
  SparsePRT* tail() { return _tail; }
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   344
};
f223f43cd62f 7014261: G1: RSet-related failures
tonyp
parents: 7397
diff changeset
   345
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 24464
diff changeset
   346
#endif // SHARE_VM_GC_G1_SPARSEPRT_HPP