| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 #include "wtf/Assertions.h" | 34 #include "wtf/Assertions.h" |
| 35 #include "wtf/CPU.h" | 35 #include "wtf/CPU.h" |
| 36 #include "wtf/WTFExport.h" | 36 #include "wtf/WTFExport.h" |
| 37 #include <cstddef> | 37 #include <cstddef> |
| 38 #include <stdint.h> | 38 #include <stdint.h> |
| 39 | 39 |
| 40 namespace WTF { | 40 namespace WTF { |
| 41 | 41 |
| 42 #if OS(WIN) | 42 #if OS(WIN) |
| 43 static const size_t kPageAllocationGranularityShift = 16; // 64KB | 43 static const size_t kPageAllocationGranularityShift = 16; // 64KB |
| 44 #else | 44 #else |
| 45 static const size_t kPageAllocationGranularityShift = 12; // 4KB | 45 static const size_t kPageAllocationGranularityShift = 12; // 4KB |
| 46 #endif | 46 #endif |
| 47 static const size_t kPageAllocationGranularity = 1 << kPageAllocationGranularity
Shift; | 47 static const size_t kPageAllocationGranularity = 1 << kPageAllocationGranularity
Shift; |
| 48 static const size_t kPageAllocationGranularityOffsetMask = kPageAllocationGranul
arity - 1; | 48 static const size_t kPageAllocationGranularityOffsetMask = kPageAllocationGranul
arity - 1; |
| 49 static const size_t kPageAllocationGranularityBaseMask = ~kPageAllocationGranula
rityOffsetMask; | 49 static const size_t kPageAllocationGranularityBaseMask = ~kPageAllocationGranula
rityOffsetMask; |
| 50 | 50 |
| 51 // All Blink-supported systems have 4096 sized system pages and can handle | 51 // All Blink-supported systems have 4096 sized system pages and can handle |
| 52 // permissions and commit / decommit at this granularity. | 52 // permissions and commit / decommit at this granularity. |
| 53 static const size_t kSystemPageSize = 4096; | 53 static const size_t kSystemPageSize = 4096; |
| 54 static const size_t kSystemPageOffsetMask = kSystemPageSize - 1; | 54 static const size_t kSystemPageOffsetMask = kSystemPageSize - 1; |
| 55 static const size_t kSystemPageBaseMask = ~kSystemPageOffsetMask; | 55 static const size_t kSystemPageBaseMask = ~kSystemPageOffsetMask; |
| 56 | 56 |
| 57 enum PageAccessibilityConfiguration { | 57 enum PageAccessibilityConfiguration { |
| 58 PageAccessible, | 58 PageAccessible, |
| 59 PageInaccessible, | 59 PageInaccessible, |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 // Allocate one or more pages. | 62 // Allocate one or more pages. |
| 63 // The requested address is just a hint; the actual address returned may | 63 // The requested address is just a hint; the actual address returned may |
| 64 // differ. The returned address will be aligned at least to align bytes. | 64 // differ. The returned address will be aligned at least to align bytes. |
| 65 // len is in bytes, and must be a multiple of kPageAllocationGranularity. | 65 // len is in bytes, and must be a multiple of kPageAllocationGranularity. |
| 66 // align is in bytes, and must be a power-of-two multiple of | 66 // align is in bytes, and must be a power-of-two multiple of |
| 67 // kPageAllocationGranularity. | 67 // kPageAllocationGranularity. |
| 68 // If addr is null, then a suitable and randomized address will be chosen | 68 // If addr is null, then a suitable and randomized address will be chosen |
| 69 // automatically. | 69 // automatically. |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 // A read or write to a discarded page will not fault. | 119 // A read or write to a discarded page will not fault. |
| 120 // Reading from a discarded page may return the original page content, or a | 120 // Reading from a discarded page may return the original page content, or a |
| 121 // page full of zeroes. | 121 // page full of zeroes. |
| 122 // Writing to a discarded page is the only guaranteed way to tell the system | 122 // Writing to a discarded page is the only guaranteed way to tell the system |
| 123 // that the page is required again. Once written to, the content of the page is | 123 // that the page is required again. Once written to, the content of the page is |
| 124 // guaranteed stable once more. After being written to, the page content may be | 124 // guaranteed stable once more. After being written to, the page content may be |
| 125 // based on the original page content, or a page of zeroes. | 125 // based on the original page content, or a page of zeroes. |
| 126 // len must be a multiple of kSystemPageSize bytes. | 126 // len must be a multiple of kSystemPageSize bytes. |
| 127 WTF_EXPORT void discardSystemPages(void* addr, size_t len); | 127 WTF_EXPORT void discardSystemPages(void* addr, size_t len); |
| 128 | 128 |
| 129 } // namespace WTF | 129 } // namespace WTF |
| 130 | 130 |
| 131 #endif // WTF_PageAllocator_h | 131 #endif // WTF_PageAllocator_h |
| OLD | NEW |