diff options
author | 2017-08-05 16:03:03 -0700 | |
---|---|---|
committer | 2017-08-14 17:47:25 -0700 | |
commit | 120aa286ab6adf3e76a31bc61fb4e583e5158d71 (patch) | |
tree | 07f1546ce7a090af8c88110598920769bfb5e669 /runtime/utils.cc | |
parent | 5bfead584f56b2a1cfb69f78c385965ec57f7e8b (diff) |
Store layout info in dex files
Store layout info for code sections inside of the oat file. This will
be used to advise the kernel when dex files are loaded in
a follow up CL.
Added unit test in dex2oat_test.
Bug: 63178181
Test: test-art-host
(cherry-picked from commit 75c5ed6e75f70002db5fa7c609137c04dd2bdf40)
Change-Id: I4777506886bde42ff0affdac412a8395e8013a40
Diffstat (limited to 'runtime/utils.cc')
-rw-r--r-- | runtime/utils.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/runtime/utils.cc b/runtime/utils.cc index ffa9d45812..3fe18c7933 100644 --- a/runtime/utils.cc +++ b/runtime/utils.cc @@ -18,6 +18,7 @@ #include <inttypes.h> #include <pthread.h> +#include <sys/mman.h> // For madvise #include <sys/stat.h> #include <sys/syscall.h> #include <sys/types.h> @@ -940,4 +941,18 @@ void SleepForever() { } } +int MadviseLargestPageAlignedRegion(const uint8_t* begin, const uint8_t* end, int advice) { + DCHECK_LE(begin, end); + begin = AlignUp(begin, kPageSize); + end = AlignDown(end, kPageSize); + if (begin < end) { + int result = madvise(const_cast<uint8_t*>(begin), end - begin, advice); + if (result != 0) { + PLOG(WARNING) << "madvise failed " << result; + } + return result; + } + return 0; +} + } // namespace art |