-
-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Propagate hotness counter for backup method to target to avoid crash
- Loading branch information
1 parent
0d9faca
commit a7b0b02
Showing
4 changed files
with
65 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
module; | ||
|
||
#include "logging.hpp" | ||
#include "utils/hook_helper.hpp" | ||
|
||
export module jit; | ||
|
||
import art_method; | ||
import common; | ||
import thread; | ||
|
||
namespace lsplant::art::jit { | ||
enum class CompilationKind { | ||
kOsr [[maybe_unused]], | ||
kBaseline [[maybe_unused]], | ||
kOptimized, | ||
}; | ||
|
||
export class Jit { | ||
CREATE_MEM_HOOK_STUB_ENTRY( | ||
"_ZN3art3jit3Jit27EnqueueOptimizedCompilationEPNS_9ArtMethodEPNS_6ThreadE", void, | ||
EnqueueOptimizedCompilation, (Jit * thiz, ArtMethod *method, Thread *self), { | ||
if (auto target = IsBackup(method); target) [[unlikely]] { | ||
LOGD("Propagate enqueue compilation: %p -> %p", method, target); | ||
method = target; | ||
} | ||
return backup(thiz, method, self); | ||
}); | ||
|
||
CREATE_MEM_HOOK_STUB_ENTRY( | ||
"_ZN3art3jit3Jit14AddCompileTaskEPNS_6ThreadEPNS_9ArtMethodENS_15CompilationKindEb", void, | ||
AddCompileTask, | ||
(Jit * thiz, Thread *self, ArtMethod *method, CompilationKind compilation_kind, | ||
bool precompile), | ||
{ | ||
if (compilation_kind == CompilationKind::kOptimized && !precompile/* && in_enqueue*/) { | ||
if (auto backup = IsHooked(method); backup) [[unlikely]] { | ||
LOGD("Propagate compile task: %p -> %p", method, backup); | ||
method = backup; | ||
} | ||
} | ||
return backup(thiz, self, method, compilation_kind, precompile); | ||
}); | ||
|
||
public: | ||
static bool Init(const HookHandler &handler) { | ||
auto sdk_int = GetAndroidApiLevel(); | ||
|
||
if (sdk_int <= __ANDROID_API_U__) [[likely]] { | ||
HookSyms(handler, EnqueueOptimizedCompilation); | ||
HookSyms(handler, AddCompileTask); | ||
} | ||
return true; | ||
} | ||
}; | ||
} // namespace lsplant::art::jit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters