https://github.com/python/cpython/commit/05e89c34bd8389f87bd6c9462d5a06ef9e1a65ab
commit: 05e89c34bd8389f87bd6c9462d5a06ef9e1a65ab
branch: main
author: Brandt Bucher <[email protected]>
committer: brandtbucher <[email protected]>
date: 2025-02-13T10:51:03-08:00
summary:

GH-115869: Don't JIT zeroed bytes (GH-130023)

files:
M Tools/jit/_writer.py

diff --git a/Tools/jit/_writer.py b/Tools/jit/_writer.py
index 5588784544ee00..090b52660f009c 100644
--- a/Tools/jit/_writer.py
+++ b/Tools/jit/_writer.py
@@ -49,15 +49,16 @@ def _dump_stencil(opname: str, group: 
_stencils.StencilGroup) -> typing.Iterator
     for part, stencil in [("code", group.code), ("data", group.data)]:
         for line in stencil.disassembly:
             yield f"    // {line}"
-        if stencil.body:
+        stripped = stencil.body.rstrip(b"\x00")
+        if stripped:
             yield f"    const unsigned char {part}_body[{len(stencil.body)}] = 
{{"
-            for i in range(0, len(stencil.body), 8):
-                row = " ".join(f"{byte:#04x}," for byte in stencil.body[i : i 
+ 8])
+            for i in range(0, len(stripped), 8):
+                row = " ".join(f"{byte:#04x}," for byte in stripped[i : i + 8])
                 yield f"        {row}"
             yield "    };"
     # Data is written first (so relaxations in the code work properly):
     for part, stencil in [("data", group.data), ("code", group.code)]:
-        if stencil.body:
+        if stencil.body.rstrip(b"\x00"):
             yield f"    memcpy({part}, {part}_body, sizeof({part}_body));"
         skip = False
         stencil.holes.sort(key=lambda hole: hole.offset)

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to