This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: improved data-flow analysis for Kawa
On 04/23/2011 12:19 AM, Helmut Eller wrote:
* Per Bothner [2011-04-18 18:41] writes:
I've checked in a much-improved data-flow framework for Kawa.
This is similar to Static Single Assignment, but of course
with the extra complication of functions and classes.
I now get a stack overflow with when compiling some of my code. It
seems to be in a big function with lots of macros. Do you have any tips
of how one could reduce that to a small test case?
You just have to remove code as long as it still fails. It's
trial-and-error.
Often you can try simplifying procedure bodies radically - for example
have a function just replace a constant or a parameter value.
If I add --debug-print-expr Kawa prints the expression tree before the
stack overflow. Does that mean that macro expansion was completed?
Yes. Macro-expansion happens in the language-specific "parser" stage,
the end-point of which is Expression tree. The various optimizations
(including the new pass) happens at the Expression level.
(Though it is possible that syntax-case macros might be evaluated
early, of course.)
In the stacktrace I see things like
java.lang.reflect.Method.invoke(Method.java:613)
gnu.expr.InlineCalls.maybeInline(InlineCalls.java:691)
gnu.expr.QuoteExp.validateApply(QuoteExp.java:148)
Is it normal that reflection is used during compilation?
Yes. Most of the reflection is "introspection" - to figure out
method names and parameter types, for example. This particular
invoke is to call a procedure-specific inline/validate method.
We use inlining to separate out compile-time code from the
actual run-time value of the procedure, to reduce footprint.
I.e. so "kawart.jar" doesn't need all the compiling/optimizing
support. (This separate is another work in progress.)
This call to a Procedure's validate-apply property is part
of the analysis phase, where we do inlining, simplification,
constant-folding, and type-inferencing. It's one messy pass
because these all interact.
--
--Per Bothner
per@bothner.com http://per.bothner.com/