summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorPablo Galindo Salgado <Pablogsal@gmail.com>2022-08-30 18:37:22 (GMT)
committerGitHub <noreply@github.com>2022-08-30 18:37:22 (GMT)
commitf49dd54b72ec3fe6dbdcd2476a810929382bc196 (patch)
tree936df577343e5321927961ec7a0c5fa554af52fb /Objects
parent45fd3685aad90de3be21c8f6eade7b5985629fb8 (diff)
downloadcpython-f49dd54b72ec3fe6dbdcd2476a810929382bc196.zip
cpython-f49dd54b72ec3fe6dbdcd2476a810929382bc196.tar.gz
cpython-f49dd54b72ec3fe6dbdcd2476a810929382bc196.tar.bz2
gh-96143: Add some comments and minor fixes missed in the original PR (#96433)
* gh-96132: Add some comments and minor fixes missed in the original PR * Update Doc/using/cmdline.rst Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com> Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Diffstat (limited to 'Objects')
-rw-r--r--Objects/perf_trampoline.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/Objects/perf_trampoline.c b/Objects/perf_trampoline.c
index 02206b2..2cbe374 100644
--- a/Objects/perf_trampoline.c
+++ b/Objects/perf_trampoline.c
@@ -284,12 +284,23 @@ new_code_arena(void)
void *start = &_Py_trampoline_func_start;
void *end = &_Py_trampoline_func_end;
size_t code_size = end - start;
+ // TODO: Check the effect of alignment of the code chunks. Initial investigation
+ // showed that this has no effect on performance in x86-64 or aarch64 and the current
+ // version has the advantage that the unwinder in GDB can unwind across JIT-ed code.
+ //
+ // We should check the values in the future and see if there is a
+ // measurable performance improvement by rounding trampolines up to 32-bit
+ // or 64-bit alignment.
size_t n_copies = mem_size / code_size;
for (size_t i = 0; i < n_copies; i++) {
memcpy(memory + i * code_size, start, code_size * sizeof(char));
}
// Some systems may prevent us from creating executable code on the fly.
+ // TODO: Call icache invalidation intrinsics if available:
+ // __builtin___clear_cache/__clear_cache (depending if clang/gcc). This is
+ // technically not necessary but we could be missing something so better be
+ // safe.
int res = mprotect(memory, mem_size, PROT_READ | PROT_EXEC);
if (res == -1) {
PyErr_SetFromErrno(PyExc_OSError);