Bug 1011350 - Use TaggedAnonymousMemory to distinguish our various mmap call sites. r=njn

We can probably get more granular information than this, given that we
can re-tag memory after the initial mapping, or tag subregions of an
individual mmap() call differently.  But this is a start.
This commit is contained in:
Jed Davis 2014-06-17 17:55:00 +02:00
parent 5d990656e6
commit 10b28157d6
6 changed files with 28 additions and 10 deletions

View File

@ -30,6 +30,8 @@
#include <sys/mman.h>
#include <unistd.h>
#include "mozilla/TaggedAnonymousMemory.h"
#include "assembler/wtf/Assertions.h"
#include "assembler/wtf/VMTags.h"
#include "js/Utility.h"
@ -43,7 +45,7 @@ size_t ExecutableAllocator::determinePageSize()
ExecutablePool::Allocation ExecutableAllocator::systemAlloc(size_t n)
{
void *allocation = mmap(NULL, n, INITIAL_PROTECTION_FLAGS, MAP_PRIVATE | MAP_ANON, VM_TAG_FOR_EXECUTABLEALLOCATOR_MEMORY, 0);
void *allocation = MozTaggedAnonymousMmap(NULL, n, INITIAL_PROTECTION_FLAGS, MAP_PRIVATE | MAP_ANON, VM_TAG_FOR_EXECUTABLEALLOCATOR_MEMORY, 0, "js-jit-code");
if (allocation == MAP_FAILED)
allocation = NULL;
ExecutablePool::Allocation alloc = { reinterpret_cast<char*>(allocation), n };

View File

@ -6,6 +6,8 @@
#include "gc/Memory.h"
#include "mozilla/TaggedAnonymousMemory.h"
#include "js/HeapAPI.h"
#include "vm/Runtime.h"
@ -378,7 +380,7 @@ MapMemory(size_t length, int prot = PROT_READ | PROT_WRITE,
}
return region;
#else
void *region = mmap(nullptr, length, prot, flags, fd, offset);
void *region = MozTaggedAnonymousMmap(nullptr, length, prot, flags, fd, offset, "js-gc-heap");
if (region == MAP_FAILED)
return nullptr;
return region;

View File

@ -14,6 +14,7 @@
#include "mozilla/Compression.h"
#include "mozilla/PodOperations.h"
#include "mozilla/TaggedAnonymousMemory.h"
#include "jslibmath.h"
#include "jsmath.h"
@ -81,9 +82,9 @@ AllocateExecutableMemory(ExclusiveContext *cx, size_t totalBytes)
return nullptr;
}
#else // assume Unix
void *p = mmap(nullptr, totalBytes,
PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON,
-1, 0);
void *p = MozTaggedAnonymousMmap(nullptr, totalBytes,
PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE | MAP_ANON,
-1, 0, "asm-js-code");
if (p == MAP_FAILED) {
js_ReportOutOfMemory(cx);
return nullptr;

View File

@ -9,6 +9,7 @@
#include "mozilla/Alignment.h"
#include "mozilla/FloatingPoint.h"
#include "mozilla/PodOperations.h"
#include "mozilla/TaggedAnonymousMemory.h"
#include <string.h>
#ifndef XP_WIN
@ -431,7 +432,7 @@ ArrayBufferObject::prepareForAsmJS(JSContext *cx, Handle<ArrayBufferObject*> buf
if (!data)
return false;
# else
data = mmap(nullptr, AsmJSMappedSize, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0);
data = MozTaggedAnonymousMmap(nullptr, AsmJSMappedSize, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0, "asm-js-reserved");
if (data == MAP_FAILED)
return false;
# endif

View File

@ -1559,8 +1559,11 @@ void (*_malloc_message)(const char *p1, const char *p2, const char *p3,
#define assert(e)
#endif
#include <mozilla/Assertions.h>
#include <mozilla/Attributes.h>
#include "mozilla/Assertions.h"
#include "mozilla/Attributes.h"
#include "mozilla/TaggedAnonymousMemory.h"
// Note: MozTaggedAnonymousMmap() could call an LD_PRELOADed mmap
// instead of the one defined here; use only MozTagAnonymousMemory().
/* RELEASE_ASSERT calls jemalloc_crash() instead of calling MOZ_CRASH()
* directly because we want crashing to add a frame to the stack. This makes
@ -1979,6 +1982,7 @@ pages_decommit(void *addr, size_t size)
if (mmap(addr, size, PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1,
0) == MAP_FAILED)
abort();
MozTagAnonymousMemory(addr, size, "jemalloc-decommitted");
#endif
}
@ -1993,6 +1997,7 @@ pages_commit(void *addr, size_t size)
if (mmap(addr, size, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE |
MAP_ANON, -1, 0) == MAP_FAILED)
abort();
MozTagAnonymousMemory(addr, size, "jemalloc");
# endif
}
@ -2363,6 +2368,8 @@ pages_map_align(size_t size, int pfd, size_t alignment)
if (ret == MAP_FAILED)
ret = NULL;
else
MozTagAnonymousMemory(ret, size, "jemalloc");
return (ret);
}
#endif
@ -2410,7 +2417,7 @@ pages_map(void *addr, size_t size, int pfd)
if (ret == MAP_FAILED) {
ret = NULL;
}
}
#if defined(__ia64__)
/*
* If the allocated memory doesn't have its upper 17 bits clear, consider it
@ -2439,6 +2446,9 @@ pages_map(void *addr, size_t size, int pfd)
}
ret = NULL;
}
if (ret != NULL) {
MozTagAnonymousMemory(ret, size, "jemalloc");
}
#if defined(__ia64__)
assert(ret == NULL || (!check_placement && ret != NULL)

View File

@ -110,10 +110,12 @@ GetDesiredRegionSize()
#else // Unix
#include "mozilla/TaggedAnonymousMemory.h"
static void *
ReserveRegion(uintptr_t region, uintptr_t size)
{
return mmap(reinterpret_cast<void*>(region), size, PROT_NONE, MAP_PRIVATE|MAP_ANON, -1, 0);
return MozTaggedAnonymousMmap(reinterpret_cast<void*>(region), size, PROT_NONE, MAP_PRIVATE|MAP_ANON, -1, 0, "poison");
}
static void