src/hotspot/share/gc/g1/g1BlockOffsetTable.hpp
author tschatzl
Wed, 18 Apr 2018 11:36:48 +0200
changeset 49806 2d62570a615c
parent 49392 2956d0ece7a9
child 53244 9807daeb47c4
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:
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
     1
/*
49392
2956d0ece7a9 8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents: 47216
diff changeset
     2
 * Copyright (c) 2001, 2018, 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: 1374
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1374
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: 1374
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: 30583
diff changeset
    25
#ifndef SHARE_VM_GC_G1_G1BLOCKOFFSETTABLE_HPP
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30583
diff changeset
    26
#define SHARE_VM_GC_G1_G1BLOCKOFFSETTABLE_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: 30583
diff changeset
    28
#include "gc/g1/g1RegionToSpaceMapper.hpp"
35469
17ea1b453dd5 8146694: Break out shared constants and static BOT functions.
david
parents: 35461
diff changeset
    29
#include "gc/shared/blockOffsetTable.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    30
#include "memory/memRegion.hpp"
30291
54cdc5c1a9cb 8068352: Move virtualspace.* out of src/share/vm/runtime to memory directory
coleenp
parents: 27149
diff changeset
    31
#include "memory/virtualspace.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    32
#include "utilities/globalDefinitions.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    33
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    34
// Forward declarations
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
    35
class G1BlockOffsetTable;
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
    36
class G1ContiguousSpace;
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    37
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    38
// This implementation of "G1BlockOffsetTable" divides the covered region
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    39
// into "N"-word subregions (where "N" = 2^"LogN".  An array with an entry
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    40
// for each such subregion indicates how far back one must go to find the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    41
// start of the chunk that includes the first word of the subregion.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    42
//
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
    43
// Each G1BlockOffsetTablePart is owned by a G1ContiguousSpace.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    44
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
    45
class G1BlockOffsetTable: public CHeapObj<mtGC> {
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
    46
  friend class G1BlockOffsetTablePart;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    47
  friend class VMStructs;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    48
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    49
private:
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
    50
  // The reserved region covered by the table.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    51
  MemRegion _reserved;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    52
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    53
  // Array for keeping offsets for retrieving object start fast given an
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    54
  // address.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    55
  u_char* _offset_array;          // byte array keeping backwards offsets
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    56
14584
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13481
diff changeset
    57
  void check_offset(size_t offset, const char* msg) const {
35469
17ea1b453dd5 8146694: Break out shared constants and static BOT functions.
david
parents: 35461
diff changeset
    58
    assert(offset <= BOTConstants::N_words,
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 31592
diff changeset
    59
           "%s - offset: " SIZE_FORMAT ", N_words: %u",
35469
17ea1b453dd5 8146694: Break out shared constants and static BOT functions.
david
parents: 35461
diff changeset
    60
           msg, offset, BOTConstants::N_words);
14584
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13481
diff changeset
    61
  }
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13481
diff changeset
    62
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    63
  // Bounds checking accessors:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    64
  // For performance these have to devolve to array accesses in product builds.
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    65
  inline u_char offset_array(size_t index) const;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    66
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    67
  void set_offset_array_raw(size_t index, u_char offset) {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    68
    _offset_array[index] = offset;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    69
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    70
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    71
  inline void set_offset_array(size_t index, u_char offset);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    72
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    73
  inline void set_offset_array(size_t index, HeapWord* high, HeapWord* low);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    74
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    75
  inline void set_offset_array(size_t left, size_t right, u_char offset);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    76
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    77
  bool is_card_boundary(HeapWord* p) const;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    78
30583
74ff3d21d616 8079330: Circular dependency between G1CollectedHeap and G1BlockOffsetSharedArray
pliden
parents: 30579
diff changeset
    79
  void check_index(size_t index, const char* msg) const NOT_DEBUG_RETURN;
74ff3d21d616 8079330: Circular dependency between G1CollectedHeap and G1BlockOffsetSharedArray
pliden
parents: 30579
diff changeset
    80
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    81
public:
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    82
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    83
  // Return the number of slots needed for an offset array
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    84
  // that covers mem_region_words words.
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    85
  static size_t compute_size(size_t mem_region_words) {
35469
17ea1b453dd5 8146694: Break out shared constants and static BOT functions.
david
parents: 35461
diff changeset
    86
    size_t number_of_slots = (mem_region_words / BOTConstants::N_words);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    87
    return ReservedSpace::allocation_align_size_up(number_of_slots);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    88
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    89
30565
ebd5af27fe02 8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents: 27149
diff changeset
    90
  // Returns how many bytes of the heap a single byte of the BOT corresponds to.
ebd5af27fe02 8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents: 27149
diff changeset
    91
  static size_t heap_map_factor() {
35469
17ea1b453dd5 8146694: Break out shared constants and static BOT functions.
david
parents: 35461
diff changeset
    92
    return BOTConstants::N_bytes;
30565
ebd5af27fe02 8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents: 27149
diff changeset
    93
  }
ebd5af27fe02 8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents: 27149
diff changeset
    94
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
    95
  // Initialize the Block Offset Table to cover the memory region passed
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
    96
  // in the heap parameter.
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
    97
  G1BlockOffsetTable(MemRegion heap, G1RegionToSpaceMapper* storage);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    98
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    99
  // Return the appropriate index into "_offset_array" for "p".
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   100
  inline size_t index_for(const void* p) const;
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   101
  inline size_t index_for_raw(const void* p) const;
1374
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
  // Return the address indicating the start of the region corresponding to
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   104
  // "index" in "_offset_array".
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   105
  inline HeapWord* address_for_index(size_t index) const;
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   106
  // Variant of address_for_index that does not check the index for validity.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   107
  inline HeapWord* address_for_index_raw(size_t index) const {
35469
17ea1b453dd5 8146694: Break out shared constants and static BOT functions.
david
parents: 35461
diff changeset
   108
    return _reserved.start() + (index << BOTConstants::LogN_words);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   109
  }
1374
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
49392
2956d0ece7a9 8199282: Remove ValueObj class for allocation subclassing for gc code
coleenp
parents: 47216
diff changeset
   112
class G1BlockOffsetTablePart {
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   113
  friend class G1BlockOffsetTable;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   114
  friend class VMStructs;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   115
private:
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   116
  // allocation boundary at which offset array must be updated
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   117
  HeapWord* _next_offset_threshold;
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   118
  size_t    _next_offset_index;      // index corresponding to that boundary
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   119
46286
c112671e114e 8173764: G1 BOT wrongly assumes that objects must always begin at the start of G1BlockOffsetTablePart
sjohanss
parents: 35469
diff changeset
   120
  // Indicates if an object can span into this G1BlockOffsetTablePart.
c112671e114e 8173764: G1 BOT wrongly assumes that objects must always begin at the start of G1BlockOffsetTablePart
sjohanss
parents: 35469
diff changeset
   121
  debug_only(bool _object_can_span;)
c112671e114e 8173764: G1 BOT wrongly assumes that objects must always begin at the start of G1BlockOffsetTablePart
sjohanss
parents: 35469
diff changeset
   122
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   123
  // This is the global BlockOffsetTable.
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   124
  G1BlockOffsetTable* _bot;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   125
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   126
  // The space that owns this subregion.
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   127
  G1ContiguousSpace* _space;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   128
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   129
  // Sets the entries
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   130
  // corresponding to the cards starting at "start" and ending at "end"
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   131
  // to point back to the card before "start": the interval [start, end)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   132
  // is right-open.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   133
  void set_remainder_to_point_to_start(HeapWord* start, HeapWord* end);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   134
  // Same as above, except that the args here are a card _index_ interval
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   135
  // that is closed: [start_index, end_index]
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   136
  void set_remainder_to_point_to_start_incl(size_t start, size_t end);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   137
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   138
  // Zero out the entry for _bottom (offset will be zero). Does not check for availability of the
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   139
  // memory first.
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   140
  void zero_bottom_entry_raw();
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   141
  // Variant of initialize_threshold that does not check for availability of the
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   142
  // memory first.
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   143
  HeapWord* initialize_threshold_raw();
25361
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 24424
diff changeset
   144
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 24424
diff changeset
   145
  inline size_t block_size(const HeapWord* p) const;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   146
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   147
  // Returns the address of a block whose start is at most "addr".
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   148
  // If "has_max_index" is true, "assumes "max_index" is the last valid one
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   149
  // in the array.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   150
  inline HeapWord* block_at_or_preceding(const void* addr,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   151
                                         bool has_max_index,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   152
                                         size_t max_index) const;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   153
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   154
  // "q" is a block boundary that is <= "addr"; "n" is the address of the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   155
  // next block (or the end of the space.)  Return the address of the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   156
  // beginning of the block that contains "addr".  Does so without side
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   157
  // effects (see, e.g., spec of  block_start.)
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   158
  inline HeapWord* forward_to_block_containing_addr_const(HeapWord* q, HeapWord* n,
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   159
                                                          const void* addr) const;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   160
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   161
  // "q" is a block boundary that is <= "addr"; return the address of the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   162
  // beginning of the block that contains "addr".  May have side effects
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   163
  // on "this", by updating imprecise entries.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   164
  inline HeapWord* forward_to_block_containing_addr(HeapWord* q,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   165
                                                    const void* addr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   166
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   167
  // "q" is a block boundary that is <= "addr"; "n" is the address of the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   168
  // next block (or the end of the space.)  Return the address of the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   169
  // beginning of the block that contains "addr".  May have side effects
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   170
  // on "this", by updating imprecise entries.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   171
  HeapWord* forward_to_block_containing_addr_slow(HeapWord* q,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   172
                                                  HeapWord* n,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   173
                                                  const void* addr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   174
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   175
  // Requires that "*threshold_" be the first array entry boundary at or
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   176
  // above "blk_start", and that "*index_" be the corresponding array
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   177
  // index.  If the block starts at or crosses "*threshold_", records
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   178
  // "blk_start" as the appropriate block start for the array index
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   179
  // starting at "*threshold_", and for any other indices crossed by the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   180
  // block.  Updates "*threshold_" and "*index_" to correspond to the first
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   181
  // index after the block end.
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   182
  void alloc_block_work(HeapWord** threshold_, size_t* index_,
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   183
                        HeapWord* blk_start, HeapWord* blk_end);
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   184
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   185
  void check_all_cards(size_t left_card, size_t right_card) const;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   186
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   187
public:
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   188
  //  The elements of the array are initialized to zero.
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   189
  G1BlockOffsetTablePart(G1BlockOffsetTable* array, G1ContiguousSpace* gsp);
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   190
26571
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   191
  void verify() const;
6983
a8c50cedbce9 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 5547
diff changeset
   192
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   193
  // Returns the address of the start of the block containing "addr", or
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   194
  // else "null" if it is covered by no block.  (May have side effects,
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   195
  // namely updating of shared array entries that "point" too far
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   196
  // backwards.  This can occur, for example, when lab allocation is used
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   197
  // in a space covered by the table.)
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   198
  inline HeapWord* block_start(const void* addr);
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   199
  // Same as above, but does not have any of the possible side effects
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   200
  // discussed above.
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   201
  inline HeapWord* block_start_const(const void* addr) const;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   202
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   203
  // Initialize the threshold to reflect the first boundary after the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   204
  // bottom of the covered region.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   205
  HeapWord* initialize_threshold();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   206
26157
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 25361
diff changeset
   207
  void reset_bot() {
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   208
    zero_bottom_entry_raw();
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   209
    initialize_threshold_raw();
26157
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 25361
diff changeset
   210
  }
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
  // Return the next threshold, the point at which the table should be
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   213
  // updated.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   214
  HeapWord* threshold() const { return _next_offset_threshold; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   215
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   216
  // These must be guaranteed to work properly (i.e., do nothing)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   217
  // when "blk_start" ("blk" for second version) is "NULL".  In this
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   218
  // implementation, that's true because NULL is represented as 0, and thus
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   219
  // never exceeds the "_next_offset_threshold".
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   220
  void alloc_block(HeapWord* blk_start, HeapWord* blk_end) {
33786
ac8da6513351 8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents: 33105
diff changeset
   221
    if (blk_end > _next_offset_threshold) {
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   222
      alloc_block_work(&_next_offset_threshold, &_next_offset_index, blk_start, blk_end);
33786
ac8da6513351 8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents: 33105
diff changeset
   223
    }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   224
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   225
  void alloc_block(HeapWord* blk, size_t size) {
33786
ac8da6513351 8139867: Change how startsHumongous and continuesHumongous regions work in G1.
david
parents: 33105
diff changeset
   226
    alloc_block(blk, blk+size);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   227
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   228
34249
a015a11067a2 8138681: Runtime.getFreeMemory() reports wrong value after humongous allocation.
david
parents: 33786
diff changeset
   229
  void set_for_starts_humongous(HeapWord* obj_top, size_t fill_size);
46286
c112671e114e 8173764: G1 BOT wrongly assumes that objects must always begin at the start of G1BlockOffsetTablePart
sjohanss
parents: 35469
diff changeset
   230
  void set_object_can_span(bool can_span) NOT_DEBUG_RETURN;
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   231
35461
1068dcb8d315 8146399: Refactor the BlockOffsetTable classes.
david
parents: 34249
diff changeset
   232
  void print_on(outputStream* out) PRODUCT_RETURN;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   233
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
   234
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30583
diff changeset
   235
#endif // SHARE_VM_GC_G1_G1BLOCKOFFSETTABLE_HPP