8000 GH-135904: Optimize the JIT's assembly control flow by brandtbucher · Pull Request #135905 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-135904: Optimize the JIT's assembly control flow #135905

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jun 27, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Shake out some bugs on Windows
  • Loading branch information
brandtbucher committed Jun 20, 2025
commit 4f85fabfff69fd9086cbbd946f98eacd002826a8
10 changes: 6 additions & 4 deletions Tools/jit/_optimizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ class Optimizer:
)
_re_jump: typing.ClassVar[re.Pattern[str]] = _RE_NEVER_MATCH # One group: target.
_re_label: typing.ClassVar[re.Pattern[str]] = re.compile(
r"\s*(?P<label>[\w\.]+):"
r'\s*(?P<label>[\w"$.?@]+):'
) # One group: label.
_re_noise: typing.ClassVar[re.Pattern[str]] = re.compile(
r"\s*(?:[#\.]|$)"
r"\s*(?:[#.]|$)"
) # No groups.
_re_return: typing.ClassVar[re.Pattern[str]] = _RE_NEVER_MATCH # No groups.

Expand Down Expand Up @@ -257,6 +257,8 @@ def _remove_dead_code(self) -> None:
todo.append(block.link)
for block in self._blocks():
if block not in reachable:
block.target = None
block.fallthrough = True
block.instructions.clear()

def _remove_redundant_jumps(self) -> None:
Expand Down Expand Up @@ -301,9 +303,9 @@ class OptimizerX86(Optimizer):

_branches = _X86_BRANCHES
_re_branch = re.compile(
rf"\s*(?P<instruction>{'|'.join(_X86_BRANCHES)})\s+(?P<target>[\w\.]+)"
rf"\s*(?P<instruction>{'|'.join(_X86_BRANCHES)})\s+(?P<target>[\w.]+)"
)
_re_jump = re.compile(r"\s*jmp\s+(?P<target>[\w\.]+)")
_re_jump = re.compile(r"\s*jmp\s+(?P<target>[\w.]+)")
_re_return = re.compile(r"\s*ret\b")

@staticmethod
Expand Down
0