mirror of
https://github.com/LSPosed/LSPlant.git
synced 2025-05-04 20:42:02 +08:00
36 lines
1.2 KiB
C++
36 lines
1.2 KiB
C++
|
#pragma once
|
||
|
|
||
|
#include "common.hpp"
|
||
|
|
||
|
namespace lsplant::art::jit {
|
||
|
class JitCodeCache {
|
||
|
CREATE_MEM_FUNC_SYMBOL_ENTRY(void, MoveObsoleteMethod, JitCodeCache *thiz,
|
||
|
ArtMethod * old_method, ArtMethod * new_method) {
|
||
|
if (MoveObsoleteMethodSym)
|
||
|
[[likely]] MoveObsoleteMethodSym(thiz, old_method, new_method);
|
||
|
}
|
||
|
|
||
|
CREATE_MEM_HOOK_STUB_ENTRY(
|
||
|
"_ZN3art3jit12JitCodeCache19GarbageCollectCacheEPNS_6ThreadE",
|
||
|
void, GarbageCollectCache, (JitCodeCache * thiz, Thread * self), {
|
||
|
LOGD("Before jit cache gc, moving hooked methods");
|
||
|
for (auto[target, backup] : GetJitMovements()) {
|
||
|
MoveObsoleteMethod(thiz, target, backup);
|
||
|
}
|
||
|
backup(thiz, self);
|
||
|
});
|
||
|
|
||
|
public:
|
||
|
static bool Init(const HookHandler &handler) {
|
||
|
if (!RETRIEVE_MEM_FUNC_SYMBOL(MoveObsoleteMethod,
|
||
|
"_ZN3art3jit12JitCodeCache18MoveObsoleteMethodEPNS_9ArtMethodES3_")) {
|
||
|
return false;
|
||
|
}
|
||
|
if (!HookSyms(handler, GarbageCollectCache)) {
|
||
|
return false;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
};
|
||
|
}
|