hotspot/src/share/vm/gc_implementation/g1/g1BlockOffsetTable.hpp
author pliden
Tue, 05 May 2015 11:17:12 +0200
changeset 30583 74ff3d21d616
parent 30579 5208524ce05c
permissions -rw-r--r--
8079330: Circular dependency between G1CollectedHeap and G1BlockOffsetSharedArray Reviewed-by: tschatzl, mgerdin
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
/*
30565
ebd5af27fe02 8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents: 27149
diff changeset
     2
 * Copyright (c) 2001, 2015, 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
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    25
#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1BLOCKOFFSETTABLE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    26
#define SHARE_VM_GC_IMPLEMENTATION_G1_G1BLOCKOFFSETTABLE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    27
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
    28
#include "gc_implementation/g1/g1RegionToSpaceMapper.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    29
#include "memory/memRegion.hpp"
30291
54cdc5c1a9cb 8068352: Move virtualspace.* out of src/share/vm/runtime to memory directory
coleenp
parents: 27149
diff changeset
    30
#include "memory/virtualspace.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    31
#include "utilities/globalDefinitions.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
    32
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    33
// The CollectedHeap type requires subtypes to implement a method
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    34
// "block_start".  For some subtypes, notably generational
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    35
// systems using card-table-based write barriers, the efficiency of this
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    36
// operation may be important.  Implementations of the "BlockOffsetArray"
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    37
// class may be useful in providing such efficient implementations.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    38
//
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    39
// While generally mirroring the structure of the BOT for GenCollectedHeap,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    40
// the following types are tailored more towards G1's uses; these should,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    41
// however, be merged back into a common BOT to avoid code duplication
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    42
// and reduce maintenance overhead.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    43
//
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    44
//    G1BlockOffsetTable (abstract)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    45
//    -- G1BlockOffsetArray                (uses G1BlockOffsetSharedArray)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    46
//       -- G1BlockOffsetArrayContigSpace
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    47
//
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    48
// A main impediment to the consolidation of this code might be the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    49
// effect of making some of the block_start*() calls non-const as
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    50
// below. Whether that might adversely affect performance optimizations
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    51
// that compilers might normally perform in the case of non-G1
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    52
// collectors needs to be carefully investigated prior to any such
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    53
// consolidation.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    54
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    55
// Forward declarations
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    56
class G1BlockOffsetSharedArray;
25361
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 24424
diff changeset
    57
class G1OffsetTableContigSpace;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    58
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    59
class G1BlockOffsetTable VALUE_OBJ_CLASS_SPEC {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    60
  friend class VMStructs;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    61
protected:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    62
  // These members describe the region covered by the table.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    63
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    64
  // The space this table is covering.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    65
  HeapWord* _bottom;    // == reserved.start
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    66
  HeapWord* _end;       // End of currently allocated region.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    67
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    68
public:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    69
  // Initialize the table to cover the given space.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    70
  // The contents of the initial table are undefined.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    71
  G1BlockOffsetTable(HeapWord* bottom, HeapWord* end) :
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    72
    _bottom(bottom), _end(end)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    73
    {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    74
      assert(_bottom <= _end, "arguments out of order");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    75
    }
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
  // Note that the committed size of the covered space may have changed,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    78
  // so the table size might also wish to change.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    79
  virtual void resize(size_t new_word_size) = 0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    80
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    81
  virtual void set_bottom(HeapWord* new_bottom) {
14584
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13481
diff changeset
    82
    assert(new_bottom <= _end,
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13481
diff changeset
    83
           err_msg("new_bottom (" PTR_FORMAT ") > _end (" PTR_FORMAT ")",
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 23858
diff changeset
    84
                   p2i(new_bottom), p2i(_end)));
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    85
    _bottom = new_bottom;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    86
    resize(pointer_delta(_end, _bottom));
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    87
  }
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
  // Requires "addr" to be contained by a block, and returns the address of
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    90
  // the start of that block.  (May have side effects, namely updating of
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    91
  // shared array entries that "point" too far backwards.  This can occur,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    92
  // for example, when LAB allocation is used in a space covered by the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    93
  // table.)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    94
  virtual HeapWord* block_start_unsafe(const void* addr) = 0;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    95
  // Same as above, but does not have any of the possible side effects
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    96
  // discussed above.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
    97
  virtual HeapWord* block_start_unsafe_const(const void* addr) const = 0;
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
  // Returns the address of the start of the block containing "addr", or
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   100
  // else "null" if it is covered by no block.  (May have side effects,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   101
  // namely updating of shared array entries that "point" too far
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   102
  // backwards.  This can occur, for example, when lab allocation is used
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   103
  // in a space covered by the table.)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   104
  inline HeapWord* block_start(const void* addr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   105
  // Same as above, but does not have any of the possible side effects
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   106
  // discussed above.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   107
  inline HeapWord* block_start_const(const void* addr) const;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   108
};
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   109
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   110
class G1BlockOffsetSharedArrayMappingChangedListener : public G1MappingChangedListener {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   111
 public:
27149
9246fc481aa3 8059758: Footprint regressions with JDK-8038423
tschatzl
parents: 26571
diff changeset
   112
  virtual void on_commit(uint start_idx, size_t num_regions, bool zero_filled) {
26322
3e4ef23b8ee3 8055816: Remove dead code in g1BlockOffsetTable
brutisso
parents: 26160
diff changeset
   113
    // Nothing to do. The BOT is hard-wired to be part of the HeapRegion, and we cannot
3e4ef23b8ee3 8055816: Remove dead code in g1BlockOffsetTable
brutisso
parents: 26160
diff changeset
   114
    // retrieve it here since this would cause firing of several asserts. The code
3e4ef23b8ee3 8055816: Remove dead code in g1BlockOffsetTable
brutisso
parents: 26160
diff changeset
   115
    // executed after commit of a region already needs to do some re-initialization of
3e4ef23b8ee3 8055816: Remove dead code in g1BlockOffsetTable
brutisso
parents: 26160
diff changeset
   116
    // the HeapRegion, so we combine that.
3e4ef23b8ee3 8055816: Remove dead code in g1BlockOffsetTable
brutisso
parents: 26160
diff changeset
   117
  }
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   118
};
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   119
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   120
// This implementation of "G1BlockOffsetTable" divides the covered region
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   121
// 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
   122
// 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
   123
// 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
   124
//
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   125
// Each BlockOffsetArray is owned by a Space.  However, the actual array
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   126
// may be shared by several BlockOffsetArrays; this is useful
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   127
// when a single resizable area (such as a generation) is divided up into
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   128
// several spaces in which contiguous allocation takes place,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   129
// such as, for example, in G1 or in the train generation.)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   130
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   131
// Here is the shared array type.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   132
13195
be27e1b6a4b9 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 7904
diff changeset
   133
class G1BlockOffsetSharedArray: public CHeapObj<mtGC> {
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   134
  friend class G1BlockOffsetArray;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   135
  friend class G1BlockOffsetArrayContigSpace;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   136
  friend class VMStructs;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   137
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   138
private:
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   139
  G1BlockOffsetSharedArrayMappingChangedListener _listener;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   140
  // The reserved region covered by the shared array.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   141
  MemRegion _reserved;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   142
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   143
  // End of the current committed region.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   144
  HeapWord* _end;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   145
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   146
  // Array for keeping offsets for retrieving object start fast given an
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   147
  // address.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   148
  u_char* _offset_array;          // byte array keeping backwards offsets
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   149
14584
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13481
diff changeset
   150
  void check_offset(size_t offset, const char* msg) const {
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13481
diff changeset
   151
    assert(offset <= N_words,
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13481
diff changeset
   152
           err_msg("%s - "
23858
dae377f5a7c7 8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents: 14584
diff changeset
   153
                   "offset: " SIZE_FORMAT", N_words: %u",
dae377f5a7c7 8039244: Don't use UINT32_FORMAT and INT32_FORMAT when printing uints and ints in the GC code
stefank
parents: 14584
diff changeset
   154
                   msg, offset, (uint)N_words));
14584
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13481
diff changeset
   155
  }
bd4290e6d0a5 7194633: G1: Assertion and guarantee failures in block offset table
johnc
parents: 13481
diff changeset
   156
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   157
  // Bounds checking accessors:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   158
  // 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
   159
  inline u_char offset_array(size_t index) const;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   160
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   161
  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
   162
    _offset_array[index] = offset;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   163
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   164
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   165
  inline void set_offset_array(size_t index, u_char offset);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   166
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   167
  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
   168
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   169
  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
   170
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   171
  bool is_card_boundary(HeapWord* p) const;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   172
30583
74ff3d21d616 8079330: Circular dependency between G1CollectedHeap and G1BlockOffsetSharedArray
pliden
parents: 30579
diff changeset
   173
  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
   174
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   175
public:
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   176
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   177
  // Return the number of slots needed for an offset array
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   178
  // that covers mem_region_words words.
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   179
  static size_t compute_size(size_t mem_region_words) {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   180
    size_t number_of_slots = (mem_region_words / N_words);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   181
    return ReservedSpace::allocation_align_size_up(number_of_slots);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   182
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   183
30565
ebd5af27fe02 8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents: 27149
diff changeset
   184
  // 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
   185
  static size_t heap_map_factor() {
ebd5af27fe02 8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents: 27149
diff changeset
   186
    return N_bytes;
ebd5af27fe02 8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents: 27149
diff changeset
   187
  }
ebd5af27fe02 8073632: Make auxiliary data structures know their own translation factor
tschatzl
parents: 27149
diff changeset
   188
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   189
  enum SomePublicConstants {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   190
    LogN = 9,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   191
    LogN_words = LogN - LogHeapWordSize,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   192
    N_bytes = 1 << LogN,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   193
    N_words = 1 << LogN_words
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   194
  };
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   195
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   196
  // Initialize the table to cover from "base" to (at least)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   197
  // "base + init_word_size".  In the future, the table may be expanded
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   198
  // (see "resize" below) up to the size of "_reserved" (which must be at
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   199
  // least "init_word_size".) The contents of the initial table are
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   200
  // undefined; it is the responsibility of the constituent
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   201
  // G1BlockOffsetTable(s) to initialize cards.
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   202
  G1BlockOffsetSharedArray(MemRegion heap, G1RegionToSpaceMapper* storage);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   203
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   204
  // Return the appropriate index into "_offset_array" for "p".
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   205
  inline size_t index_for(const void* p) const;
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   206
  inline size_t index_for_raw(const void* p) const;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   207
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   208
  // Return the address indicating the start of the region corresponding to
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   209
  // "index" in "_offset_array".
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   210
  inline HeapWord* address_for_index(size_t index) const;
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   211
  // 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
   212
  inline HeapWord* address_for_index_raw(size_t index) const {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   213
    return _reserved.start() + (index << LogN_words);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   214
  }
1374
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
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   217
// And here is the G1BlockOffsetTable subtype that uses the array.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   218
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   219
class G1BlockOffsetArray: public G1BlockOffsetTable {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   220
  friend class G1BlockOffsetSharedArray;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   221
  friend class G1BlockOffsetArrayContigSpace;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   222
  friend class VMStructs;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   223
private:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   224
  enum SomePrivateConstants {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   225
    N_words = G1BlockOffsetSharedArray::N_words,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   226
    LogN    = G1BlockOffsetSharedArray::LogN
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
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   229
  // This is the array, which can be shared by several BlockOffsetArray's
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   230
  // servicing different
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   231
  G1BlockOffsetSharedArray* _array;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   232
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   233
  // The space that owns this subregion.
25361
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 24424
diff changeset
   234
  G1OffsetTableContigSpace* _gsp;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   235
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   236
  // The portion [_unallocated_block, _sp.end()) of the space that
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   237
  // is a single block known not to contain any objects.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   238
  // NOTE: See BlockOffsetArrayUseUnallocatedBlock flag.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   239
  HeapWord* _unallocated_block;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   240
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   241
  // Sets the entries
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   242
  // corresponding to the cards starting at "start" and ending at "end"
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   243
  // 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
   244
  // is right-open.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   245
  void set_remainder_to_point_to_start(HeapWord* start, HeapWord* end);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   246
  // 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
   247
  // that is closed: [start_index, end_index]
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   248
  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
   249
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   250
protected:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   251
25361
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 24424
diff changeset
   252
  G1OffsetTableContigSpace* gsp() const { return _gsp; }
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 24424
diff changeset
   253
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 24424
diff changeset
   254
  inline size_t block_size(const HeapWord* p) const;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   255
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   256
  // 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
   257
  // 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
   258
  // in the array.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   259
  inline HeapWord* block_at_or_preceding(const void* addr,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   260
                                         bool has_max_index,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   261
                                         size_t max_index) const;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   262
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   263
  // "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
   264
  // 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
   265
  // beginning of the block that contains "addr".  Does so without side
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   266
  // effects (see, e.g., spec of  block_start.)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   267
  inline HeapWord*
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   268
  forward_to_block_containing_addr_const(HeapWord* q, HeapWord* n,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   269
                                         const void* addr) const;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   270
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   271
  // "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
   272
  // beginning of the block that contains "addr".  May have side effects
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   273
  // on "this", by updating imprecise entries.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   274
  inline HeapWord* forward_to_block_containing_addr(HeapWord* q,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   275
                                                    const void* addr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   276
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   277
  // "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
   278
  // 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
   279
  // beginning of the block that contains "addr".  May have side effects
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   280
  // on "this", by updating imprecise entries.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   281
  HeapWord* forward_to_block_containing_addr_slow(HeapWord* q,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   282
                                                  HeapWord* n,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   283
                                                  const void* addr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   284
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   285
  // Requires that "*threshold_" be the first array entry boundary at or
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   286
  // above "blk_start", and that "*index_" be the corresponding array
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   287
  // index.  If the block starts at or crosses "*threshold_", records
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   288
  // "blk_start" as the appropriate block start for the array index
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   289
  // starting at "*threshold_", and for any other indices crossed by the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   290
  // block.  Updates "*threshold_" and "*index_" to correspond to the first
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   291
  // index after the block end.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   292
  void alloc_block_work2(HeapWord** threshold_, size_t* index_,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   293
                         HeapWord* blk_start, HeapWord* blk_end);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   294
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   295
public:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   296
  // The space may not have it's bottom and top set yet, which is why the
26322
3e4ef23b8ee3 8055816: Remove dead code in g1BlockOffsetTable
brutisso
parents: 26160
diff changeset
   297
  // region is passed as a parameter. The elements of the array are
3e4ef23b8ee3 8055816: Remove dead code in g1BlockOffsetTable
brutisso
parents: 26160
diff changeset
   298
  // initialized to zero.
3e4ef23b8ee3 8055816: Remove dead code in g1BlockOffsetTable
brutisso
parents: 26160
diff changeset
   299
  G1BlockOffsetArray(G1BlockOffsetSharedArray* array, MemRegion mr);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   300
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   301
  // Note: this ought to be part of the constructor, but that would require
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   302
  // "this" to be passed as a parameter to a member constructor for
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   303
  // the containing concrete subtype of Space.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   304
  // This would be legal C++, but MS VC++ doesn't allow it.
25361
5146d1e12a2f 8047820: G1 Block offset table does not need to support generic Space classes
mgerdin
parents: 24424
diff changeset
   305
  void set_space(G1OffsetTableContigSpace* sp);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   306
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   307
  // Resets the covered region to one with the same _bottom as before but
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   308
  // the "new_word_size".
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   309
  void resize(size_t new_word_size);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   310
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   311
  virtual HeapWord* block_start_unsafe(const void* addr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   312
  virtual HeapWord* block_start_unsafe_const(const void* addr) const;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   313
26571
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   314
  void check_all_cards(size_t left_card, size_t right_card) const;
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   315
26571
5fe42815e865 8025564: gc/memory/UniThread/Linear1 times out during heap verification
brutisso
parents: 26322
diff changeset
   316
  void verify() const;
6983
a8c50cedbce9 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 5547
diff changeset
   317
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   318
  virtual void print_on(outputStream* out) PRODUCT_RETURN;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   319
};
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   320
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   321
// A subtype of BlockOffsetArray that takes advantage of the fact
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   322
// that its underlying space is a ContiguousSpace, so that its "active"
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   323
// region can be more efficiently tracked (than for a non-contiguous space).
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   324
class G1BlockOffsetArrayContigSpace: public G1BlockOffsetArray {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   325
  friend class VMStructs;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   326
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   327
  // allocation boundary at which offset array must be updated
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   328
  HeapWord* _next_offset_threshold;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   329
  size_t    _next_offset_index;      // index corresponding to that boundary
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   330
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   331
  // Work function to be called when allocation start crosses the next
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   332
  // threshold in the contig space.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   333
  void alloc_block_work1(HeapWord* blk_start, HeapWord* blk_end) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   334
    alloc_block_work2(&_next_offset_threshold, &_next_offset_index,
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   335
                      blk_start, blk_end);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   336
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   337
26322
3e4ef23b8ee3 8055816: Remove dead code in g1BlockOffsetTable
brutisso
parents: 26160
diff changeset
   338
  // Zero out the entry for _bottom (offset will be zero). Does not check for availability of the
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   339
  // memory first.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   340
  void zero_bottom_entry_raw();
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   341
  // Variant of initialize_threshold that does not check for availability of the
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   342
  // memory first.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   343
  HeapWord* initialize_threshold_raw();
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   344
 public:
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   345
  G1BlockOffsetArrayContigSpace(G1BlockOffsetSharedArray* array, MemRegion mr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   346
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   347
  // Initialize the threshold to reflect the first boundary after the
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   348
  // bottom of the covered region.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   349
  HeapWord* initialize_threshold();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   350
26157
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 25361
diff changeset
   351
  void reset_bot() {
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   352
    zero_bottom_entry_raw();
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents: 26157
diff changeset
   353
    initialize_threshold_raw();
26157
70eddb655686 8054818: Refactor HeapRegionSeq to manage heap region and auxiliary data
tschatzl
parents: 25361
diff changeset
   354
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   355
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   356
  // 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
   357
  // updated.
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   358
  HeapWord* threshold() const { return _next_offset_threshold; }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   359
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   360
  // These must be guaranteed to work properly (i.e., do nothing)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   361
  // when "blk_start" ("blk" for second version) is "NULL".  In this
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   362
  // 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
   363
  // never exceeds the "_next_offset_threshold".
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   364
  void alloc_block(HeapWord* blk_start, HeapWord* blk_end) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   365
    if (blk_end > _next_offset_threshold)
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   366
      alloc_block_work1(blk_start, blk_end);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   367
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   368
  void alloc_block(HeapWord* blk, size_t size) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   369
     alloc_block(blk, blk+size);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   370
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   371
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   372
  HeapWord* block_start_unsafe(const void* addr);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   373
  HeapWord* block_start_unsafe_const(const void* addr) const;
6983
a8c50cedbce9 6991377: G1: race between concurrent refinement and humongous object allocation
tonyp
parents: 5547
diff changeset
   374
7904
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   375
  void set_for_starts_humongous(HeapWord* new_top);
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   376
e90e097fced4 7007068: G1: refine the BOT during evac failure handling
tonyp
parents: 7397
diff changeset
   377
  virtual void print_on(outputStream* out) PRODUCT_RETURN;
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents:
diff changeset
   378
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
   379
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6983
diff changeset
   380
#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1BLOCKOFFSETTABLE_HPP