summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Cheng <bccheng@android.com>2010-02-11 15:03:00 -0800
committerBen Cheng <bccheng@android.com>2010-02-11 16:07:17 -0800
commit878e91ad5017950cbba1653c17470c87c6eb631b (patch)
treef42ba7720cdb59d4eb4234049d7cb3183b807ba9
parent4f9be5213afc3e31db170c190f72fd5f91c0e456 (diff)
downloadandroid_dalvik-878e91ad5017950cbba1653c17470c87c6eb631b.tar.gz
android_dalvik-878e91ad5017950cbba1653c17470c87c6eb631b.tar.bz2
android_dalvik-878e91ad5017950cbba1653c17470c87c6eb631b.zip
Use ashmem to create the JIT code cache.
-rw-r--r--vm/compiler/Compiler.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/vm/compiler/Compiler.c b/vm/compiler/Compiler.c
index 032b8594e..484f9a392 100644
--- a/vm/compiler/Compiler.c
+++ b/vm/compiler/Compiler.c
@@ -16,6 +16,7 @@
#include <sys/mman.h>
#include <errno.h>
+#include <cutils/ashmem.h>
#include "Dalvik.h"
#include "interp/Jit.h"
@@ -127,18 +128,26 @@ bool dvmCompilerSetupCodeCache(void)
{
extern void dvmCompilerTemplateStart(void);
extern void dmvCompilerTemplateEnd(void);
+ int fd;
/* Allocate the code cache */
- gDvmJit.codeCache = mmap(0, gDvmJit.codeCacheSize,
- PROT_READ | PROT_WRITE | PROT_EXEC,
- MAP_PRIVATE | MAP_ANON, -1, 0);
+ fd = ashmem_create_region("dalvik-jit-code-cache", gDvmJit.codeCacheSize);
+ if (fd < 0) {
+ LOGE("Could not create %u-byte ashmem region for the JIT code cache",
+ gDvmJit.codeCacheSize);
+ return false;
+ }
+ gDvmJit.codeCache = mmap(NULL, gDvmJit.codeCacheSize,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_PRIVATE , fd, 0);
+ close(fd);
if (gDvmJit.codeCache == MAP_FAILED) {
- LOGE("Failed to create the code cache: %s\n", strerror(errno));
+ LOGE("Failed to mmap the JIT code cache: %s\n", strerror(errno));
return false;
}
- // STOPSHIP - for debugging only
- LOGD("Code cache starts at %p", gDvmJit.codeCache);
+ /* This can be found through "dalvik-jit-code-cache" in /proc/<pid>/maps */
+ // LOGD("Code cache starts at %p", gDvmJit.codeCache);
/* Copy the template code into the beginning of the code cache */
int templateSize = (intptr_t) dmvCompilerTemplateEnd -