diff options
| author | 2024-01-12 14:08:54 +0000 | |
|---|---|---|
| committer | 2024-01-15 14:33:06 +0000 | |
| commit | a8a55bc8c82ab27a576741917cfdb68ee3724974 (patch) | |
| tree | 3cb1d800835d38ded001a0d2c2ec3dcc40c5e6df /runtime/gc/allocator/art-dlmalloc.cc | |
| parent | 3dccb13f4e92db37a13359e126c5ddc12cb674b5 (diff) | |
Clean-up dlmalloc callbacks
Move Dlmalloc*Callback functions to dlmalloc_space.cc, the only file
where they are used.
Move ArtDlMallocMoreCore declaration to dlmalloc_space.h to be
consistent with the definition.
Test: art/test.py -b --host
Change-Id: Ib5462c1a3e6881e118cc84960a059001b7d54550
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); -} |