8000 bpo-37271: Optimize bytecode multiple times until it cannot be optimized further by pablogsal · Pull Request #14068 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-37271: Optimize bytecode multiple times until it cannot be optimized further #14068

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

Closed
wants to merge 6 commits into from
Closed
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
Move comment to old function
  • Loading branch information
pablogsal committed Sep 9, 2019
commit cba492736ff3247002f1c1272b0b5d96a0c1784e
26 changes: 13 additions & 13 deletions Python/peephole.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,19 @@ markblocks(_Py_CODEUNIT *code, Py_ssize_t len)
return blocks;
}

/* Perform basic peephole optimizations to components of a code object.
The consts object should still be in list form to allow new constants
to be appended.

To keep the optimizer simple, it bails when the lineno table has complex
encoding for gaps >= 255.

Optimizations are restricted to simple transformations occurring within a
single basic block. All transformations keep the code size the same or
smaller. For those that reduce size, the gaps are initially filled with
NOPs. Later those NOPs are removed and the jump addresses retargeted in
a single pass. */

static PyObject *
optimize_bytecode_once(PyObject *code, PyObject* consts, PyObject *names,
PyObject *lnotab_obj)
Expand Down Expand Up @@ -529,19 +542,6 @@ optimize_bytecode_once(PyObject *code, PyObject* consts, PyObject *names,
return code;
}

/* Perform basic peephole optimizations to components of a code object.
The consts object should still be in list form to allow new constants
to be appended.

To keep the optimizer simple, it bails when the lineno table has complex
encoding for gaps >= 255.

Optimizations are restricted to simple transformations occurring within a
single basic block. All transformations keep the code size the same or
smaller. For those that reduce size, the gaps are initially filled with
NOPs. Later those NOPs are removed and the jump addresses retargeted in
a single pass. */

PyObject *
PyCode_Optimize(PyObject *code, PyObject *consts, PyObject *names,
PyObject *lnotab_obj)
Expand Down
0