Save jit state before/after callback

This commit is contained in:
2024-02-13 11:13:01 +08:00
parent f3323469d0
commit a6fb2a6870
10 changed files with 115 additions and 41 deletions

View File

@@ -63,6 +63,28 @@ __attribute__((unused)) static bool thread_executable()
return thread_mask() == 1;
}
#define JIT_CALLBACK_GUARD(x) \
{ \
bool executable = uc->current_executable; \
assert (executable == thread_executable()); \
x; \
if (executable != thread_executable()) { \
jit_write_protect(executable); \
} \
} \
#define JIT_CALLBACK_GUARD_VAR(var, x) \
{ \
bool executable = uc->current_executable; \
assert (executable == thread_executable()); \
var = x; \
if (executable != thread_executable()) { \
jit_write_protect(executable); \
} \
} \
#else /* defined(__aarch64__) && defined(CONFIG_DARWIN) */
static inline void jit_write_protect(int enabled)
@@ -70,6 +92,19 @@ static inline void jit_write_protect(int enabled)
return;
}
#define JIT_CALLBACK_GUARD(x) \
{ \
(void*)uc; \
x; \
} \
#define JIT_CALLBACK_GUARD_VAR(var, x) \
{ \
(void*)uc; \
var = x; \
} \
#endif
#endif /* define TCG_APPLE_JIT_H */