aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/perf_trampoline.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/perf_trampoline.c')
-rw-r--r--Python/perf_trampoline.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/Python/perf_trampoline.c b/Python/perf_trampoline.c
index 996e54b82b6..a2da3c7d56d 100644
--- a/Python/perf_trampoline.c
+++ b/Python/perf_trampoline.c
@@ -230,6 +230,7 @@ perf_map_init_state(void)
{
PyUnstable_PerfMapState_Init();
trampoline_api.code_padding = 0;
+ trampoline_api.code_alignment = 32;
perf_trampoline_type = PERF_TRAMPOLINE_TYPE_MAP;
return NULL;
}
@@ -291,7 +292,9 @@ new_code_arena(void)
void *start = &_Py_trampoline_func_start;
void *end = &_Py_trampoline_func_end;
size_t code_size = end - start;
- size_t chunk_size = round_up(code_size + trampoline_api.code_padding, 16);
+ size_t unaligned_size = code_size + trampoline_api.code_padding;
+ size_t chunk_size = round_up(unaligned_size, trampoline_api.code_alignment);
+ assert(chunk_size % trampoline_api.code_alignment == 0);
// 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.
@@ -356,7 +359,9 @@ static inline py_trampoline
code_arena_new_code(code_arena_t *code_arena)
{
py_trampoline trampoline = (py_trampoline)code_arena->current_addr;
- size_t total_code_size = round_up(code_arena->code_size + trampoline_api.code_padding, 16);
+ size_t total_code_size = round_up(code_arena->code_size + trampoline_api.code_padding,
+ trampoline_api.code_alignment);
+ assert(total_code_size % trampoline_api.code_alignment == 0);
code_arena->size_left -= total_code_size;
code_arena->current_addr += total_code_size;
return trampoline;
@@ -489,9 +494,6 @@ _PyPerfTrampoline_Init(int activate)
}
else {
_PyInterpreterState_SetEvalFrameFunc(tstate->interp, py_trampoline_evaluator);
- if (new_code_arena() < 0) {
- return -1;
- }
extra_code_index = _PyEval_RequestCodeExtraIndex(NULL);
if (extra_code_index == -1) {
return -1;
@@ -499,6 +501,9 @@ _PyPerfTrampoline_Init(int activate)
if (trampoline_api.state == NULL && trampoline_api.init_state != NULL) {
trampoline_api.state = trampoline_api.init_state();
}
+ if (new_code_arena() < 0) {
+ return -1;
+ }
perf_status = PERF_STATUS_OK;
}
#endif