hotspot/src/share/vm/gc/parallel/parMarkBitMap.hpp
author stefank
Tue, 03 May 2016 22:45:27 +0200
changeset 38177 b0c9cb06506b
parent 35877 a2a62511d0f8
child 46402 8147e17ad6fa
permissions -rw-r--r--
8141501: Problems with BitMap buffer management Reviewed-by: pliden, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
35877
a2a62511d0f8 8146987: Improve Parallel GC Full GC by caching results of live_words_in_range()
tschatzl
parents: 33105
diff changeset
     2
 * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
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: 3261
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 24424
diff changeset
    25
#ifndef SHARE_VM_GC_PARALLEL_PARMARKBITMAP_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 24424
diff changeset
    26
#define SHARE_VM_GC_PARALLEL_PARMARKBITMAP_HPP
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
7408
c04a5c989f26 7003125: precompiled.hpp is included when precompiled headers are not used
stefank
parents: 7397
diff changeset
    28
#include "memory/memRegion.hpp"
17390
f6f515533813 8014339: Improve assert and remove some dead code from parMarkBitMap.hpp/cpp
brutisso
parents: 16685
diff changeset
    29
#include "oops/oop.hpp"
f6f515533813 8014339: Improve assert and remove some dead code from parMarkBitMap.hpp/cpp
brutisso
parents: 16685
diff changeset
    30
#include "utilities/bitMap.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
class ParMarkBitMapClosure;
17390
f6f515533813 8014339: Improve assert and remove some dead code from parMarkBitMap.hpp/cpp
brutisso
parents: 16685
diff changeset
    33
class PSVirtualSpace;
35877
a2a62511d0f8 8146987: Improve Parallel GC Full GC by caching results of live_words_in_range()
tschatzl
parents: 33105
diff changeset
    34
class ParCompactionManager;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7408
diff changeset
    36
class ParMarkBitMap: public CHeapObj<mtGC>
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  typedef BitMap::idx_t idx_t;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  // Values returned by the iterate() methods.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  enum IterationStatus { incomplete, complete, full, would_overflow };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  inline ParMarkBitMap();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  bool initialize(MemRegion covered_region);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  // Atomically mark an object as live.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  bool mark_obj(HeapWord* addr, size_t size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  inline bool mark_obj(oop obj, int size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  // Return whether the specified begin or end bit is set.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  inline bool is_obj_beg(idx_t bit) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  inline bool is_obj_end(idx_t bit) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  // Traditional interface for testing whether an object is marked or not (these
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // test only the begin bits).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  inline bool is_marked(idx_t bit)      const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  inline bool is_marked(HeapWord* addr) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  inline bool is_marked(oop obj)        const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  inline bool is_unmarked(idx_t bit)      const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  inline bool is_unmarked(HeapWord* addr) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  inline bool is_unmarked(oop obj)        const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  // Convert sizes from bits to HeapWords and back.  An object that is n bits
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  // long will be bits_to_words(n) words long.  An object that is m words long
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  // will take up words_to_bits(m) bits in the bitmap.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  inline static size_t bits_to_words(idx_t bits);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  inline static idx_t  words_to_bits(size_t words);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  // Return the size in words of an object given a begin bit and an end bit, or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  // the equivalent beg_addr and end_addr.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  inline size_t obj_size(idx_t beg_bit, idx_t end_bit) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  inline size_t obj_size(HeapWord* beg_addr, HeapWord* end_addr) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  // Return the size in words of the object (a search is done for the end bit).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  inline size_t obj_size(idx_t beg_bit)  const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  inline size_t obj_size(HeapWord* addr) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  // Apply live_closure to each live object that lies completely within the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  // range [live_range_beg, live_range_end).  This is used to iterate over the
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  // compacted region of the heap.  Return values:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  // incomplete         The iteration is not complete.  The last object that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  //                    begins in the range does not end in the range;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  //                    closure->source() is set to the start of that object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  // complete           The iteration is complete.  All objects in the range
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  //                    were processed and the closure is not full;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  //                    closure->source() is set one past the end of the range.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  // full               The closure is full; closure->source() is set to one
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  //                    past the end of the last object processed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // would_overflow     The next object in the range would overflow the closure;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  //                    closure->source() is set to the start of that object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  IterationStatus iterate(ParMarkBitMapClosure* live_closure,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
                          idx_t range_beg, idx_t range_end) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  inline IterationStatus iterate(ParMarkBitMapClosure* live_closure,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
                                 HeapWord* range_beg,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
                                 HeapWord* range_end) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // Apply live closure as above and additionally apply dead_closure to all dead
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // space in the range [range_beg, dead_range_end).  Note that dead_range_end
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  // must be >= range_end.  This is used to iterate over the dense prefix.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // This method assumes that if the first bit in the range (range_beg) is not
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  // marked, then dead space begins at that point and the dead_closure is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  // applied.  Thus callers must ensure that range_beg is not in the middle of a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  // live object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  IterationStatus iterate(ParMarkBitMapClosure* live_closure,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
                          ParMarkBitMapClosure* dead_closure,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
                          idx_t range_beg, idx_t range_end,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
                          idx_t dead_range_end) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  inline IterationStatus iterate(ParMarkBitMapClosure* live_closure,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
                                 ParMarkBitMapClosure* dead_closure,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
                                 HeapWord* range_beg,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
                                 HeapWord* range_end,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
                                 HeapWord* dead_range_end) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
17390
f6f515533813 8014339: Improve assert and remove some dead code from parMarkBitMap.hpp/cpp
brutisso
parents: 16685
diff changeset
   121
  // Return the number of live words in the range [beg_addr, end_obj) due to
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  // objects that start in the range.  If a live object extends onto the range,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  // the caller must detect and account for any live words due to that object.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  // If a live object extends beyond the end of the range, only the words within
17390
f6f515533813 8014339: Improve assert and remove some dead code from parMarkBitMap.hpp/cpp
brutisso
parents: 16685
diff changeset
   125
  // the range are included in the result. The end of the range must be a live object,
f6f515533813 8014339: Improve assert and remove some dead code from parMarkBitMap.hpp/cpp
brutisso
parents: 16685
diff changeset
   126
  // which is the case when updating pointers.  This allows a branch to be removed
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  // from inside the loop.
35877
a2a62511d0f8 8146987: Improve Parallel GC Full GC by caching results of live_words_in_range()
tschatzl
parents: 33105
diff changeset
   128
  size_t live_words_in_range(ParCompactionManager* cm, HeapWord* beg_addr, oop end_obj) const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  inline HeapWord* region_start() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  inline HeapWord* region_end() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  inline size_t    region_size() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  inline size_t    size() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
17627
325871034f2c 7186737: Unable to allocate bit maps or card tables for parallel gc for the requested heap
tamao
parents: 17390
diff changeset
   135
  size_t reserved_byte_size() const { return _reserved_byte_size; }
325871034f2c 7186737: Unable to allocate bit maps or card tables for parallel gc for the requested heap
tamao
parents: 17390
diff changeset
   136
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  // Convert a heap address to/from a bit index.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  inline idx_t     addr_to_bit(HeapWord* addr) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  inline HeapWord* bit_to_addr(idx_t bit) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  // Return the bit index of the first marked object that begins (or ends,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  // respectively) in the range [beg, end).  If no object is found, return end.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  inline idx_t find_obj_beg(idx_t beg, idx_t end) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  inline idx_t find_obj_end(idx_t beg, idx_t end) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  inline HeapWord* find_obj_beg(HeapWord* beg, HeapWord* end) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  inline HeapWord* find_obj_end(HeapWord* beg, HeapWord* end) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  // Clear a range of bits or the entire bitmap (both begin and end bits are
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  // cleared).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  inline void clear_range(idx_t beg, idx_t end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  // Return the number of bits required to represent the specified number of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  // HeapWords, or the specified region.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  static inline idx_t bits_required(size_t words);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  static inline idx_t bits_required(MemRegion covered_region);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
16685
41c34debcde0 8011872: Include Bit Map addresses in the hs_err files
stefank
parents: 13963
diff changeset
   158
  void print_on_error(outputStream* st) const {
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 17627
diff changeset
   159
    st->print_cr("Marking Bits: (ParMarkBitMap*) " PTR_FORMAT, p2i(this));
16685
41c34debcde0 8011872: Include Bit Map addresses in the hs_err files
stefank
parents: 13963
diff changeset
   160
    _beg_bits.print_on_error(st, " Begin Bits: ");
41c34debcde0 8011872: Include Bit Map addresses in the hs_err files
stefank
parents: 13963
diff changeset
   161
    _end_bits.print_on_error(st, " End Bits:   ");
41c34debcde0 8011872: Include Bit Map addresses in the hs_err files
stefank
parents: 13963
diff changeset
   162
  }
41c34debcde0 8011872: Include Bit Map addresses in the hs_err files
stefank
parents: 13963
diff changeset
   163
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
#ifdef  ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  void verify_clear() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  inline void verify_bit(idx_t bit) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  inline void verify_addr(HeapWord* addr) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
#endif  // #ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
private:
35877
a2a62511d0f8 8146987: Improve Parallel GC Full GC by caching results of live_words_in_range()
tschatzl
parents: 33105
diff changeset
   171
  size_t live_words_in_range_helper(HeapWord* beg_addr, oop end_obj) const;
a2a62511d0f8 8146987: Improve Parallel GC Full GC by caching results of live_words_in_range()
tschatzl
parents: 33105
diff changeset
   172
a2a62511d0f8 8146987: Improve Parallel GC Full GC by caching results of live_words_in_range()
tschatzl
parents: 33105
diff changeset
   173
  bool is_live_words_in_range_in_cache(ParCompactionManager* cm, HeapWord* beg_addr) const;
a2a62511d0f8 8146987: Improve Parallel GC Full GC by caching results of live_words_in_range()
tschatzl
parents: 33105
diff changeset
   174
  size_t live_words_in_range_use_cache(ParCompactionManager* cm, HeapWord* beg_addr, oop end_obj) const;
a2a62511d0f8 8146987: Improve Parallel GC Full GC by caching results of live_words_in_range()
tschatzl
parents: 33105
diff changeset
   175
  void update_live_words_in_range_cache(ParCompactionManager* cm, HeapWord* beg_addr, oop end_obj, size_t result) const;
a2a62511d0f8 8146987: Improve Parallel GC Full GC by caching results of live_words_in_range()
tschatzl
parents: 33105
diff changeset
   176
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  // Each bit in the bitmap represents one unit of 'object granularity.' Objects
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  // are double-word aligned in 32-bit VMs, but not in 64-bit VMs, so the 32-bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  // granularity is 2, 64-bit is 1.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  static inline size_t obj_granularity() { return size_t(MinObjAlignment); }
2997
69cd0f7ac5d6 6814552: par compact - some compilers fail to optimize bitmap code
jcoomes
parents: 1374
diff changeset
   181
  static inline int obj_granularity_shift() { return LogMinObjAlignment; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  HeapWord*       _region_start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  size_t          _region_size;
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 35877
diff changeset
   185
  BitMapView      _beg_bits;
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 35877
diff changeset
   186
  BitMapView      _end_bits;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  PSVirtualSpace* _virtual_space;
17627
325871034f2c 7186737: Unable to allocate bit maps or card tables for parallel gc for the requested heap
tamao
parents: 17390
diff changeset
   188
  size_t          _reserved_byte_size;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
inline ParMarkBitMap::ParMarkBitMap():
17627
325871034f2c 7186737: Unable to allocate bit maps or card tables for parallel gc for the requested heap
tamao
parents: 17390
diff changeset
   192
  _beg_bits(), _end_bits(), _region_start(NULL), _region_size(0), _virtual_space(NULL), _reserved_byte_size(0)
17390
f6f515533813 8014339: Improve assert and remove some dead code from parMarkBitMap.hpp/cpp
brutisso
parents: 16685
diff changeset
   193
{ }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
inline void ParMarkBitMap::clear_range(idx_t beg, idx_t end)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  _beg_bits.clear_range(beg, end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  _end_bits.clear_range(beg, end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
inline ParMarkBitMap::idx_t
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
ParMarkBitMap::bits_required(size_t words)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  // Need two bits (one begin bit, one end bit) for each unit of 'object
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  // granularity' in the heap.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  return words_to_bits(words * 2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
inline ParMarkBitMap::idx_t
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
ParMarkBitMap::bits_required(MemRegion covered_region)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  return bits_required(covered_region.word_size());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
inline HeapWord*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
ParMarkBitMap::region_start() const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  return _region_start;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
inline HeapWord*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
ParMarkBitMap::region_end() const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  return region_start() + region_size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
inline size_t
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
ParMarkBitMap::region_size() const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  return _region_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
inline size_t
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
ParMarkBitMap::size() const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  return _beg_bits.size();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
inline bool ParMarkBitMap::is_obj_beg(idx_t bit) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  return _beg_bits.at(bit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
inline bool ParMarkBitMap::is_obj_end(idx_t bit) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  return _end_bits.at(bit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
inline bool ParMarkBitMap::is_marked(idx_t bit) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  return is_obj_beg(bit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
inline bool ParMarkBitMap::is_marked(HeapWord* addr) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  return is_marked(addr_to_bit(addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
inline bool ParMarkBitMap::is_marked(oop obj) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  return is_marked((HeapWord*)obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
inline bool ParMarkBitMap::is_unmarked(idx_t bit) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  return !is_marked(bit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
inline bool ParMarkBitMap::is_unmarked(HeapWord* addr) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  return !is_marked(addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
inline bool ParMarkBitMap::is_unmarked(oop obj) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  return !is_marked(obj);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
inline size_t
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
ParMarkBitMap::bits_to_words(idx_t bits)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
{
2997
69cd0f7ac5d6 6814552: par compact - some compilers fail to optimize bitmap code
jcoomes
parents: 1374
diff changeset
   282
  return bits << obj_granularity_shift();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
inline ParMarkBitMap::idx_t
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
ParMarkBitMap::words_to_bits(size_t words)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
{
2997
69cd0f7ac5d6 6814552: par compact - some compilers fail to optimize bitmap code
jcoomes
parents: 1374
diff changeset
   288
  return words >> obj_granularity_shift();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
inline size_t ParMarkBitMap::obj_size(idx_t beg_bit, idx_t end_bit) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  DEBUG_ONLY(verify_bit(beg_bit);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  DEBUG_ONLY(verify_bit(end_bit);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  return bits_to_words(end_bit - beg_bit + 1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
inline size_t
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
ParMarkBitMap::obj_size(HeapWord* beg_addr, HeapWord* end_addr) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  DEBUG_ONLY(verify_addr(beg_addr);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  DEBUG_ONLY(verify_addr(end_addr);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  return pointer_delta(end_addr, beg_addr) + obj_granularity();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
inline size_t ParMarkBitMap::obj_size(idx_t beg_bit) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
{
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   308
  const idx_t end_bit = _end_bits.get_next_one_offset_inline(beg_bit, size());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  assert(is_marked(beg_bit), "obj not marked");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
  assert(end_bit < size(), "end bit missing");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  return obj_size(beg_bit, end_bit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
inline size_t ParMarkBitMap::obj_size(HeapWord* addr) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  return obj_size(addr_to_bit(addr));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
inline ParMarkBitMap::IterationStatus
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
ParMarkBitMap::iterate(ParMarkBitMapClosure* live_closure,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
                       HeapWord* range_beg,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
                       HeapWord* range_end) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  return iterate(live_closure, addr_to_bit(range_beg), addr_to_bit(range_end));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
inline ParMarkBitMap::IterationStatus
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
ParMarkBitMap::iterate(ParMarkBitMapClosure* live_closure,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
                       ParMarkBitMapClosure* dead_closure,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
                       HeapWord* range_beg,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
                       HeapWord* range_end,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
                       HeapWord* dead_range_end) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  return iterate(live_closure, dead_closure,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
                 addr_to_bit(range_beg), addr_to_bit(range_end),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
                 addr_to_bit(dead_range_end));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
inline bool
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
ParMarkBitMap::mark_obj(oop obj, int size)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  return mark_obj((HeapWord*)obj, (size_t)size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
inline BitMap::idx_t
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
ParMarkBitMap::addr_to_bit(HeapWord* addr) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  DEBUG_ONLY(verify_addr(addr);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  return words_to_bits(pointer_delta(addr, region_start()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
inline HeapWord*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
ParMarkBitMap::bit_to_addr(idx_t bit) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  DEBUG_ONLY(verify_bit(bit);)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  return region_start() + bits_to_words(bit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
inline ParMarkBitMap::idx_t
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
ParMarkBitMap::find_obj_beg(idx_t beg, idx_t end) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
{
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   362
  return _beg_bits.get_next_one_offset_inline_aligned_right(beg, end);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
inline ParMarkBitMap::idx_t
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
ParMarkBitMap::find_obj_end(idx_t beg, idx_t end) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
{
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   368
  return _end_bits.get_next_one_offset_inline_aligned_right(beg, end);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
inline HeapWord*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
ParMarkBitMap::find_obj_beg(HeapWord* beg, HeapWord* end) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  const idx_t beg_bit = addr_to_bit(beg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  const idx_t end_bit = addr_to_bit(end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  const idx_t search_end = BitMap::word_align_up(end_bit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  const idx_t res_bit = MIN2(find_obj_beg(beg_bit, search_end), end_bit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  return bit_to_addr(res_bit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
inline HeapWord*
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
ParMarkBitMap::find_obj_end(HeapWord* beg, HeapWord* end) const
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  const idx_t beg_bit = addr_to_bit(beg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  const idx_t end_bit = addr_to_bit(end);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  const idx_t search_end = BitMap::word_align_up(end_bit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
  const idx_t res_bit = MIN2(find_obj_end(beg_bit, search_end), end_bit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  return bit_to_addr(res_bit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
#ifdef  ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
inline void ParMarkBitMap::verify_bit(idx_t bit) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  // Allow one past the last valid bit; useful for loop bounds.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  assert(bit <= _beg_bits.size(), "bit out of range");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
inline void ParMarkBitMap::verify_addr(HeapWord* addr) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  // Allow one past the last valid address; useful for loop bounds.
17390
f6f515533813 8014339: Improve assert and remove some dead code from parMarkBitMap.hpp/cpp
brutisso
parents: 16685
diff changeset
   399
  assert(addr >= region_start(),
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 30764
diff changeset
   400
         "addr too small, addr: " PTR_FORMAT " region start: " PTR_FORMAT, p2i(addr), p2i(region_start()));
17390
f6f515533813 8014339: Improve assert and remove some dead code from parMarkBitMap.hpp/cpp
brutisso
parents: 16685
diff changeset
   401
  assert(addr <= region_end(),
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 30764
diff changeset
   402
         "addr too big, addr: " PTR_FORMAT " region end: " PTR_FORMAT, p2i(addr), p2i(region_end()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
#endif  // #ifdef ASSERT
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   405
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 24424
diff changeset
   406
#endif // SHARE_VM_GC_PARALLEL_PARMARKBITMAP_HPP