src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp
author tschatzl
Wed, 08 Aug 2018 15:31:06 +0200
changeset 51332 c25572739e7c
parent 47216 71c04702a3d5
child 53116 bb03098c4dde
permissions -rw-r--r--
8208669: GC changes to allow enabling -Wreorder Reviewed-by: kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
     1
/*
46745
f7b9bb98bb72 8176571: Fine bitmaps should be allocated as belonging to mtGC, not mtInternal
kbarrett
parents: 46625
diff changeset
     2
 * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
     4
 *
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
     7
 * published by the Free Software Foundation.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
     8
 *
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    13
 * accompanied this code).
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    14
 *
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    18
 *
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    21
 * questions.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    22
 *
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    23
 */
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    24
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    25
#include "precompiled.hpp"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30291
diff changeset
    26
#include "gc/g1/g1BiasedArray.hpp"
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30291
diff changeset
    27
#include "gc/g1/g1RegionToSpaceMapper.hpp"
26163
89f44df5b438 8055635: Missing include in g1RegionToSpaceMapper.hpp results in unresolved symbol of fastdebug build without precompiled headers
tschatzl
parents: 26160
diff changeset
    28
#include "memory/allocation.inline.hpp"
30291
54cdc5c1a9cb 8068352: Move virtualspace.* out of src/share/vm/runtime to memory directory
coleenp
parents: 30158
diff changeset
    29
#include "memory/virtualspace.hpp"
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    30
#include "services/memTracker.hpp"
46625
edefffab74e2 8183552: Move align functions to align.hpp
stefank
parents: 46619
diff changeset
    31
#include "utilities/align.hpp"
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    32
#include "utilities/bitMap.inline.hpp"
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    33
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    34
G1RegionToSpaceMapper::G1RegionToSpaceMapper(ReservedSpace rs,
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
    35
                                             size_t used_size,
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
    36
                                             size_t page_size,
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    37
                                             size_t region_granularity,
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 33105
diff changeset
    38
                                             size_t commit_factor,
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    39
                                             MemoryType type) :
51332
c25572739e7c 8208669: GC changes to allow enabling -Wreorder
tschatzl
parents: 47216
diff changeset
    40
  _listener(NULL),
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
    41
  _storage(rs, used_size, page_size),
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    42
  _region_granularity(region_granularity),
46745
f7b9bb98bb72 8176571: Fine bitmaps should be allocated as belonging to mtGC, not mtInternal
kbarrett
parents: 46625
diff changeset
    43
  _commit_map(rs.size() * commit_factor / region_granularity, mtGC) {
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
    44
  guarantee(is_power_of_2(page_size), "must be");
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    45
  guarantee(is_power_of_2(region_granularity), "must be");
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    46
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    47
  MemTracker::record_virtual_memory_type((address)rs.base(), type);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    48
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    49
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    50
// G1RegionToSpaceMapper implementation where the region granularity is larger than
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    51
// or the same as the commit granularity.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    52
// Basically, the space corresponding to one region region spans several OS pages.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    53
class G1RegionsLargerThanCommitSizeMapper : public G1RegionToSpaceMapper {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    54
 private:
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    55
  size_t _pages_per_region;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    56
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    57
 public:
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    58
  G1RegionsLargerThanCommitSizeMapper(ReservedSpace rs,
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
    59
                                      size_t actual_size,
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
    60
                                      size_t page_size,
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    61
                                      size_t alloc_granularity,
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    62
                                      size_t commit_factor,
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    63
                                      MemoryType type) :
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 33105
diff changeset
    64
    G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, type),
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
    65
    _pages_per_region(alloc_granularity / (page_size * commit_factor)) {
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    66
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
    67
    guarantee(alloc_granularity >= page_size, "allocation granularity smaller than commit granularity");
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    68
  }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    69
41178
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
    70
  virtual void commit_regions(uint start_idx, size_t num_regions, WorkGang* pretouch_gang) {
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
    71
    size_t const start_page = (size_t)start_idx * _pages_per_region;
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
    72
    bool zero_filled = _storage.commit(start_page, num_regions * _pages_per_region);
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
    73
    if (AlwaysPreTouch) {
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
    74
      _storage.pretouch(start_page, num_regions * _pages_per_region, pretouch_gang);
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
    75
    }
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    76
    _commit_map.set_range(start_idx, start_idx + num_regions);
28482
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 27149
diff changeset
    77
    fire_on_commit(start_idx, num_regions, zero_filled);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    78
  }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    79
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
    80
  virtual void uncommit_regions(uint start_idx, size_t num_regions) {
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
    81
    _storage.uncommit((size_t)start_idx * _pages_per_region, num_regions * _pages_per_region);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    82
    _commit_map.clear_range(start_idx, start_idx + num_regions);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    83
  }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    84
};
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    85
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    86
// G1RegionToSpaceMapper implementation where the region granularity is smaller
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    87
// than the commit granularity.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    88
// Basically, the contents of one OS page span several regions.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    89
class G1RegionsSmallerThanCommitSizeMapper : public G1RegionToSpaceMapper {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    90
 private:
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    91
  class CommitRefcountArray : public G1BiasedMappedArray<uint> {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    92
   protected:
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    93
     virtual uint default_value() const { return 0; }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    94
  };
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    95
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    96
  size_t _regions_per_page;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    97
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    98
  CommitRefcountArray _refcounts;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    99
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   100
  uintptr_t region_idx_to_page_idx(uint region) const {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   101
    return region / _regions_per_page;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   102
  }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   103
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   104
 public:
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   105
  G1RegionsSmallerThanCommitSizeMapper(ReservedSpace rs,
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   106
                                       size_t actual_size,
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   107
                                       size_t page_size,
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   108
                                       size_t alloc_granularity,
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   109
                                       size_t commit_factor,
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   110
                                       MemoryType type) :
38177
b0c9cb06506b 8141501: Problems with BitMap buffer management
stefank
parents: 33105
diff changeset
   111
    G1RegionToSpaceMapper(rs, actual_size, page_size, alloc_granularity, commit_factor, type),
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   112
    _regions_per_page((page_size * commit_factor) / alloc_granularity), _refcounts() {
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   113
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   114
    guarantee((page_size * commit_factor) >= alloc_granularity, "allocation granularity smaller than commit granularity");
46619
a3919f5e8d2b 8178499: Remove _ptr_ and _size_ infixes from align functions
stefank
parents: 41178
diff changeset
   115
    _refcounts.initialize((HeapWord*)rs.base(), (HeapWord*)(rs.base() + align_up(rs.size(), page_size)), page_size);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   116
  }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   117
41178
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   118
  virtual void commit_regions(uint start_idx, size_t num_regions, WorkGang* pretouch_gang) {
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   119
    size_t const NoPage = ~(size_t)0;
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   120
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   121
    size_t first_committed = NoPage;
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   122
    size_t num_committed = 0;
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   123
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   124
    bool all_zero_filled = true;
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   125
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   126
    for (uint i = start_idx; i < start_idx + num_regions; i++) {
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 30764
diff changeset
   127
      assert(!_commit_map.at(i), "Trying to commit storage at region %u that is already committed", i);
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   128
      size_t idx = region_idx_to_page_idx(i);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   129
      uint old_refcount = _refcounts.get_by_index(idx);
41178
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   130
27149
9246fc481aa3 8059758: Footprint regressions with JDK-8038423
tschatzl
parents: 26163
diff changeset
   131
      bool zero_filled = false;
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   132
      if (old_refcount == 0) {
41178
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   133
        if (first_committed == NoPage) {
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   134
          first_committed = idx;
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   135
          num_committed = 1;
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   136
        } else {
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   137
          num_committed++;
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   138
        }
28482
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 27149
diff changeset
   139
        zero_filled = _storage.commit(idx, 1);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   140
      }
41178
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   141
      all_zero_filled &= zero_filled;
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   142
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   143
      _refcounts.set_by_index(idx, old_refcount + 1);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   144
      _commit_map.set_bit(i);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   145
    }
41178
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   146
    if (AlwaysPreTouch && num_committed > 0) {
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   147
      _storage.pretouch(first_committed, num_committed, pretouch_gang);
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   148
    }
e567be097315 8157952: Parallelize Memory Pretouch
tschatzl
parents: 38177
diff changeset
   149
    fire_on_commit(start_idx, num_regions, all_zero_filled);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   150
  }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   151
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   152
  virtual void uncommit_regions(uint start_idx, size_t num_regions) {
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   153
    for (uint i = start_idx; i < start_idx + num_regions; i++) {
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 30764
diff changeset
   154
      assert(_commit_map.at(i), "Trying to uncommit storage at region %u that is not committed", i);
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   155
      size_t idx = region_idx_to_page_idx(i);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   156
      uint old_refcount = _refcounts.get_by_index(idx);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   157
      assert(old_refcount > 0, "must be");
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   158
      if (old_refcount == 1) {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   159
        _storage.uncommit(idx, 1);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   160
      }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   161
      _refcounts.set_by_index(idx, old_refcount - 1);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   162
      _commit_map.clear_bit(i);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   163
    }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   164
  }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   165
};
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   166
27149
9246fc481aa3 8059758: Footprint regressions with JDK-8038423
tschatzl
parents: 26163
diff changeset
   167
void G1RegionToSpaceMapper::fire_on_commit(uint start_idx, size_t num_regions, bool zero_filled) {
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   168
  if (_listener != NULL) {
27149
9246fc481aa3 8059758: Footprint regressions with JDK-8038423
tschatzl
parents: 26163
diff changeset
   169
    _listener->on_commit(start_idx, num_regions, zero_filled);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   170
  }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   171
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   172
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   173
G1RegionToSpaceMapper* G1RegionToSpaceMapper::create_mapper(ReservedSpace rs,
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   174
                                                            size_t actual_size,
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   175
                                                            size_t page_size,
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   176
                                                            size_t region_granularity,
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   177
                                                            size_t commit_factor,
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   178
                                                            MemoryType type) {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   179
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   180
  if (region_granularity >= (page_size * commit_factor)) {
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   181
    return new G1RegionsLargerThanCommitSizeMapper(rs, actual_size, page_size, region_granularity, commit_factor, type);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   182
  } else {
30158
bd6094906ef8 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
tschatzl
parents: 28482
diff changeset
   183
    return new G1RegionsSmallerThanCommitSizeMapper(rs, actual_size, page_size, region_granularity, commit_factor, type);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   184
  }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   185
}