Chromium Code Reviews| Index: src/base/platform/platform.h |
| diff --git a/src/base/platform/platform.h b/src/base/platform/platform.h |
| index 9464fb11231dbcd59efed2846ff4d4894681f83f..77c8d96056d38ccfa4a6dd21b4d07eaf5c89cb59 100644 |
| --- a/src/base/platform/platform.h |
| +++ b/src/base/platform/platform.h |
| @@ -337,6 +337,22 @@ class VirtualMemory { |
| // Creates a single guard page at the given address. |
| bool Guard(void* address); |
| + // Releases the tail [free_start, free_start + size] of a previously allocated |
|
ulan
2016/06/06 15:53:15
Should be [free_start, size_]
Hannes Payer (out of office)
2016/06/06 15:56:38
Done.
|
| + // chunk of memory. |
| + void ReleasePartial(void* free_start) { |
| + DCHECK(IsReserved()); |
| + // Notice: Order is important here. The VirtualMemory object might live |
| + // inside the allocated region. |
| + size_t size = size_ - (reinterpret_cast<size_t>(free_start) - |
| + reinterpret_cast<size_t>(address_)); |
| + CHECK(InVM(free_start, size)); |
| + DCHECK(free_start != address_); |
|
ulan
2016/06/06 15:53:15
DCHECK_LT(address_, free_start);
DCHECK_LT(free_st
Hannes Payer (out of office)
2016/06/06 15:56:38
Done.
|
| + bool result = ReleasePartialRegion(address_, size_, free_start, size); |
| + USE(result); |
| + DCHECK(result); |
| + size_ -= size; |
| + } |
| + |
| void Release() { |
| DCHECK(IsReserved()); |
| // Notice: Order is important here. The VirtualMemory object might live |
| @@ -369,6 +385,12 @@ class VirtualMemory { |
| // and the same size it was reserved with. |
| static bool ReleaseRegion(void* base, size_t size); |
| + // Must be called with a base pointer that has been returned by ReserveRegion |
| + // and the same size it was reserved with. |
| + // [free_start, free_start + free_size] is the memory that will be released. |
| + static bool ReleasePartialRegion(void* base, size_t size, void* free_start, |
| + size_t free_size); |
| + |
| // Returns true if OS performs lazy commits, i.e. the memory allocation call |
| // defers actual physical memory allocation till the first memory access. |
| // Otherwise returns false. |