Content-Length: 17739 | pFad | http://github.com/python/cpython/pull/136528.diff
thub.com
diff --git a/Python/jit.c b/Python/jit.c
index e232cc1f7d9250..01bc0076497c6d 100644
--- a/Python/jit.c
+++ b/Python/jit.c
@@ -431,8 +431,10 @@ void patch_aarch64_trampoline(unsigned char *location, int ordinal, jit_state *s
#if defined(__aarch64__) || defined(_M_ARM64)
#define TRAMPOLINE_SIZE 16
+ #define DATA_ALIGN 8
#else
#define TRAMPOLINE_SIZE 0
+ #define DATA_ALIGN 1
#endif
// Generate and patch AArch64 trampolines. The symbols to jump to are stored
@@ -522,8 +524,9 @@ _PyJIT_Compile(_PyExecutorObject *executor, const _PyUOpInstruction trace[], siz
// Round up to the nearest page:
size_t page_size = get_page_size();
assert((page_size & (page_size - 1)) == 0);
- size_t padding = page_size - ((code_size + state.trampolines.size + data_size) & (page_size - 1));
- size_t total_size = code_size + state.trampolines.size + data_size + padding;
+ size_t code_padding = DATA_ALIGN - ((code_size + state.trampolines.size) & (DATA_ALIGN - 1));
+ size_t padding = page_size - ((code_size + state.trampolines.size + code_padding + data_size) & (page_size - 1));
+ size_t total_size = code_size + state.trampolines.size + code_padding + data_size + padding;
unsigned char *memory = jit_alloc(total_size);
if (memory == NULL) {
return -1;
@@ -545,7 +548,7 @@ _PyJIT_Compile(_PyExecutorObject *executor, const _PyUOpInstruction trace[], siz
// Loop again to emit the code:
unsigned char *code = memory;
state.trampolines.mem = memory + code_size;
- unsigned char *data = memory + code_size + state.trampolines.size;
+ unsigned char *data = memory + code_size + state.trampolines.size + code_padding;
// Compile the shim, which handles converting between the native
// calling convention and the calling convention used by jitted code
// (which may be different for efficiency reasons).
@@ -567,7 +570,7 @@ _PyJIT_Compile(_PyExecutorObject *executor, const _PyUOpInstruction trace[], siz
code += group->code_size;
data += group->data_size;
assert(code == memory + code_size);
- assert(data == memory + code_size + state.trampolines.size + data_size);
+ assert(data == memory + code_size + state.trampolines.size + code_padding + data_size);
#ifdef MAP_JIT
pthread_jit_write_protect_np(1);
#endif
diff --git a/Tools/jit/_optimizers.py b/Tools/jit/_optimizers.py
index 1077e4106fdfbd..33db110b728dba 100644
--- a/Tools/jit/_optimizers.py
+++ b/Tools/jit/_optimizers.py
@@ -70,21 +70,21 @@ class Optimizer:
path: pathlib.Path
_: dataclasses.KW_ONLY
- # prefix used to mangle symbols on some platforms:
- prefix: str = ""
+ # Prefixes used to mangle local labels and symbols:
+ label_prefix: str
+ symbol_prefix: str
# The first block in the linked list:
_root: _Block = dataclasses.field(init=False, default_factory=_Block)
_labels: dict[str, _Block] = dataclasses.field(init=False, default_factory=dict)
# No groups:
_re_noninstructions: typing.ClassVar[re.Pattern[str]] = re.compile(
- r"\s*(?:\.|#|//|$)"
+ r"\s*(?:\.|#|//|;|$)"
)
# One group (label):
_re_label: typing.ClassVar[re.Pattern[str]] = re.compile(
r'\s*(?P