3 ms·
It tends to be quadratic, based on the number of variables and the cyclomatic complexity. The DFA equations cannot be solved directly, but only iteratively unti
by WalterBright 7y ago
It tends to be quadratic, based on the number of variables and the cyclomatic complexity. The DFA equations cannot be solved directly, but only iteratively until a solution is reached.
Debug code generation, on the other hand, involves none of that and the compiler just blasts out code expression by expression. The time goes up linearly with the number of expressions.
DFA (and the O/B DFA) is done at the function level. It can be done globally, but I try to keep the compile times reasonable.
- mntmoss 7y agoIs an expensive DFA something that could be mitigated with source code hints? An 80% solution might do the trick.
- WalterBright 7y agoPeople using DFA tend to want a 100% solution. Rust, for example, sets a store on a 100% solution.
- kragen 7y agoCan you cache the solution from the last compile and check that it still works in linear time without introducing nondeterminism?
- WalterBright 7y agoMany implementors try to cache the results of DFA and patch it incrementally. Anecdotal evidence is that they spend endless hours dealing with weird optimization bugs because they patched it wrong. I decided to redo the DFA from scratch anytime the AST changed, and have had pretty reliable optimization as a result.
- jedharris 7y agoWould this help? <https://dl.acm.org/doi/10.1145/3302516.3307352> https://dl.acm.org/doi/10.1145/3302516.3307352> GPU-accelerated fixpoint algorithms for faster compiler analyses. Brute force but maybe that is what is needed.