Java Reference
In-Depth Information
thereby allowing illegal operations to be detected even when source files are
not available. Other tools such as Electric Fence [Piz99] can detect dynamic
storage problems such as bu
ff
er overruns and improperly deallocated storage.
1.8.2 Optimizing Compilers
An optimizing compiler is specially designed to produce e
cient target code
at the cost of increased compiler complexity and possibly increased compila-
tion times. In practice, all production-quality compilers (those whose output
will be used in everyday work) make some e
ort to generate reasonable target
code. For example, no add instruction would normally be generated for the
expression i+0.
The term optimizing compiler is actually a misnomer. This is because no
compiler of any sophistication can produce optimal code for all programs. The
reason for this is twofold. First, theoretical computer science has shown that
even so simple a question as whether two programs are equivalent is undecid-
able : such questions cannot generally be answered by any computer program.
Thus finding the simplest (and most e
ff
cient) translation of a program cannot
always be done. Second, many program optimizations require time propor-
tional to an exponential function of the size of the program being compiled.
Thus, optimal code, even when theoretically possible, is often infeasible in
practice.
Optimizing compilers actually use a wide variety of transformations that
improve a program's performance. The complexity of an optimizing compiler
arises from the need to employ a variety of transforms, some of which interfere
with each other. For example, keeping frequently used variables in registers
reduces their access time but makes procedure and function calls more expen-
sive. This is because registers need to be saved across calls. Many optimizing
compilers provide a number of levels of optimization, each providing increas-
ingly greater code improvements at increasingly greater costs. The choice
of which improvements are most e
ective (and least expensive) is a matter
of judgment and experience. Chapter 13 discusses some optimizations that
are specific to code generation, such as register allocation. Chapter 14 cov-
ers the theory of optimizing compilers in greater detail, including data flow
frameworks and static single-assignment form . Further discussion of a com-
prehensive optimizing compiler is beyond the scope of this topic. However,
compilers that produce high-quality code at reasonable cost are an achievable
goal.
ff
1.8.3 Retargetable Compilers
Compilers are designed for a particular programming language (the source
language) and a particular target computer (the computer for which it will
 
 
 
Search WWH ::




Custom Search