| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_ALLOCATOR_PARTITION_ALLOCATOR_PAGE_ALLOCATOR_H | 5 #ifndef BASE_ALLOCATOR_PARTITION_ALLOCATOR_PAGE_ALLOCATOR_H |
| 6 #define BASE_ALLOCATOR_PARTITION_ALLOCATOR_PAGE_ALLOCATOR_H | 6 #define BASE_ALLOCATOR_PARTITION_ALLOCATOR_PAGE_ALLOCATOR_H |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <cstddef> | 10 #include <cstddef> |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 // The pages will be readable and writeable. | 68 // The pages will be readable and writeable. |
| 69 // len must be a multiple of kSystemPageSize bytes. | 69 // len must be a multiple of kSystemPageSize bytes. |
| 70 // The result bool value indicates whether the permission | 70 // The result bool value indicates whether the permission |
| 71 // change succeeded or not. You must check the result | 71 // change succeeded or not. You must check the result |
| 72 // (in most cases you need to CHECK that it is true). | 72 // (in most cases you need to CHECK that it is true). |
| 73 BASE_EXPORT WARN_UNUSED_RESULT bool SetSystemPagesAccessible(void* address, | 73 BASE_EXPORT WARN_UNUSED_RESULT bool SetSystemPagesAccessible(void* address, |
| 74 size_t length); | 74 size_t length); |
| 75 | 75 |
| 76 // Decommit one or more system pages. Decommitted means that the physical memory | 76 // Decommit one or more system pages. Decommitted means that the physical memory |
| 77 // is released to the system, but the virtual address space remains reserved. | 77 // is released to the system, but the virtual address space remains reserved. |
| 78 // System pages are re-committed by calling recommitSystemPages(). Touching | 78 // System pages are re-committed by calling RecommitSystemPages(). Touching |
| 79 // a decommitted page _may_ fault. | 79 // a decommitted page _may_ fault. |
| 80 // Clients should not make any assumptions about the contents of decommitted | 80 // Clients should not make any assumptions about the contents of decommitted |
| 81 // system pages, before or after they write to the page. The only guarantee | 81 // system pages, before or after they write to the page. The only guarantee |
| 82 // provided is that the contents of the system page will be deterministic again | 82 // provided is that the contents of the system page will be deterministic again |
| 83 // after recommitting and writing to it. In particlar note that system pages are | 83 // after recommitting and writing to it. In particlar note that system pages are |
| 84 // not guaranteed to be zero-filled upon re-commit. len must be a multiple of | 84 // not guaranteed to be zero-filled upon re-commit. |len| must be a multiple of |
| 85 // kSystemPageSize bytes. | 85 // |kSystemPageSize| bytes. |
| 86 BASE_EXPORT void DecommitSystemPages(void* address, size_t length); | 86 // |
| 87 // |purge_hint| is an optional hint to signal that the system pages can |
| 88 // be discarded from process memory right away. By supplying |true|, the |
| 89 // implementation makes an OS-specific best effort to decommit the system pages |
| 90 // sooner from the process. Even with |purge_hint| set to |true|, it is not |
| 91 // guaranteed that the decommitted system pages will be zero-filled upon |
| 92 // recommit. |
| 93 BASE_EXPORT void DecommitSystemPages(void* address, |
| 94 size_t length, |
| 95 bool purge_hint = false); |
| 87 | 96 |
| 88 // Recommit one or more system pages. Decommitted system pages must be | 97 // Recommit one or more system pages. Decommitted system pages must be |
| 89 // recommitted before they are read are written again. | 98 // recommitted before they are read are written again. |
| 90 // Note that this operation may be a no-op on some platforms. | 99 // Note that this operation may be a no-op on some platforms. |
| 91 // len must be a multiple of kSystemPageSize bytes. | 100 // len must be a multiple of kSystemPageSize bytes. |
| 92 BASE_EXPORT void RecommitSystemPages(void* address, size_t length); | 101 BASE_EXPORT void RecommitSystemPages(void* address, size_t length); |
| 93 | 102 |
| 94 // Discard one or more system pages. Discarding is a hint to the system that | 103 // Discard one or more system pages. Discarding is a hint to the system that |
| 95 // the page is no longer required. The hint may: | 104 // the page is no longer required. The hint may: |
| 96 // - Do nothing. | 105 // - Do nothing. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 115 ALWAYS_INLINE uintptr_t RoundDownToSystemPage(uintptr_t address) { | 124 ALWAYS_INLINE uintptr_t RoundDownToSystemPage(uintptr_t address) { |
| 116 return address & kSystemPageBaseMask; | 125 return address & kSystemPageBaseMask; |
| 117 } | 126 } |
| 118 | 127 |
| 119 // Returns errno (or GetLastError code) when mmap (or VirtualAlloc) fails. | 128 // Returns errno (or GetLastError code) when mmap (or VirtualAlloc) fails. |
| 120 BASE_EXPORT uint32_t GetAllocPageErrorCode(); | 129 BASE_EXPORT uint32_t GetAllocPageErrorCode(); |
| 121 | 130 |
| 122 } // namespace base | 131 } // namespace base |
| 123 | 132 |
| 124 #endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_PAGE_ALLOCATOR_H | 133 #endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_PAGE_ALLOCATOR_H |
| OLD | NEW |