diff --git a/lsplant/src/main/jni/art/runtime/jit/jit_code_cache.cxx b/lsplant/src/main/jni/art/runtime/jit/jit_code_cache.cxx index f286634..abd8d98 100644 --- a/lsplant/src/main/jni/art/runtime/jit/jit_code_cache.cxx +++ b/lsplant/src/main/jni/art/runtime/jit/jit_code_cache.cxx @@ -22,14 +22,23 @@ export class JitCodeCache { } } + void MoveObsoleteMethods() { + auto movements = GetJitMovements(); + LOGD("Before jit cache collection, moving %zu hooked methods", movements.size()); + for (auto [target, backup] : movements) { + MoveObsoleteMethod(this, target, backup); + } + } + CREATE_MEM_HOOK_STUB_ENTRY("_ZN3art3jit12JitCodeCache19GarbageCollectCacheEPNS_6ThreadE", void, GarbageCollectCache, (JitCodeCache * thiz, Thread *self), { - auto movements = GetJitMovements(); - LOGD("Before jit cache gc, moving %zu hooked methods", - movements.size()); - for (auto [target, backup] : movements) { - MoveObsoleteMethod(thiz, target, backup); - } + thiz->MoveObsoleteMethods(); + backup(thiz, self); + }); + + CREATE_MEM_HOOK_STUB_ENTRY("_ZN3art3jit12JitCodeCache12DoCollectionEPNS_6ThreadE", void, + DoCollection, (JitCodeCache * thiz, Thread *self), { + thiz->MoveObsoleteMethods(); backup(thiz, self); }); @@ -45,7 +54,7 @@ public: } } if (sdk_int >= __ANDROID_API_N__) [[likely]] { - if (!HookSyms(handler, GarbageCollectCache)) [[unlikely]] { + if (!HookSyms(handler, GarbageCollectCache, DoCollection)) [[unlikely]] { return false; } }