[antlr-interest] FEATURE REQUEST: continued and memory/speedissues
ric.klaren at gmail.com
Mon Jan 3 02:59:35 PST 2005
On Sun, 2 Jan 2005 23:57:58 -0800 (PST), Akhilesh Mritunjai
<virtualaspirin at yahoo.com> wrote:
> As of now there are three reference counted garbage
> collector implementations in C++ code generator (viz-
> RefCount, ASTRefCount and ref_ptr/TokenRefCount).
Don't get me started on those. I had planned to move to one reference
counter after 2.7.4 release. Someone contributed a pretty nifty
replacement but I didn't get it to work for 2.7.5 release so I had to
revert to the old ones just to get the release out. (The new one
worked ok, but I needed to do some tricky changes to the codegenerator
for heterogeneous AST's and that's not something I want to do 1-2
weeks before releasing a prerelease)
> Among these, the ref_ptr is most feature rich
> (ASTRefCount is similar, but hard coded for use with
> AST class, and TokenRefCount is, I believe, adaptation
> in 2.7.5 of ref_ptr (of development snapshot build)
> for use with Token class [why???]). RefCount is most
> simple and non-intrusive, but most inflexible one.
For heterogenous AST's the current reference counters allow some dirty
casting (up and down). TokenRefCount was added this release just to
get the tokenstream rewrite engine going, I must admit it's a
dirty/shamefull copy paste. Previously the C++ runtime didn't work
100% (convenient) with custom token classes. Considering time I had to
or take out the tokenstream rewrite engine or make changes to the
reference counter. (2.7.5 main goal is to get the python codegen out)
> Is there any specific reason for all of three to
> co-exist, or can we do away with all and standardize
> on deriving from 'Countable' and using ref_ptr ?
If it wasn't for heterogeneous AST support we'd be using one now, the
ones from wheatfarm.org (thanks to Mark Lentczner). Countable/ref_ptr
are not in the 2.7.5 release anymore. I could have release with
Countable/ref_ptr for the tokens/SharedInputStates and the old ones
for the AST's but it seemed better to me to release with just the old
'brand' and leave options open for after 2.7.5 release.
I will probably investigate getting rid of the reference counter for
the AST's and Tokens. This will give a good speed up and make the
heterogenous AST stuff less of a headache on the codegen front.
More information about the antlr-interest