1 /*
2 * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
61 void add_segment(ZPhysicalMemorySegment segment);
62
63 ZPhysicalMemory split(size_t size);
64 void clear();
65 };
66
67 class ZPhysicalMemoryManager {
68 friend class VMStructs;
69
70 private:
71 ZPhysicalMemoryBacking _backing;
72 const size_t _max_capacity;
73 size_t _current_max_capacity;
74 size_t _capacity;
75 size_t _used;
76
77 void nmt_commit(ZPhysicalMemory pmem, uintptr_t offset);
78 void nmt_uncommit(ZPhysicalMemory pmem, uintptr_t offset);
79
80 public:
81 ZPhysicalMemoryManager(size_t max_capacity, size_t granule_size);
82
83 bool is_initialized() const;
84
85 size_t max_capacity() const;
86 size_t current_max_capacity() const;
87 size_t capacity() const;
88 size_t unused_capacity() const;
89
90 void try_ensure_unused_capacity(size_t size);
91
92 ZPhysicalMemory alloc(size_t size);
93 void free(ZPhysicalMemory pmem);
94
95 void map(ZPhysicalMemory pmem, uintptr_t offset);
96 void unmap(ZPhysicalMemory pmem, uintptr_t offset);
97 void flip(ZPhysicalMemory pmem, uintptr_t offset);
98 };
99
100 #endif // SHARE_GC_Z_ZPHYSICALMEMORY_HPP
|
1 /*
2 * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
61 void add_segment(ZPhysicalMemorySegment segment);
62
63 ZPhysicalMemory split(size_t size);
64 void clear();
65 };
66
67 class ZPhysicalMemoryManager {
68 friend class VMStructs;
69
70 private:
71 ZPhysicalMemoryBacking _backing;
72 const size_t _max_capacity;
73 size_t _current_max_capacity;
74 size_t _capacity;
75 size_t _used;
76
77 void nmt_commit(ZPhysicalMemory pmem, uintptr_t offset);
78 void nmt_uncommit(ZPhysicalMemory pmem, uintptr_t offset);
79
80 public:
81 ZPhysicalMemoryManager(size_t max_capacity);
82
83 bool is_initialized() const;
84
85 size_t max_capacity() const;
86 size_t current_max_capacity() const;
87 size_t capacity() const;
88 size_t unused_capacity() const;
89
90 void try_ensure_unused_capacity(size_t size);
91
92 ZPhysicalMemory alloc(size_t size);
93 void free(ZPhysicalMemory pmem);
94
95 void map(ZPhysicalMemory pmem, uintptr_t offset);
96 void unmap(ZPhysicalMemory pmem, uintptr_t offset);
97 void flip(ZPhysicalMemory pmem, uintptr_t offset);
98 };
99
100 #endif // SHARE_GC_Z_ZPHYSICALMEMORY_HPP
|