Commit 9a9fdbff authored by Erik Chen's avatar Erik Chen Committed by Commit Bot

Fix accounting for reused memory for v8 on macOS.

Calls to madvise(MADV_FREE_REUSABLE) [when discarding/decommitting memory]
should be paired with calls to madvise(MADV_FREE_REUSE) [when reusing/committing
memory]. The latter is purely for accounting purposes.

Bug: chromium:823915
Cq-Include-Trybots: luci.chromium.try:linux_chromium_rel_ng
Change-Id: Ib1758fd72c5ad4dfe731f5d9a6dbaf75b1e0e14b
Reviewed-on: https://chromium-review.googlesource.com/988193
Commit-Queue: Erik Chen <erikchen@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52674}
parent f52b4b3b
...@@ -354,6 +354,18 @@ bool OS::SetPermissions(void* address, size_t size, MemoryPermission access) { ...@@ -354,6 +354,18 @@ bool OS::SetPermissions(void* address, size_t size, MemoryPermission access) {
if (ret == 0 && access == OS::MemoryPermission::kNoAccess) { if (ret == 0 && access == OS::MemoryPermission::kNoAccess) {
ret = ReclaimInaccessibleMemory(address, size); ret = ReclaimInaccessibleMemory(address, size);
} }
// For accounting purposes, we want to call MADV_FREE_REUSE on macOS after
// changing permissions away from OS::MemoryPermission::kNoAccess. Since this
// state is not kept at this layer, we always call this if access != kNoAccess.
// The cost is a syscall that effectively no-ops.
// TODO(erikchen): Fix this to only call MADV_FREE_REUSE when necessary.
// https://crbug.com/823915
#if defined(OS_MACOSX)
if (access != OS::MemoryPermission::kNoAccess)
madvise(address, size, MADV_FREE_REUSE);
#endif
return ret == 0; return ret == 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment