Re: inling/tail recursion, recursive decent parser

diablovision@yahoo.com
30 Jun 2005 10:01:31 -0400

          From comp.compilers

Related articles
inling/tail recursion, recursive decent parser spam@disney.com (Lefteris Keftedopoulos) (2005-06-21)
Re: inling/tail recursion, recursive decent parser henry@spsystems.net (2005-06-23)
Re: inling/tail recursion, recursive decent parser diablovision@yahoo.com (2005-06-30)
Re: inling/tail recursion, recursive decent parser ronny@cs.ru.nl (Ronny Wichers Schreur) (2005-07-02)
Re: inling/tail recursion, recursive decent parser cfc@shell01.TheWorld.com (Chris F Clark) (2005-07-02)
| List of all articles for this month |

From: diablovision@yahoo.com
Newsgroups: comp.compilers
Date: 30 Jun 2005 10:01:31 -0400
Organization: http://groups.google.com
References: 05-06-100
Keywords: parse, practice
Posted-Date: 30 Jun 2005 10:01:31 EDT



Lefteris Keftedopoulos wrote:
> 1)
> Would inlining / tail recursion have significant effect on the amount
> of call stack space used by a recursive decent parser?
>
> 2)
> would a generated parser (javaCC) compiled by javac, automatically
> be inlined / and tail recursionified by javac, and would it have any
> significant effect.
>


Javac does not perform inlining, even for private methods. Bytecode has
no way to express tail recursive calls, and Java's exception model
(i.e. the availability of a stack trace) makes it basically impossible
to do tail recursion elimination, either by Javac or by the VM. VM's
will do aggressive inlining of calls along hot paths using CHA or
guarded inling strategies; in fact, I think that worrying about what
calls are present in the bytecode of your application isn't much
warranted these days, as VMs are getting more and more aggressive
optimization strategies.


If you're worried about the call stack depth, I'd suggest that you
re-engineer your grammar to be more iterative and less recursive (i.e.
use lists of productions rather than tail-recursive productions). Also,
unless you are worried about running on an embedded device (in which
case, your performance problems are severe due to the slowness of
crappy VMs for phones and such), don't even bother worrying about call
stack depth.


And I would suggest that you get real familiar with the profiling
utilities in the standard VM (e.g. Hotspot) and profile your parser in
detail before you begin optimization. Unless you live and die by a
profiler, you're only kidding yourself that you care about performance.



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.