Skip to content

Commit

Permalink
Fix GarbageCollectCache got removed
Browse files Browse the repository at this point in the history
Co-authored-by: JingMatrix <[email protected]>
  • Loading branch information
yujincheng08 and JingMatrix committed Jul 23, 2024
1 parent 5121a21 commit 0d9faca
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions lsplant/src/main/jni/art/runtime/jit/jit_code_cache.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand All @@ -45,7 +54,7 @@ export class JitCodeCache {
}
}
if (sdk_int >= __ANDROID_API_N__) [[likely]] {
if (!HookSyms(handler, GarbageCollectCache)) [[unlikely]] {
if (!HookSyms(handler, GarbageCollectCache, DoCollection)) [[unlikely]] {
return false;
}
}
Expand Down

0 comments on commit 0d9faca

Please sign in to comment.