|
Many algorithms are expressed
most concisely as
tail-recursive methods.
Compilers can automatically
transform such methods into
loops and thereby improve
program performance, but
this transformation is not
required by the Java
language specification,
so not all JVMs will perform
it. This means that
tail-recursive methods in
the Java language can result
in unexpectedly large memory
usage. This article
demonstrates that dynamic
compilation maintains the
language's semantics while
static compilation often
doesn't. Learn why this
matters and get a bit of
code to help you determine
whether your just-in-time
(JIT) compiler can transform
tail recursion on code while
preserving semantics.
Date: Jun, 02 2001 |