summaryrefslogtreecommitdiffstats
path: root/Python/peephole.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-42057: Fix peephole optimizer (GH-22802)Inada Naoki2020-10-221-1/+1
|
* bpo-38249: Expand Py_UNREACHABLE() to __builtin_unreachable() in the release ↵Serhiy Storchaka2020-03-091-1/+5
| | | | | mode. (GH-16329) Co-authored-by: Victor Stinner <vstinner@python.org>
* bpo-39156: Break up COMPARE_OP into four logically distinct opcodes. (GH-17754)Mark Shannon2020-01-141-2/+4
| | | | | | | | Break up COMPARE_OP into four logically distinct opcodes: * COMPARE_OP for rich comparisons * IS_OP for 'is' and 'is not' tests * CONTAINS_OP for 'in' and 'is not' tests * JUMP_IF_NOT_EXC_MATCH for checking exceptions in 'try-except' statements.
* Produce cleaner bytecode for 'with' and 'async with' by generating separate ↵Mark Shannon2019-11-211-9/+3
| | | | | | code for normal and exceptional paths. (#6641) Remove BEGIN_FINALLY, END_FINALLY, CALL_FINALLY and POP_FINALLY bytecodes. Implement finally blocks by code duplication. Reimplement frame.lineno setter using line numbers rather than bytecode offsets.
* Fix unused variable and signed/unsigned warnings (GH-15537)Raymond Hettinger2019-08-271-2/+2
|
* bpo-37289: Remove 'if False' handling in the peephole optimizer (GH-14099)Pablo Galindo2019-06-151-9/+3
|
* bpo-37269: Correctly optimise conditionals with constant booleans (GH-14071)Pablo Galindo2019-06-141-0/+5
| | | | | | | | Fix a regression introduced by af8646c8054d0f4180a2013383039b6a472f9698 that was causing code of the form: if True and False: do_something() to be optimized incorrectly, eliminating the block.
* bpo-37213: Handle negative line deltas correctly in the peephole optimizer ↵Pablo Galindo2019-06-131-5/+9
| | | | | (GH-13969) The peephole optimizer was not optimizing correctly bytecode after negative deltas were introduced. This is due to the fact that some special values (255) were being searched for in both instruction pointer delta and line number deltas.
* bpo-1875: Raise SyntaxError in invalid blocks that will be optimised away ↵Pablo Galindo2019-05-171-4/+12
| | | | | | | (GH-13332) Move the check for dead conditionals (if 0) to the peephole optimizer and make sure that the code block is still compiled to report any existing syntax errors within.
* bpo-9566: Fix compiler warnings in peephole.c (GH-10652)Victor Stinner2018-12-071-21/+47
|
* bpo-35193: Fix an off by one error in the RETURN_VALUE case. (GH-10418)Gregory P. Smith2018-11-091-10/+12
| | | | | | | | | | | | Fix an off by one error in the peephole optimizer when checking for unreachable code beyond a return. Do a bounds check within find_op so it can return before going past the end as a safety measure. https://github.com/python/cpython/commit/7db3c488335168993689ddae5914a28e16188447#diff-a33329ae6ae0bb295d742f0caf93c137 introduced this off by one error while fixing another one nearby. This bug was shipped in all Python 3.6 and 3.7 releases. The included unittest won't fail unless you do a clang msan build.
* bpo-17611. Move unwinding of stack for "pseudo exceptions" from interpreter ↵Serhiy Storchaka2018-02-221-15/+18
| | | | | | | | | to compiler. (GH-5006) Co-authored-by: Mark Shannon <mark@hotpy.org> Co-authored-by: Antoine Pitrou <antoine@python.org>
* bpo-29469: peephole: Remove const_stack (GH-4879)INADA Naoki2017-12-181-81/+21
| | | | | | | | | | Constant folding was moved to AST optimizer. But compiler may emit LOAD_CONSTs + BUILD_TUPLE. For example, default arguments can be constant tuple if all arguments are constant. This commit makes peephole's tuple folding simple. It doesn't support nested tuples because nested tuples are folded by AST optimizer already.
* bpo-29469: Optimize literal lists and sets iterating on the AST level. (#4866)Serhiy Storchaka2017-12-141-24/+3
|
* bpo-29469: Remove unnecessary peephole optimizer (GH-4863)INADA Naoki2017-12-141-15/+0
| | | | | Conversions like `not a is b -> a is not b` are implemented in AST optimizer in previous commit (7ea143a). So this commit removes them from peephole optimizer.
* bpo-29469: Move constant folding to AST optimizer (GH-2858)INADA Naoki2017-12-141-193/+0
|
* bpo-30501: Make the compiler producing optimized code for condition ↵Serhiy Storchaka2017-06-111-12/+2
| | | | expressions. (#1851)
* Issue #28517: Fixed of-by-one error in the peephole optimizer that causedSerhiy Storchaka2016-10-251-2/+2
| | | | keeping unreachable code.
* Fixed refactoring bug in dd046963bd42 (issue27129).Serhiy Storchaka2016-09-111-1/+1
|
* Issue #27129: Replaced wordcode related magic constants with macros.Serhiy Storchaka2016-09-111-105/+112
|
* Re-linewrap commentsRaymond Hettinger2016-08-081-13/+8
|
* Issue #27076: Merge spelling from 3.5Martin Panter2016-05-261-1/+1
|\
| * Issue #27076: Doc, comment and tests spelling fixesMartin Panter2016-05-261-1/+1
| | | | | | | | Most fixes to Doc/ and Lib/ directories by Ville Skyttä.
* | Issue #26647: Python interpreter now uses 16-bit wordcode instead of bytecode.Serhiy Storchaka2016-05-241-263/+313
| | | | | | | | Patch by Demur Rumed.
* | Issue #22570: Renamed Py_SETREF to Py_XSETREF.Serhiy Storchaka2016-04-061-1/+1
|\ \ | |/
* | co_lnotab supports negative line number deltaVictor Stinner2016-01-201-23/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #26107: The format of the co_lnotab attribute of code objects changes to support negative line number delta. Changes: * assemble_lnotab(): if line number delta is less than -128 or greater than 127, emit multiple (offset_delta, lineno_delta) in co_lnotab * update functions decoding co_lnotab to use signed 8-bit integers - dis.findlinestarts() - PyCode_Addr2Line() - _PyCode_CheckLineNumber() - frame_setlineno() * update lnotab_notes.txt * increase importlib MAGIC_NUMBER to 3361 * document the change in What's New in Python 3.6 * cleanup also PyCode_Optimize() to use better variable names
* | Issue #20440: Cleaning up the code by using Py_SETREF.Serhiy Storchaka2016-01-051-3/+1
|/
* PEP 0492 -- Coroutines with async and await syntax. Issue #24017.Yury Selivanov2015-05-121-0/+3
|
* Issue #23450: Silenced compiler warnings and added asserts in peephole ↵Serhiy Storchaka2015-02-161-3/+9
| | | | optimizer.
* Issue #23446: Use PyMem_New instead of PyMem_Malloc to avoid possible integerSerhiy Storchaka2015-02-161-2/+2
| | | | overflows. Added few missed PyErr_NoMemory().
* Issue #19437: Fix fold_unaryops_on_constants() of the peephole optimizer, clearVictor Stinner2013-11-141-0/+1
| | | | the exception when PyList_Append() fails
* Issue #18408: Fix PyCode_Optimize(): raise a MemoryError on memory allocationVictor Stinner2013-07-081-2/+6
| | | | failure.
* create NameConstant AST class for None, True, and False literals (closes #16619)Benjamin Peterson2012-12-061-46/+0
|
* Implement PEP 393.Martin v. Löwis2011-09-281-18/+0
|
* Issue #13002: Fix Visual Studio warning (not enough actual parameters).Stefan Krah2011-09-211-1/+1
|
* #5057: Merge with 3.2.Ezio Melotti2011-04-151-0/+18
|\
| * #5057: Merge with 3.1.Ezio Melotti2011-04-151-0/+18
| |\
| | * Issue #5057: fix a bug in the peepholer that led to non-portable pyc files ↵Ezio Melotti2011-04-151-0/+18
| | | | | | | | | | | | between narrow and wide builds while optimizing BINARY_SUBSCR on non-BMP chars (e.g. "\U00012345"[0]).
| | * Recorded merge of revisions 81032 via svnmerge fromAntoine Pitrou2010-05-091-598/+598
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r81032 | antoine.pitrou | 2010-05-09 17:52:27 +0200 (dim., 09 mai 2010) | 9 lines Recorded merge of revisions 81029 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines Untabify C files. Will watch buildbots. ........ ................
| | * Merged revisions 74126,74130-74131,74149,74155,74157,74180-74183,74398 via ↵Georg Brandl2009-08-131-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | svnmerge from svn+ssh://svn.python.org/python/branches/py3k ................ r74126 | alexandre.vassalotti | 2009-07-21 02:39:03 +0200 (Di, 21 Jul 2009) | 14 lines Merged revisions 73871 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r73871 | alexandre.vassalotti | 2009-07-06 22:17:30 -0400 (Mon, 06 Jul 2009) | 7 lines Grow the allocated buffer in PyUnicode_EncodeUTF7 to avoid buffer overrun. Without this change, test_unicode.UnicodeTest.test_codecs_utf7 crashes in debug mode. What happens is the unicode string u'\U000abcde' with a length of 1 encodes to the string '+2m/c3g-' of length 8. Since only 5 bytes is reserved in the buffer, a buffer overrun occurs. ........ ................ r74130 | alexandre.vassalotti | 2009-07-21 02:57:50 +0200 (Di, 21 Jul 2009) | 2 lines Add ignore rule for the Doc/tools/jinga2/ directory. ................ r74131 | alexandre.vassalotti | 2009-07-21 04:51:58 +0200 (Di, 21 Jul 2009) | 13 lines Merged revisions 73683,73786 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r73683 | georg.brandl | 2009-06-29 10:44:49 -0400 (Mon, 29 Jun 2009) | 1 line Fix error handling in PyCode_Optimize, by Alexander Schremmer at EuroPython sprint. ........ r73786 | benjamin.peterson | 2009-07-02 18:56:16 -0400 (Thu, 02 Jul 2009) | 1 line condense with assertRaises ........ ................ r74149 | ezio.melotti | 2009-07-21 22:37:52 +0200 (Di, 21 Jul 2009) | 9 lines Merged revisions 74148 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r74148 | ezio.melotti | 2009-07-21 23:18:27 +0300 (Tue, 21 Jul 2009) | 1 line #6536 fixed typo ........ ................ r74155 | alexandre.vassalotti | 2009-07-22 04:24:49 +0200 (Mi, 22 Jul 2009) | 2 lines Issue #6242: Fix deallocator of io.StringIO and io.BytesIO. ................ r74157 | alexandre.vassalotti | 2009-07-22 05:07:33 +0200 (Mi, 22 Jul 2009) | 2 lines Issue #6241: Better type checking for the arguments of io.StringIO. ................ r74180 | ezio.melotti | 2009-07-22 23:17:14 +0200 (Mi, 22 Jul 2009) | 9 lines Merged revisions 74179 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r74179 | ezio.melotti | 2009-07-23 00:08:49 +0300 (Thu, 23 Jul 2009) | 1 line #6423 has_key -> in ........ ................ r74181 | alexandre.vassalotti | 2009-07-22 23:27:53 +0200 (Mi, 22 Jul 2009) | 6 lines Clean up test_curses. By using __stdout__ directly, test_curses caused regrtest.py to duplicate the output of some test results. ................ r74182 | alexandre.vassalotti | 2009-07-22 23:29:01 +0200 (Mi, 22 Jul 2009) | 2 lines Use assertGreater instead of assertTrue(x > y). ................ r74183 | alexandre.vassalotti | 2009-07-23 01:27:17 +0200 (Do, 23 Jul 2009) | 4 lines Specialize assertTrue checks when possible. We should get slightly more helpful failure messages with this change. ................ r74398 | georg.brandl | 2009-08-13 11:16:39 +0200 (Do, 13 Aug 2009) | 1 line #6694: fix old function names. ................
| * | Issue 11510: Fix BUILD_SET optimizer bug.Raymond Hettinger2011-03-151-1/+2
| | |
* | | Issue #11244: Remove outdated peepholer check that was preventing the ↵Mark Dickinson2011-03-231-4/+2
| | | | | | | | | | | | peepholer from folding -0 and -0.0. Thanks Eugene Toder for the patch.
* | | Issue 11510: Fix BUILD_SET optimizer bug.Raymond Hettinger2011-03-151-1/+2
| | |
* | | Issue #11244: The peephole optimizer is now able to constant-foldAntoine Pitrou2011-03-111-47/+120
|/ / | | | | | | | | arbitrarily complex expressions. This also fixes a 3.2 regression where operations involving negative numbers were not constant-folded.
* | Remove redundant includes of headers that are already included by Python.h.Georg Brandl2010-11-301-2/+0
| |
* | Issue 8403: Don't mask KeyboardInterrupt during peephole operation.Raymond Hettinger2010-08-221-4/+8
| |
* | Recorded merge of revisions 81029 via svnmerge fromAntoine Pitrou2010-05-091-616/+616
| | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r81029 | antoine.pitrou | 2010-05-09 16:46:46 +0200 (dim., 09 mai 2010) | 3 lines Untabify C files. Will watch buildbots. ........
* | Issue #6690: Optimize the bytecode for expressions such as `x in {1, 2, 3}`,Antoine Pitrou2010-01-161-4/+16
| | | | | | | | | | | | | | | | | | where the right hand operand is a set of constants, by turning the set into a frozenset and pre-building it as a constant. The comparison operation is made against the constant instead of building a new set each time it is executed (a similar optimization already existed which turned a list of constants into a pre-built tuple). Patch and additional tests by Dave Malcolm.
* | Peephole constant folding had missed UNARY_POSITIVE.Raymond Hettinger2009-10-221-0/+4
| |
* | Merged revisions 73683,73786 via svnmerge fromAlexandre Vassalotti2009-07-211-6/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | svn+ssh://pythondev@svn.python.org/python/trunk ........ r73683 | georg.brandl | 2009-06-29 10:44:49 -0400 (Mon, 29 Jun 2009) | 1 line Fix error handling in PyCode_Optimize, by Alexander Schremmer at EuroPython sprint. ........ r73786 | benjamin.peterson | 2009-07-02 18:56:16 -0400 (Thu, 02 Jul 2009) | 1 line condense with assertRaises ........