Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Side by Side Diff: base/allocator/partition_allocator/page_allocator.h

Issue 2614883006: Change PartitionAlloc to Chromium naming style. (Closed)
Patch Set: Rebase and fix some names. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 // The requested address is just a hint; the actual address returned may 42 // The requested address is just a hint; the actual address returned may
43 // differ. The returned address will be aligned at least to align bytes. 43 // differ. The returned address will be aligned at least to align bytes.
44 // len is in bytes, and must be a multiple of kPageAllocationGranularity. 44 // len is in bytes, and must be a multiple of kPageAllocationGranularity.
45 // align is in bytes, and must be a power-of-two multiple of 45 // align is in bytes, and must be a power-of-two multiple of
46 // kPageAllocationGranularity. 46 // kPageAllocationGranularity.
47 // If addr is null, then a suitable and randomized address will be chosen 47 // If addr is null, then a suitable and randomized address will be chosen
48 // automatically. 48 // automatically.
49 // PageAccessibilityConfiguration controls the permission of the 49 // PageAccessibilityConfiguration controls the permission of the
50 // allocated pages. 50 // allocated pages.
51 // This call will return null if the allocation cannot be satisfied. 51 // This call will return null if the allocation cannot be satisfied.
52 BASE_EXPORT void* allocPages(void* addr, 52 BASE_EXPORT void* AllocPages(void* address,
53 size_t len, 53 size_t len,
54 size_t align, 54 size_t align,
55 PageAccessibilityConfiguration); 55 PageAccessibilityConfiguration);
56 56
57 // Free one or more pages. 57 // Free one or more pages.
58 // addr and len must match a previous call to allocPages(). 58 // addr and len must match a previous call to allocPages().
59 BASE_EXPORT void freePages(void* addr, size_t len); 59 BASE_EXPORT void FreePages(void* address, size_t length);
60 60
61 // Mark one or more system pages as being inaccessible. 61 // Mark one or more system pages as being inaccessible.
62 // Subsequently accessing any address in the range will fault, and the 62 // Subsequently accessing any address in the range will fault, and the
63 // addresses will not be re-used by future allocations. 63 // addresses will not be re-used by future allocations.
64 // len must be a multiple of kSystemPageSize bytes. 64 // len must be a multiple of kSystemPageSize bytes.
65 BASE_EXPORT void setSystemPagesInaccessible(void* addr, size_t len); 65 BASE_EXPORT void SetSystemPagesInaccessible(void* address, size_t length);
66 66
67 // Mark one or more system pages as being accessible. 67 // Mark one or more system pages as being accessible.
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* addr, 73 BASE_EXPORT WARN_UNUSED_RESULT bool SetSystemPagesAccessible(void* address,
74 size_t len); 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* addr, size_t len); 86 BASE_EXPORT void DecommitSystemPages(void* address, size_t length);
87 87
88 // Recommit one or more system pages. Decommitted system pages must be 88 // Recommit one or more system pages. Decommitted system pages must be
89 // recommitted before they are read are written again. 89 // recommitted before they are read are written again.
90 // Note that this operation may be a no-op on some platforms. 90 // Note that this operation may be a no-op on some platforms.
91 // len must be a multiple of kSystemPageSize bytes. 91 // len must be a multiple of kSystemPageSize bytes.
92 BASE_EXPORT void recommitSystemPages(void* addr, size_t len); 92 BASE_EXPORT void RecommitSystemPages(void* address, size_t length);
93 93
94 // Discard one or more system pages. Discarding is a hint to the system that 94 // Discard one or more system pages. Discarding is a hint to the system that
95 // the page is no longer required. The hint may: 95 // the page is no longer required. The hint may:
96 // - Do nothing. 96 // - Do nothing.
97 // - Discard the page immediately, freeing up physical pages. 97 // - Discard the page immediately, freeing up physical pages.
98 // - Discard the page at some time in the future in response to memory pressure. 98 // - Discard the page at some time in the future in response to memory pressure.
99 // Only committed pages should be discarded. Discarding a page does not 99 // Only committed pages should be discarded. Discarding a page does not
100 // decommit it, and it is valid to discard an already-discarded page. 100 // decommit it, and it is valid to discard an already-discarded page.
101 // A read or write to a discarded page will not fault. 101 // A read or write to a discarded page will not fault.
102 // Reading from a discarded page may return the original page content, or a 102 // Reading from a discarded page may return the original page content, or a
103 // page full of zeroes. 103 // page full of zeroes.
104 // Writing to a discarded page is the only guaranteed way to tell the system 104 // Writing to a discarded page is the only guaranteed way to tell the system
105 // that the page is required again. Once written to, the content of the page is 105 // that the page is required again. Once written to, the content of the page is
106 // guaranteed stable once more. After being written to, the page content may be 106 // guaranteed stable once more. After being written to, the page content may be
107 // based on the original page content, or a page of zeroes. 107 // based on the original page content, or a page of zeroes.
108 // len must be a multiple of kSystemPageSize bytes. 108 // len must be a multiple of kSystemPageSize bytes.
109 BASE_EXPORT void discardSystemPages(void* addr, size_t len); 109 BASE_EXPORT void DiscardSystemPages(void* address, size_t length);
110 110
111 ALWAYS_INLINE uintptr_t roundUpToSystemPage(uintptr_t address) { 111 ALWAYS_INLINE uintptr_t RoundUpToSystemPage(uintptr_t address) {
112 return (address + kSystemPageOffsetMask) & kSystemPageBaseMask; 112 return (address + kSystemPageOffsetMask) & kSystemPageBaseMask;
113 } 113 }
114 114
115 ALWAYS_INLINE uintptr_t roundDownToSystemPage(uintptr_t address) { 115 ALWAYS_INLINE uintptr_t RoundDownToSystemPage(uintptr_t address) {
116 return address & kSystemPageBaseMask; 116 return address & kSystemPageBaseMask;
117 } 117 }
118 118
119 // Returns errno (or GetLastError code) when mmap (or VirtualAlloc) fails. 119 // Returns errno (or GetLastError code) when mmap (or VirtualAlloc) fails.
120 BASE_EXPORT uint32_t getAllocPageErrorCode(); 120 BASE_EXPORT uint32_t GetAllocPageErrorCode();
121 121
122 } // namespace base 122 } // namespace base
123 123
124 #endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_PAGE_ALLOCATOR_H 124 #endif // BASE_ALLOCATOR_PARTITION_ALLOCATOR_PAGE_ALLOCATOR_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698