From 52d87249cbb1bd09b3f33a96f2e3c4bbfc1165ef Mon Sep 17 00:00:00 2001 From: "iposva@chromium.org" Date: Wed, 30 Sep 2009 22:21:10 +0000 Subject: [PATCH] Based on a patch submitted by Jens Alfke: Tag Mac OS X VM regions allocated by V8. This has no effect other than making it possible to identify V8 allocations in the vmmap(1) memory profiling tool, to get a better idea of an embedder's/Chrome's memory usage. CRBUG=23455 TEST=Tested by running vmmap(1) and looking for "Memory tag=255" in the output. Review URL: http://codereview.chromium.org/244051 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3001 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/platform-macos.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/platform-macos.cc b/src/platform-macos.cc index 596b0fb04..0b236a5a9 100644 --- a/src/platform-macos.cc +++ b/src/platform-macos.cc @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -123,12 +124,22 @@ size_t OS::AllocateAlignment() { } +// Constants used for mmap. +// kMmapFd is used to pass vm_alloc flags to tag the region with the user +// defined tag 255 This helps identify V8-allocated regions in memory analysis +// tools like vmmap(1). +static const int kMmapFd = VM_MAKE_TAG(255); +static const off_t kMmapFdOffset = 0; + + void* OS::Allocate(const size_t requested, size_t* allocated, bool is_executable) { const size_t msize = RoundUp(requested, getpagesize()); int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0); - void* mbase = mmap(NULL, msize, prot, MAP_PRIVATE | MAP_ANON, -1, 0); + void* mbase = mmap(NULL, msize, prot, + MAP_PRIVATE | MAP_ANON, + kMmapFd, kMmapFdOffset); if (mbase == MAP_FAILED) { LOG(StringEvent("OS::Allocate", "mmap failed")); return NULL; @@ -280,9 +291,6 @@ int OS::StackWalk(Vector frames) { } -// Constants used for mmap. -static const int kMmapFd = -1; -static const int kMmapFdOffset = 0; VirtualMemory::VirtualMemory(size_t size) { -- 2.34.1