Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Unified Diff: src/platform-macos.cc

Issue 251047: Tag Mac VM regions allocated by V8. This has no effect other than making it possi... (Closed) Base URL: http://v8.googlecode.com/svn/tags/1.3.12/
Patch Set: '' Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform-macos.cc
===================================================================
--- src/platform-macos.cc (revision 2953)
+++ src/platform-macos.cc (working copy)
@@ -42,6 +42,7 @@
#include <mach/mach.h>
#include <mach/semaphore.h>
#include <mach/task.h>
+#include <mach/vm_statistics.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/types.h>
@@ -128,7 +129,12 @@
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);
+ // Use the fd parameter 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).
+ void* mbase = mmap(NULL, msize, prot,
+ MAP_PRIVATE | MAP_ANON,
+ VM_MAKE_TAG(255), 0);
if (mbase == MAP_FAILED) {
LOG(StringEvent("OS::Allocate", "mmap failed"));
return NULL;
@@ -195,8 +201,9 @@
FILE* file = fopen(name, "w+");
if (file == NULL) return NULL;
fwrite(initial, size, 1, file);
- void* memory =
- mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fileno(file), 0);
+ void* memory = mmap(0, size, PROT_READ | PROT_WRITE,
+ MAP_SHARED,
+ fileno(file), 0);
return new PosixMemoryMappedFile(file, memory, size);
}
@@ -280,14 +287,18 @@
}
-// Constants used for mmap.
-static const int kMmapFd = -1;
+// Constants used for mmap calls by the VirtualMemory class.
+// kMmapFd is used to pass vm_alloc flags to tag the region with the user
+// defined tag 254. This helps identify V8-allocated regions in memory analysis
+// tools like vmmap(1).
+static const int kMmapFlags = MAP_PRIVATE | MAP_ANON;
+static const int kMmapFd = VM_MAKE_TAG(254);
static const int kMmapFdOffset = 0;
VirtualMemory::VirtualMemory(size_t size) {
address_ = mmap(NULL, size, PROT_NONE,
- MAP_PRIVATE | MAP_ANON | MAP_NORESERVE,
+ kMmapFlags | MAP_NORESERVE,
kMmapFd, kMmapFdOffset);
size_ = size;
}
@@ -308,7 +319,7 @@
bool VirtualMemory::Commit(void* address, size_t size, bool is_executable) {
int prot = PROT_READ | PROT_WRITE | (is_executable ? PROT_EXEC : 0);
if (MAP_FAILED == mmap(address, size, prot,
- MAP_PRIVATE | MAP_ANON | MAP_FIXED,
+ kMmapFlags | MAP_FIXED,
kMmapFd, kMmapFdOffset)) {
return false;
}
@@ -320,7 +331,7 @@
bool VirtualMemory::Uncommit(void* address, size_t size) {
return mmap(address, size, PROT_NONE,
- MAP_PRIVATE | MAP_ANON | MAP_NORESERVE | MAP_FIXED,
+ kMmapFlags | MAP_NORESERVE | MAP_FIXED,
kMmapFd, kMmapFdOffset) != MAP_FAILED;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698