Skip to content

Commit

Permalink
bpo-29469: Move constant folding to AST optimizer (GH-2858)
Browse files Browse the repository at this point in the history
  • Loading branch information
methane authored Dec 14, 2017
1 parent b5fd9ad commit 7ea143a
Show file tree
Hide file tree
Showing 11 changed files with 4,431 additions and 3,966 deletions.
3 changes: 3 additions & 0 deletions Doc/whatsnew/3.7.rst
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,9 @@ Optimizations
and :meth:`selectors.DevpollSelector.modify` may be around 10% faster under
heavy loads. (Contributed by Giampaolo Rodola' in :issue:`30014`)

* Constant folding is moved from peephole optimizer to new AST optimizer.
(Contributed by Eugene Toder and INADA Naoki in :issue:`29469`)

Build and C API Changes
=======================

Expand Down
2 changes: 2 additions & 0 deletions Include/compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
#define PY_INVALID_STACK_EFFECT INT_MAX
PyAPI_FUNC(int) PyCompile_OpcodeStackEffect(int opcode, int oparg);

PyAPI_FUNC(int) _PyAST_Optimize(struct _mod *, PyArena *arena);

#ifdef __cplusplus
}
#endif
Expand Down
1 change: 1 addition & 0 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ PYTHON_OBJS= \
Python/Python-ast.o \
Python/asdl.o \
Python/ast.o \
Python/ast_opt.o \
Python/bltinmodule.o \
Python/ceval.o \
Python/compile.o \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Move constant folding from bytecode layer to AST layer.
Original patch by Eugene Toder.
1 change: 1 addition & 0 deletions PCbuild/pythoncore.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@
<ClCompile Include="..\Python\_warnings.c" />
<ClCompile Include="..\Python\asdl.c" />
<ClCompile Include="..\Python\ast.c" />
<ClCompile Include="..\Python\ast_opt.c" />
<ClCompile Include="..\Python\bltinmodule.c" />
<ClCompile Include="..\Python\bootstrap_hash.c" />
<ClCompile Include="..\Python\ceval.c" />
Expand Down
3 changes: 3 additions & 0 deletions PCbuild/pythoncore.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,9 @@
<ClCompile Include="..\Python\ast.c">
<Filter>Python</Filter>
</ClCompile>
<ClCompile Include="..\Python\ast_opt.c">
<Filter>Python</Filter>
</ClCompile>
<ClCompile Include="..\Python\bltinmodule.c">
<Filter>Python</Filter>
</ClCompile>
Expand Down
Loading

0 comments on commit 7ea143a

Please sign in to comment.