hotspot/src/share/vm/gc_implementation/g1/g1PageBasedVirtualSpace.cpp
author sjohanss
Mon, 12 Jan 2015 15:24:29 +0100
changeset 28482 e1a8d03c342f
parent 28208 d67f748ece0a
child 30158 bd6094906ef8
permissions -rw-r--r--
8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit Summary: Making sure committed memory is cleared when re-committed, even if using large pages. Reviewed-by: kbarrett, tschatzl
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
     1
/*
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
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"
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    26
#include "gc_implementation/g1/g1PageBasedVirtualSpace.hpp"
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    27
#include "oops/markOop.hpp"
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    28
#include "oops/oop.inline.hpp"
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    29
#include "services/memTracker.hpp"
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    30
#ifdef TARGET_OS_FAMILY_linux
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    31
# include "os_linux.inline.hpp"
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    32
#endif
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    33
#ifdef TARGET_OS_FAMILY_solaris
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    34
# include "os_solaris.inline.hpp"
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    35
#endif
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    36
#ifdef TARGET_OS_FAMILY_windows
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    37
# include "os_windows.inline.hpp"
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    38
#endif
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    39
#ifdef TARGET_OS_FAMILY_aix
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    40
# include "os_aix.inline.hpp"
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    41
#endif
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    42
#ifdef TARGET_OS_FAMILY_bsd
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    43
# include "os_bsd.inline.hpp"
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    44
#endif
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    45
#include "utilities/bitMap.inline.hpp"
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    46
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    47
G1PageBasedVirtualSpace::G1PageBasedVirtualSpace() : _low_boundary(NULL),
28482
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
    48
  _high_boundary(NULL), _committed(), _page_size(0), _special(false),
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
    49
  _dirty(), _executable(false) {
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    50
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    51
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    52
bool G1PageBasedVirtualSpace::initialize_with_granularity(ReservedSpace rs, size_t page_size) {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    53
  if (!rs.is_reserved()) {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    54
    return false;  // Allocation failed.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    55
  }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    56
  assert(_low_boundary == NULL, "VirtualSpace already initialized");
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    57
  assert(page_size > 0, "Granularity must be non-zero.");
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    58
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    59
  _low_boundary  = rs.base();
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    60
  _high_boundary = _low_boundary + rs.size();
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    61
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    62
  _special = rs.special();
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    63
  _executable = rs.executable();
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    64
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    65
  _page_size = page_size;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    66
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    67
  assert(_committed.size() == 0, "virtual space initialized more than once");
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    68
  uintx size_in_bits = rs.size() / page_size;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    69
  _committed.resize(size_in_bits, /* in_resource_area */ false);
28482
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
    70
  if (_special) {
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
    71
    _dirty.resize(size_in_bits, /* in_resource_area */ false);
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
    72
  }
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    73
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    74
  return true;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    75
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    76
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    77
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    78
G1PageBasedVirtualSpace::~G1PageBasedVirtualSpace() {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    79
  release();
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    80
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    81
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    82
void G1PageBasedVirtualSpace::release() {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    83
  // This does not release memory it never reserved.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    84
  // Caller must release via rs.release();
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    85
  _low_boundary           = NULL;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    86
  _high_boundary          = NULL;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    87
  _special                = false;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    88
  _executable             = false;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    89
  _page_size              = 0;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    90
  _committed.resize(0, false);
28482
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
    91
  _dirty.resize(0, false);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    92
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    93
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    94
size_t G1PageBasedVirtualSpace::committed_size() const {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    95
  return _committed.count_one_bits() * _page_size;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    96
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    97
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    98
size_t G1PageBasedVirtualSpace::reserved_size() const {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
    99
  return pointer_delta(_high_boundary, _low_boundary, sizeof(char));
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   100
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   101
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   102
size_t G1PageBasedVirtualSpace::uncommitted_size()  const {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   103
  return reserved_size() - committed_size();
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   104
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   105
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   106
uintptr_t G1PageBasedVirtualSpace::addr_to_page_index(char* addr) const {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   107
  return (addr - _low_boundary) / _page_size;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   108
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   109
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   110
bool G1PageBasedVirtualSpace::is_area_committed(uintptr_t start, size_t size_in_pages) const {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   111
  uintptr_t end = start + size_in_pages;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   112
  return _committed.get_next_zero_offset(start, end) >= end;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   113
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   114
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   115
bool G1PageBasedVirtualSpace::is_area_uncommitted(uintptr_t start, size_t size_in_pages) const {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   116
  uintptr_t end = start + size_in_pages;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   117
  return _committed.get_next_one_offset(start, end) >= end;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   118
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   119
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   120
char* G1PageBasedVirtualSpace::page_start(uintptr_t index) {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   121
  return _low_boundary + index * _page_size;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   122
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   123
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   124
size_t G1PageBasedVirtualSpace::byte_size_for_pages(size_t num) {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   125
  return num * _page_size;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   126
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   127
28482
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
   128
bool G1PageBasedVirtualSpace::commit(uintptr_t start, size_t size_in_pages) {
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   129
  // We need to make sure to commit all pages covered by the given area.
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   130
  guarantee(is_area_uncommitted(start, size_in_pages), "Specified area is not uncommitted");
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   131
28482
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
   132
  bool zero_filled = true;
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
   133
  uintptr_t end = start + size_in_pages;
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
   134
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
   135
  if (_special) {
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
   136
    // Check for dirty pages and update zero_filled if any found.
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
   137
    if (_dirty.get_next_one_offset(start,end) < end) {
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
   138
      zero_filled = false;
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
   139
      _dirty.clear_range(start, end);
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
   140
    }
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
   141
  } else {
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   142
    os::commit_memory_or_exit(page_start(start), byte_size_for_pages(size_in_pages), _executable,
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   143
                              err_msg("Failed to commit pages from "SIZE_FORMAT" of length "SIZE_FORMAT, start, size_in_pages));
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   144
  }
28482
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
   145
  _committed.set_range(start, end);
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   146
28208
d67f748ece0a 8067469: G1 ignores AlwaysPreTouch
tschatzl
parents: 26162
diff changeset
   147
  if (AlwaysPreTouch) {
28482
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
   148
    os::pretouch_memory(page_start(start), page_start(end));
28208
d67f748ece0a 8067469: G1 ignores AlwaysPreTouch
tschatzl
parents: 26162
diff changeset
   149
  }
28482
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
   150
  return zero_filled;
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   151
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   152
28482
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
   153
void G1PageBasedVirtualSpace::uncommit(uintptr_t start, size_t size_in_pages) {
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   154
  guarantee(is_area_committed(start, size_in_pages), "checking");
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   155
28482
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
   156
  if (_special) {
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
   157
    // Mark that memory is dirty. If committed again the memory might
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
   158
    // need to be cleared explicitly.
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
   159
    _dirty.set_range(start, start + size_in_pages);
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
   160
  } else {
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   161
    os::uncommit_memory(page_start(start), byte_size_for_pages(size_in_pages));
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   162
  }
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   163
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   164
  _committed.clear_range(start, start + size_in_pages);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   165
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   166
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   167
bool G1PageBasedVirtualSpace::contains(const void* p) const {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   168
  return _low_boundary <= (const char*) p && (const char*) p < _high_boundary;
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   169
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   170
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   171
#ifndef PRODUCT
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   172
void G1PageBasedVirtualSpace::print_on(outputStream* out) {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   173
  out->print   ("Virtual space:");
28482
e1a8d03c342f 8062063: Usage of UseHugeTLBFS, UseLargePagesInMetaspace and huge SurvivorAlignmentInBytes cause crashes in CMBitMapClosure::do_bit
sjohanss
parents: 28208
diff changeset
   174
  if (_special) out->print(" (pinned in memory)");
26160
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   175
  out->cr();
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   176
  out->print_cr(" - committed: " SIZE_FORMAT, committed_size());
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   177
  out->print_cr(" - reserved:  " SIZE_FORMAT, reserved_size());
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   178
  out->print_cr(" - [low_b, high_b]: [" INTPTR_FORMAT ", " INTPTR_FORMAT "]",  p2i(_low_boundary), p2i(_high_boundary));
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   179
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   180
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   181
void G1PageBasedVirtualSpace::print() {
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   182
  print_on(tty);
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   183
}
aba6b01cb988 8038423: G1: Decommit memory within heap
tschatzl
parents:
diff changeset
   184
#endif