pfalcon / python-compiler.old

Python2 compiler package ported to Python3. Compiles Python AST (as produced by the "ast" module) to bytecode assembly and code objects.
https://docs.python.org/2/library/compiler.html
Other
41 stars 3 forks source link

Revamp co_stacksize calculation #3

Open pfalcon opened 5 years ago

pfalcon commented 5 years ago

Currently, it definitely doesn't work correctly. The implementation looks over-engineered - it seems to attempt to implement dataflow analysis over arbitrary CFG, which is absolutely great if it's implemented correctly and works. And if it doesn't, there's always suspicion about the implementation correctness. And Python compilers (CPython's and this) at the current level of optimization produce structured CFGs anyway, so dataflow analysis with "meet over all paths" isn't needed. Instead, structured recursive analysis should be enough (e.g., stack use of if is max of stack use of its branches + stack use of the if itself).

pfalcon commented 4 years ago

Per https://github.com/pfalcon/python-compiler/issues/7#issuecomment-531453470, I switched working on my own bytecode compiler, written from scratch. I unlikely will work on this issue anytime soon, but leaving it open for possible interested parties.