1 /* |
1 /* |
2 * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. |
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. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
68 friend class VMStructs; |
68 friend class VMStructs; |
69 |
69 |
70 private: |
70 private: |
71 ZPhysicalMemoryBacking _backing; |
71 ZPhysicalMemoryBacking _backing; |
72 const size_t _max_capacity; |
72 const size_t _max_capacity; |
|
73 size_t _current_max_capacity; |
73 size_t _capacity; |
74 size_t _capacity; |
74 size_t _used; |
75 size_t _used; |
75 |
|
76 bool ensure_available(size_t size); |
|
77 |
76 |
78 void nmt_commit(ZPhysicalMemory pmem, uintptr_t offset); |
77 void nmt_commit(ZPhysicalMemory pmem, uintptr_t offset); |
79 void nmt_uncommit(ZPhysicalMemory pmem, uintptr_t offset); |
78 void nmt_uncommit(ZPhysicalMemory pmem, uintptr_t offset); |
80 |
79 |
81 public: |
80 public: |
82 ZPhysicalMemoryManager(size_t max_capacity, size_t granule_size); |
81 ZPhysicalMemoryManager(size_t max_capacity, size_t granule_size); |
83 |
82 |
84 bool is_initialized() const; |
83 bool is_initialized() const; |
85 |
84 |
86 size_t max_capacity() const; |
85 size_t max_capacity() const; |
|
86 size_t current_max_capacity() const; |
87 size_t capacity() const; |
87 size_t capacity() const; |
88 size_t used() const; |
88 size_t unused_capacity() const; |
89 size_t available() const; |
89 |
|
90 void try_ensure_unused_capacity(size_t size); |
90 |
91 |
91 ZPhysicalMemory alloc(size_t size); |
92 ZPhysicalMemory alloc(size_t size); |
92 void free(ZPhysicalMemory pmem); |
93 void free(ZPhysicalMemory pmem); |
93 |
94 |
94 void map(ZPhysicalMemory pmem, uintptr_t offset); |
95 void map(ZPhysicalMemory pmem, uintptr_t offset); |