Do not generate Java for unused dynamic rules
(minor)
I noticed that for each DR Stratego/J generates 18 Java strategies (DR, once-DR, bagof-DR, bigbagof-DR, …), while (at least in my experience) generally only 1 or 2 of those strategies are used.
It may be useful to have the compiler check which ones are actually used, and generate only those.
Some numbers (of a few days ago) on my project:
- 19 DRs, each used in one way only (17 unused strategies per DR)
- 19 * 17 => 323 unused Java files generated and compiled, on a total of 1387 Java files
- potential benefit: up to 23% faster compilation :-)
(Or does this option already exist somewhere where I didn’t look yet?)
Submitted by Tobi Vollebregt on 12 January 2011 at 12:45
Issue Log
I’m pretty sure it does this already, as long as you don’t use the
--library
option that disables the dead code elimination. For Spoofax, this option is used as Spoofax programs have multiple entry points…
Aha, interesting.
I tried removing the –library option and tricked the compiler into exporting all necessary strategies by adding a (never executed)
main
strategy that lists all public strategies. (Might be an idea to automate that at some point; after all this list of strategies is known from the .esv files)This reduced the number of generated Java files from 1377 to 609 (!), and also halfed the compilation time :-)
One other observation: the aux-DR strategy kept existing for all my DRs, while I never explicitly use it. Calls to this are generated as part of some syntactic construct? (one guess: DR scope?)
Log in to post comments