Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add a bunch of macros
Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
  • Loading branch information
pablogsal committed Sep 1, 2022
commit 33e10bfb2f18ba75cf899484a34ef3da6ac44546
28 changes: 18 additions & 10 deletions Objects/perf_trampoline.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,22 @@ typedef enum {
#include <sys/types.h>
#include <unistd.h>

#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
Comment thread
pablogsal marked this conversation as resolved.
#define PY_HAVE_INVALIDATE_ICACHE

#if defined(__clang__) || defined(__GNUC__)
extern void __clear_cache(void *, void*);
#endif

static void invalidate_icache(char* begin, char*end) {
#if defined(__clang__) || defined(__GNUC__)
return __clear_cache(begin, end);
#else
return;
#endif
}
#endif

/* The function pointer is passed as last argument. The other three arguments
* are passed in the same order as the function requires. This results in
* shorter, more efficient ASM code for trampoline.
Expand Down Expand Up @@ -185,17 +201,9 @@ struct trampoline_api_st {

typedef struct trampoline_api_st trampoline_api_t;

#if defined(__clang__) || defined(__GNUC__)
extern void __clear_cache(void *, void*);
#endif
#ifdef PY_HAVE_INVALIDATE_ICACHE

static void invalidate_icache(char* begin, char*end) {
#if defined(__clang__) || defined(__GNUC__)
return __clear_cache(begin, end);
#else
return;
#endif
Comment thread
pablogsal marked this conversation as resolved.
Outdated
}

static perf_status_t perf_status = PERF_STATUS_NO_INIT;
static Py_ssize_t extra_code_index = -1;
Expand Down Expand Up @@ -319,7 +327,7 @@ new_code_arena(void)
return -1;
}

#if defined(__arm__) || defined(__arm64__) || defined(__aarch64__)
#ifdef PY_HAVE_INVALIDATE_ICACHE
// Before the JIT can run a block of code that has been emitted it must invalidate
// the instruction cache on some platforms like arm and aarch64.
invalidate_icache(memory, memory + mem_size);
Expand Down