src/hotspot/share/gc/parallel/psFileBackedVirtualspace.cpp
author phh
Sat, 30 Nov 2019 14:33:05 -0800
changeset 59330 5b96c12f909d
parent 54264 41af8d0546bc
permissions -rw-r--r--
8234541: C1 emits an empty message when it inlines successfully Summary: Use "inline" as the message when successfull Reviewed-by: thartmann, mdoerr Contributed-by: navy.xliu@gmail.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
53117
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
     1
/*
54264
41af8d0546bc 8221260: Initialize more class members on construction, remove some unused ones
lkorinth
parents: 53117
diff changeset
     2
 * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
53117
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
     4
 *
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
     7
 * published by the Free Software Foundation.
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
     8
 *
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    13
 * accompanied this code).
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    14
 *
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    18
 *
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    21
 * questions.
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    22
 *
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    23
 */
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    24
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    25
#include "precompiled.hpp"
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    26
#include "gc/parallel/psFileBackedVirtualspace.hpp"
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    27
#include "memory/virtualspace.hpp"
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    28
#include "runtime/os.inline.hpp"
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    29
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    30
PSFileBackedVirtualSpace::PSFileBackedVirtualSpace(ReservedSpace rs, size_t alignment, const char* path) : PSVirtualSpace(rs, alignment),
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    31
                                                   _file_path(path), _fd(-1), _mapping_succeeded(false) {
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    32
  assert(!rs.special(), "ReservedSpace passed to PSFileBackedVirtualSpace cannot be special");
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    33
}
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    34
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    35
bool PSFileBackedVirtualSpace::initialize() {
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    36
  _fd = os::create_file_for_heap(_file_path);
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    37
  if (_fd == -1) {
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    38
    return false;
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    39
  }
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    40
  // We map the reserved space to a file at initialization.
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    41
  char* ret = os::replace_existing_mapping_with_file_mapping(reserved_low_addr(), reserved_size(), _fd);
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    42
  if (ret != reserved_low_addr()) {
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    43
    os::close(_fd);
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    44
    return false;
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    45
  }
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    46
  // _mapping_succeeded is false if we return before this point.
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    47
  // expand calls later check value of this flag and return error if it is false.
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    48
  _mapping_succeeded = true;
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    49
  _special = true;
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    50
  os::close(_fd);
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    51
  return true;
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    52
}
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    53
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    54
bool PSFileBackedVirtualSpace::expand_by(size_t bytes) {
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    55
  assert(special(), "Since entire space is committed at initialization, _special should always be true for PSFileBackedVirtualSpace");
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    56
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    57
  // if mapping did not succeed during intialization return false
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    58
  if (!_mapping_succeeded) {
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    59
    return false;
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    60
  }
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    61
  return PSVirtualSpace::expand_by(bytes);
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    62
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    63
}
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    64
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    65
bool PSFileBackedVirtualSpace::shrink_by(size_t bytes) {
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    66
  assert(special(), "Since entire space is committed at initialization, _special should always be true for PSFileBackedVirtualSpace");
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    67
  return PSVirtualSpace::shrink_by(bytes);
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    68
}
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    69
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    70
size_t PSFileBackedVirtualSpace::expand_into(PSVirtualSpace* space, size_t bytes) {
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    71
  // not supported. Since doing this will change page mapping which will lead to large TLB penalties.
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    72
  assert(false, "expand_into() should not be called for PSFileBackedVirtualSpace");
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    73
  return 0;
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    74
}
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    75
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    76
void PSFileBackedVirtualSpace::release() {
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    77
  os::close(_fd);
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    78
  _fd = -1;
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    79
  _file_path = NULL;
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    80
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    81
  PSVirtualSpace::release();
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    82
}
37930c6ba6d7 8211424: Allocation of old generation of java heap on alternate memory devices - Parallel GC
sangheki
parents:
diff changeset
    83