@@ -431,8 +431,10 @@ void patch_aarch64_trampoline(unsigned char *location, int ordinal, jit_state *s
431431
432432#if defined(__aarch64__ ) || defined(_M_ARM64 )
433433 #define TRAMPOLINE_SIZE 16
434+ #define DATA_ALIGN 8
434435#else
435436 #define TRAMPOLINE_SIZE 0
437+ #define DATA_ALIGN 0
436438#endif
437439
438440// Generate and patch AArch64 trampolines. The symbols to jump to are stored
@@ -522,7 +524,8 @@ _PyJIT_Compile(_PyExecutorObject *executor, const _PyUOpInstruction trace[], siz
522524 // Round up to the nearest page:
523525 size_t page_size = get_page_size ();
524526 assert ((page_size & (page_size - 1 )) == 0 );
525- size_t padding = page_size - ((code_size + state .trampolines .size + data_size ) & (page_size - 1 ));
527+ size_t code_padding = DATA_ALIGN - ((code_size + state .trampolines .size ) & (DATA_ALIGN - 1 ))
528+ size_t padding = page_size - ((code_size + state .trampolines .size + code_padding + data_size ) & (page_size - 1 ));
526529 size_t total_size = code_size + state .trampolines .size + data_size + padding ;
527530 unsigned char * memory = jit_alloc (total_size );
528531 if (memory == NULL ) {
@@ -545,7 +548,7 @@ _PyJIT_Compile(_PyExecutorObject *executor, const _PyUOpInstruction trace[], siz
545548 // Loop again to emit the code:
546549 unsigned char * code = memory ;
547550 state .trampolines .mem = memory + code_size ;
548- unsigned char * data = memory + code_size + state .trampolines .size ;
551+ unsigned char * data = memory + code_size + state .trampolines .size + code_padding ;
549552 // Compile the shim, which handles converting between the native
550553 // calling convention and the calling convention used by jitted code
551554 // (which may be different for efficiency reasons).
@@ -567,7 +570,7 @@ _PyJIT_Compile(_PyExecutorObject *executor, const _PyUOpInstruction trace[], siz
567570 code += group -> code_size ;
568571 data += group -> data_size ;
569572 assert (code == memory + code_size );
570- assert (data == memory + code_size + state .trampolines .size + data_size );
573+ assert (data == memory + code_size + state .trampolines .size + code_padding + data_size );
571574#ifdef MAP_JIT
572575 pthread_jit_write_protect_np (1 );
573576#endif
0 commit comments