What we Found in the BEAM Code
summary
Claim: recover an Erlang abstract syntax tree from BEAM bytecode even without debug info. Built a pipeline using beam disassembly, an intermediate representation that expands VM steps, SSA conversion and graph-rewriting to restructure unstructured control flow into a functional normal form, then emit Erlang AST and feed it into refactor integration. Demonstrations show reconstructed conditionals, constants (42) and added function edges, but original variable names, macros and some patterns are lost and large modules run slowly.
AI-written summary · about
chapters (15)
- 0:00Intro
- 0:44Motivation
- 3:00Refactor Eri
- 6:17Machine code vs. BEAM
- 8:17What is the problem?
- 8:49Is it starightforward? NO!
- 10:55Decompiler workflow
- 11:36Disassambled BEAM
- 12:34Intermediate Representation
- 16:18Control Flow Graph (CFG)
- 17:36Static Single Assignment (SSA)
- 19:22Structuring
- 25:12A-Normal Form
- 27:59Code generation Methodology
- 41:03Future Notes
related talks
39mCheck your code with RefactorErl!
40mIntelliJ Elixir Works Even if your Code Doesn't
29mAST: the Secret Weapon to Transform a Codebase
29mMy Little Parser: Tooling is Magic
33mEmbracing Black Magic: The Power of Code Transpilation
31mAdvanced JavaScript code search: Abstract Syntax Tree analysis
34mThe Future of Erlang LS
15mAdaptable Traces for Program Explanations
