From b13c9ba98d31c3d1618f0f17c7408c494bd3e374 Mon Sep 17 00:00:00 2001 From: kotori0 Date: Fri, 11 Dec 2020 15:02:14 +0800 Subject: [PATCH] Increase hook cap to prevent frequent memory allocating --- edxp-core/src/main/cpp/external/yahfa/src/HookMain.c | 11 ++++------- .../src/main/cpp/external/yahfa/src/trampoline.h | 2 +- .../cpp/main/include/art/runtime/jit/jit_code_cache.h | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/edxp-core/src/main/cpp/external/yahfa/src/HookMain.c b/edxp-core/src/main/cpp/external/yahfa/src/HookMain.c index 99b30ac0..e9f341b7 100644 --- a/edxp-core/src/main/cpp/external/yahfa/src/HookMain.c +++ b/edxp-core/src/main/cpp/external/yahfa/src/HookMain.c @@ -9,13 +9,11 @@ #include "HookMain.h" int SDKVersion; -static int OFFSET_entry_point_from_interpreter_in_ArtMethod; -static int OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod; -static int OFFSET_ArtMehod_in_Object; -static int OFFSET_access_flags_in_ArtMethod; -static uint32_t kAccNative = 0x0100; +static uint32_t OFFSET_entry_point_from_interpreter_in_ArtMethod; +static uint32_t OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod; +static uint32_t OFFSET_ArtMehod_in_Object; +static uint32_t OFFSET_access_flags_in_ArtMethod; static uint32_t kAccCompileDontBother = 0x01000000; -static uint32_t kAccFastInterpreterToInterpreterInvoke = 0x40000000; static jfieldID fieldArtMethod = NULL; @@ -32,7 +30,6 @@ static inline void *readAddr(void *addr) { } void Java_lab_galaxy_yahfa_HookMain_init(JNIEnv *env, jclass clazz, jint sdkVersion) { - int i; SDKVersion = sdkVersion; jclass classExecutable; LOGI("init to SDK %d", sdkVersion); diff --git a/edxp-core/src/main/cpp/external/yahfa/src/trampoline.h b/edxp-core/src/main/cpp/external/yahfa/src/trampoline.h index 2235a42d..ad1a0078 100644 --- a/edxp-core/src/main/cpp/external/yahfa/src/trampoline.h +++ b/edxp-core/src/main/cpp/external/yahfa/src/trampoline.h @@ -16,6 +16,6 @@ int doInitHookCap(unsigned int cap); void setupTrampoline(uint8_t offset); void *genTrampoline(void *toMethod, void *entrypoint); -#define DEFAULT_CAP 1 //size of each trampoline area would be no more than 4k Bytes(one page) +#define DEFAULT_CAP 4 //size of each trampoline area would be no more than 4k Bytes(one page) #endif //YAHFA_TAMPOLINE_H diff --git a/edxp-core/src/main/cpp/main/include/art/runtime/jit/jit_code_cache.h b/edxp-core/src/main/cpp/main/include/art/runtime/jit/jit_code_cache.h index 6c6471ed..6f35e78c 100644 --- a/edxp-core/src/main/cpp/main/include/art/runtime/jit/jit_code_cache.h +++ b/edxp-core/src/main/cpp/main/include/art/runtime/jit/jit_code_cache.h @@ -9,7 +9,7 @@ namespace art { CREATE_HOOK_STUB_ENTRIES(const void*, GetSavedEntryPointOfPreCompiledMethod, void *thiz, void *art_method) { if (UNLIKELY(edxp::isHooked(art_method))) { - LOGD("Found hooked method, return entrypoint as jit entrypoint"); + LOGD("Found hooked method %p, return entrypoint as jit entrypoint", art_method); return getEntryPoint(art_method); } return GetSavedEntryPointOfPreCompiledMethodBackup(thiz, art_method);