summaryrefslogtreecommitdiffstats
path: root/Tools/jit
diff options
context:
space:
mode:
authorBrandt Bucher <brandtbucher@microsoft.com>2024-04-06 15:26:43 (GMT)
committerGitHub <noreply@github.com>2024-04-06 15:26:43 (GMT)
commit62aeb0ee69b06091396398de56dcb755ca3b9dc9 (patch)
treea45c8e920b3679cb3f7ca371b9b36fd5211c68bf /Tools/jit
parentdf4d84c3cdca572f1be8f5dc5ef8ead5351b51fb (diff)
downloadcpython-62aeb0ee69b06091396398de56dcb755ca3b9dc9.zip
cpython-62aeb0ee69b06091396398de56dcb755ca3b9dc9.tar.gz
cpython-62aeb0ee69b06091396398de56dcb755ca3b9dc9.tar.bz2
GH-117512: Allow 64-bit JIT operands on 32-bit platforms (GH-117527)
Diffstat (limited to 'Tools/jit')
-rw-r--r--Tools/jit/_stencils.py5
-rw-r--r--Tools/jit/_writer.py4
-rw-r--r--Tools/jit/template.c7
3 files changed, 13 insertions, 3 deletions
diff --git a/Tools/jit/_stencils.py b/Tools/jit/_stencils.py
index 601ea0b..243bb3d 100644
--- a/Tools/jit/_stencils.py
+++ b/Tools/jit/_stencils.py
@@ -27,8 +27,11 @@ class HoleValue(enum.Enum):
GOT = enum.auto()
# The current uop's oparg (exposed as _JIT_OPARG):
OPARG = enum.auto()
- # The current uop's operand (exposed as _JIT_OPERAND):
+ # The current uop's operand on 64-bit platforms (exposed as _JIT_OPERAND):
OPERAND = enum.auto()
+ # The current uop's operand on 32-bit platforms (exposed as _JIT_OPERAND_HI and _JIT_OPERAND_LO):
+ OPERAND_HI = enum.auto()
+ OPERAND_LO = enum.auto()
# The current uop's target (exposed as _JIT_TARGET):
TARGET = enum.auto()
# The base address of the machine code for the jump target (exposed as _JIT_JUMP_TARGET):
diff --git a/Tools/jit/_writer.py b/Tools/jit/_writer.py
index 8a2a42e..cbc1ed2 100644
--- a/Tools/jit/_writer.py
+++ b/Tools/jit/_writer.py
@@ -17,7 +17,7 @@ def _dump_header() -> typing.Iterator[str]:
yield "} HoleValue;"
yield ""
yield "typedef struct {"
- yield " const uint64_t offset;"
+ yield " const size_t offset;"
yield " const HoleKind kind;"
yield " const HoleValue value;"
yield " const void *symbol;"
@@ -58,7 +58,7 @@ def _dump_footer(opnames: typing.Iterable[str]) -> typing.Iterator[str]:
yield ""
yield "#define GET_PATCHES() { \\"
for value in _stencils.HoleValue:
- yield f" [HoleValue_{value.name}] = (uint64_t)0xBADBADBADBADBADB, \\"
+ yield f" [HoleValue_{value.name}] = (uintptr_t)0xBADBADBADBADBADB, \\"
yield "}"
diff --git a/Tools/jit/template.c b/Tools/jit/template.c
index 2300bd0..b195aff 100644
--- a/Tools/jit/template.c
+++ b/Tools/jit/template.c
@@ -88,7 +88,14 @@ _JIT_ENTRY(_PyInterpreterFrame *frame, PyObject **stack_pointer, PyThreadState *
int uopcode = _JIT_OPCODE;
// Other stuff we need handy:
PATCH_VALUE(uint16_t, _oparg, _JIT_OPARG)
+#if SIZEOF_VOID_P == 8
PATCH_VALUE(uint64_t, _operand, _JIT_OPERAND)
+#else
+ assert(SIZEOF_VOID_P == 4);
+ PATCH_VALUE(uint32_t, _operand_hi, _JIT_OPERAND_HI)
+ PATCH_VALUE(uint32_t, _operand_lo, _JIT_OPERAND_LO)
+ uint64_t _operand = ((uint64_t)_operand_hi << 32) | _operand_lo;
+#endif
PATCH_VALUE(uint32_t, _target, _JIT_TARGET)
PATCH_VALUE(uint16_t, _exit_index, _JIT_EXIT_INDEX)