src/hotspot/share/gc/g1/g1ConcurrentMarkBitMap.hpp
author tschatzl
Wed, 18 Apr 2018 11:36:48 +0200
changeset 49806 2d62570a615c
parent 49644 50a01910e00a
child 51332 c25572739e7c
permissions -rw-r--r--
8200426: Make G1 code use _g1h members Summary: Consistently use _g1h member names for cached G1CollectedHeap* variables. Reviewed-by: sangheki, sjohanss
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
46751
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
     1
/*
49392
2956d0ece7a9 8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents: 47885
diff changeset
     2
 * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
46751
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
     4
 *
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
     8
 *
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    14
 *
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    18
 *
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    21
 * questions.
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    22
 *
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    23
 */
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    24
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    25
#ifndef SHARE_VM_GC_G1_G1CONCURRENTMARKBITMAP_HPP
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    26
#define SHARE_VM_GC_G1_G1CONCURRENTMARKBITMAP_HPP
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    27
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    28
#include "gc/g1/g1RegionToSpaceMapper.hpp"
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    29
#include "memory/memRegion.hpp"
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
    30
#include "oops/oopsHierarchy.hpp"
46751
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    31
#include "utilities/bitMap.hpp"
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    32
#include "utilities/globalDefinitions.hpp"
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    33
#include "utilities/macros.hpp"
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    34
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    35
class G1CMBitMap;
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    36
class G1CMTask;
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    37
class G1ConcurrentMark;
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
    38
class HeapRegion;
46751
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    39
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    40
// Closure for iteration over bitmaps
49392
2956d0ece7a9 8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents: 47885
diff changeset
    41
class G1CMBitMapClosure {
46751
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    42
  G1ConcurrentMark* const _cm;
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    43
  G1CMTask* const _task;
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    44
public:
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    45
  G1CMBitMapClosure(G1CMTask *task, G1ConcurrentMark* cm) : _task(task), _cm(cm) { }
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    46
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    47
  bool do_addr(HeapWord* const addr);
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    48
};
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    49
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    50
class G1CMBitMapMappingChangedListener : public G1MappingChangedListener {
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    51
  G1CMBitMap* _bm;
49644
50a01910e00a 8151171: Bring g1ConcurrentMark files up to current coding conventions
tschatzl
parents: 49392
diff changeset
    52
public:
46751
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    53
  G1CMBitMapMappingChangedListener() : _bm(NULL) {}
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    54
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    55
  void set_bitmap(G1CMBitMap* bm) { _bm = bm; }
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    56
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    57
  virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled);
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    58
};
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    59
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    60
// A generic mark bitmap for concurrent marking.  This is essentially a wrapper
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    61
// around the BitMap class that is based on HeapWords, with one bit per (1 << _shifter) HeapWords.
49392
2956d0ece7a9 8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents: 47885
diff changeset
    62
class G1CMBitMap {
46751
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    63
  MemRegion _covered;    // The heap area covered by this bitmap.
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    64
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    65
  const int _shifter;    // Shift amount from heap index to bit index in the bitmap.
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    66
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    67
  BitMapView _bm;        // The actual bitmap.
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    68
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    69
  G1CMBitMapMappingChangedListener _listener;
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    70
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    71
  inline void check_mark(HeapWord* addr) NOT_DEBUG_RETURN;
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    72
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    73
  // Convert from bit offset to address.
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    74
  HeapWord* offset_to_addr(size_t offset) const {
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    75
    return _covered.start() + (offset << _shifter);
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    76
  }
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    77
  // Convert from address to bit offset.
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    78
  size_t addr_to_offset(const HeapWord* addr) const {
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    79
    return pointer_delta(addr, _covered.start()) >> _shifter;
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    80
  }
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    81
public:
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    82
  static size_t compute_size(size_t heap_size);
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    83
  // Returns the amount of bytes on the heap between two marks in the bitmap.
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    84
  static size_t mark_distance();
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    85
  // Returns how many bytes (or bits) of the heap a single byte (or bit) of the
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    86
  // mark bitmap corresponds to. This is the same as the mark distance above.
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    87
  static size_t heap_map_factor() {
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    88
    return mark_distance();
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    89
  }
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    90
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    91
  G1CMBitMap() : _covered(), _bm(), _shifter(LogMinObjAlignment), _listener() { _listener.set_bitmap(this); }
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    92
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    93
  // Initializes the underlying BitMap to cover the given area.
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    94
  void initialize(MemRegion heap, G1RegionToSpaceMapper* storage);
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    95
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    96
  // Read marks
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
    97
  bool is_marked(oop obj) const;
46751
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    98
  bool is_marked(HeapWord* addr) const {
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
    99
    assert(_covered.contains(addr),
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   100
           "Address " PTR_FORMAT " is outside underlying space from " PTR_FORMAT " to " PTR_FORMAT,
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   101
           p2i(addr), p2i(_covered.start()), p2i(_covered.end()));
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   102
    return _bm.at(addr_to_offset(addr));
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   103
  }
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   104
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   105
  // Apply the closure to the addresses that correspond to marked bits in the bitmap.
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   106
  inline bool iterate(G1CMBitMapClosure* cl, MemRegion mr);
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   107
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   108
  // Return the address corresponding to the next marked bit at or after
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   109
  // "addr", and before "limit", if "limit" is non-NULL.  If there is no
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   110
  // such bit, returns "limit" if that is non-NULL, or else "endWord()".
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   111
  inline HeapWord* get_next_marked_addr(const HeapWord* addr,
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   112
                                        const HeapWord* limit) const;
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   113
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   114
  void print_on_error(outputStream* st, const char* prefix) const;
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   115
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   116
  // Write marks.
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   117
  inline void mark(HeapWord* addr);
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   118
  inline void clear(HeapWord* addr);
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   119
  inline void clear(oop obj);
46751
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   120
  inline bool par_mark(HeapWord* addr);
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   121
  inline bool par_mark(oop obj);
46751
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   122
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   123
  void clear_range(MemRegion mr);
47885
5caa1d5f74c1 8186571: Implementation: JEP 307: Parallel Full GC for G1
sjohanss
parents: 47216
diff changeset
   124
  void clear_region(HeapRegion* hr);
46751
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   125
};
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   126
d2e0cecdbcb0 8184347: Move G1CMBitMap and support classes into their own files
tschatzl
parents:
diff changeset
   127
#endif // SHARE_VM_GC_G1_G1CONCURRENTMARKBITMAP_HPP