Index: src/base/platform/platform.h |
diff --git a/src/base/platform/platform.h b/src/base/platform/platform.h |
index 9464fb11231dbcd59efed2846ff4d4894681f83f..73300d937942ee7170babc659f0371cfb7308646 100644 |
--- a/src/base/platform/platform.h |
+++ b/src/base/platform/platform.h |
@@ -337,6 +337,21 @@ 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 |
+ // chunk of memory. |
+ void ReleasePartial(void* free_start, size_t size) { |
ulan
2016/06/06 13:44:22
As discussed, we can make a stricter version of th
Hannes Payer (out of office)
2016/06/06 14:42:44
Done.
|
+ DCHECK(IsReserved()); |
+ // Notice: Order is important here. The VirtualMemory object might live |
+ // inside the allocated region. |
+ CHECK(InVM(free_start, size)); |
+ DCHECK(free_start != address_); |
+ DCHECK(size < size_); |
+ 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 +384,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. |