src/hotspot/os/bsd/gc/z/zBackingFile_bsd.hpp
author eosterlund
Tue, 12 Nov 2019 09:27:21 +0000
changeset 59026 f51714d3385d
permissions -rw-r--r--
8224817: Implementation of JEP 364: ZGC on macOS Reviewed-by: pliden, stefank
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
59026
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
     1
/*
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
     4
 *
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
     8
 *
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    13
 * accompanied this code).
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    14
 *
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    18
 *
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    21
 * questions.
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    22
 */
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    23
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    24
#ifndef OS_BSD_GC_Z_ZBACKINGFILE_BSD_HPP
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    25
#define OS_BSD_GC_Z_ZBACKINGFILE_BSD_HPP
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    26
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    27
#include "memory/allocation.hpp"
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    28
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    29
class ZPhysicalMemory;
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    30
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    31
// On macOS, we use a virtual backing file. It is represented by a reserved virtual
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    32
// address space, in which we commit physical memory using the mach_vm_map() API.
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    33
// The multi-mapping API simply remaps these addresses using mach_vm_remap() into
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    34
// the different heap views. This works as-if there was a backing file, it's just
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    35
// that the file is represented with memory mappings instead.
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    36
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    37
class ZBackingFile {
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    38
private:
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    39
  uintptr_t _base;
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    40
  size_t    _size;
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    41
  bool      _initialized;
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    42
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    43
  bool commit_inner(size_t offset, size_t length);
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    44
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    45
public:
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    46
  ZBackingFile();
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    47
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    48
  bool is_initialized() const;
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    49
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    50
  size_t size() const;
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    51
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    52
  size_t commit(size_t offset, size_t length);
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    53
  size_t uncommit(size_t offset, size_t length);
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    54
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    55
  void map(uintptr_t addr, size_t size, uintptr_t offset) const;
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    56
  void unmap(uintptr_t addr, size_t size) const;
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    57
};
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    58
f51714d3385d 8224817: Implementation of JEP 364: ZGC on macOS
eosterlund
parents:
diff changeset
    59
#endif // OS_BSD_GC_Z_ZBACKINGFILE_BSD_HPP