diff options
Diffstat (limited to 'runtime/gc/allocator/art-dlmalloc.cc')
-rw-r--r-- | runtime/gc/allocator/art-dlmalloc.cc | 48 |
1 files changed, 1 insertions, 47 deletions
diff --git a/runtime/gc/allocator/art-dlmalloc.cc b/runtime/gc/allocator/art-dlmalloc.cc index 62a768db39..86732324d9 100644 --- a/runtime/gc/allocator/art-dlmalloc.cc +++ b/runtime/gc/allocator/art-dlmalloc.cc @@ -19,6 +19,7 @@ #include <android-base/logging.h> #include "base/bit_utils.h" +#include "gc/space/dlmalloc_space.h" // ART specific morecore implementation defined in space.cc. static void* art_heap_morecore(void* m, intptr_t increment); @@ -57,50 +58,3 @@ static void art_heap_usage_error(const char* function, void* p) { LOG(FATAL) << "Incorrect use of function '" << function << "' argument " << p << " not expected"; } - -#include <sys/mman.h> - -#include "base/utils.h" -#include "runtime_globals.h" - -extern "C" void DlmallocMadviseCallback(void* start, void* end, size_t used_bytes, void* arg) { - // Is this chunk in use? - if (used_bytes != 0) { - return; - } - // Do we have any whole pages to give back? - start = reinterpret_cast<void*>(art::RoundUp(reinterpret_cast<uintptr_t>(start), art::gPageSize)); - end = reinterpret_cast<void*>(art::RoundDown(reinterpret_cast<uintptr_t>(end), art::gPageSize)); - if (end > start) { - size_t length = reinterpret_cast<uint8_t*>(end) - reinterpret_cast<uint8_t*>(start); - int rc = madvise(start, length, MADV_DONTNEED); - if (UNLIKELY(rc != 0)) { - errno = rc; - PLOG(FATAL) << "madvise failed during heap trimming"; - } - size_t* reclaimed = reinterpret_cast<size_t*>(arg); - *reclaimed += length; - } -} - -extern "C" void DlmallocBytesAllocatedCallback([[maybe_unused]] void* start, - [[maybe_unused]] void* end, - size_t used_bytes, - void* arg) { - if (used_bytes == 0) { - return; - } - size_t* bytes_allocated = reinterpret_cast<size_t*>(arg); - *bytes_allocated += used_bytes + sizeof(size_t); -} - -extern "C" void DlmallocObjectsAllocatedCallback([[maybe_unused]] void* start, - [[maybe_unused]] void* end, - size_t used_bytes, - void* arg) { - if (used_bytes == 0) { - return; - } - size_t* objects_allocated = reinterpret_cast<size_t*>(arg); - ++(*objects_allocated); -} |