Skip to content
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

Redundant jump instructions due to deleted unreachable bytecode blocks #86781

Closed
OmG-117 mannequin opened this issue Dec 10, 2020 · 2 comments
Closed

Redundant jump instructions due to deleted unreachable bytecode blocks #86781

OmG-117 mannequin opened this issue Dec 10, 2020 · 2 comments
Labels
3.10 only security fixes performance Performance or resource usage

Comments

@OmG-117
Copy link
Mannequin

OmG-117 mannequin commented Dec 10, 2020

BPO 42615
Nosy @markshannon, @OmG-117
PRs
  • bpo-42615: Delete redundant jump instructions that only bypass empty blocks #23733
  • Files
  • jmptest.py: This file contains a short function that exhibits this behavior. Notice the JUMP_FORWARD 0 instruction, which does nothing.
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2020-12-16.14:43:48.978>
    created_at = <Date 2020-12-10.16:47:13.158>
    labels = ['3.10', 'performance']
    title = 'Redundant jump instructions due to deleted unreachable bytecode blocks'
    updated_at = <Date 2020-12-16.14:43:48.978>
    user = 'https://github.com/OmG-117'

    bugs.python.org fields:

    activity = <Date 2020-12-16.14:43:48.978>
    actor = 'OmG'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-12-16.14:43:48.978>
    closer = 'OmG'
    components = []
    creation = <Date 2020-12-10.16:47:13.158>
    creator = 'OmG'
    dependencies = []
    files = ['49664']
    hgrepos = []
    issue_num = 42615
    keywords = ['patch']
    message_count = 2.0
    messages = ['382834', '383157']
    nosy_count = 2.0
    nosy_names = ['Mark.Shannon', 'OmG']
    pr_nums = ['23733']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'performance'
    url = 'https://bugs.python.org/issue42615'
    versions = ['Python 3.10']

    @OmG-117
    Copy link
    Mannequin Author

    OmG-117 mannequin commented Dec 10, 2020

    During optimization, the compiler deletes blocks that are marked as unreachable. In doing so, it can render jump instructions that used to jump over the now-deleted blocks redundant, since simply falling through to the next non-empty block is now equivalent.

    An example of a place where this occurs is around "if condition: statement; else: break" style structures (see attached proof of concept code below), but this is a general case and could occur in other places.

    Tested on the latest 3.10 branch including all recent compile.c changes.

    @OmG-117 OmG-117 mannequin added 3.10 only security fixes performance Performance or resource usage labels Dec 10, 2020
    @markshannon
    Copy link
    Member

    New changeset c71581c by Om G in branch 'master':
    bpo-42615: Delete redundant jump instructions that only bypass empty blocks (GH-23733)
    c71581c

    @OmG-117 OmG-117 mannequin closed this as completed Dec 16, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes performance Performance or resource usage
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant