Java Reference
In-Depth Information
code generation in Chapter 11 before proceeding to lower-level code genera-
tion in Chapter 13. This allows us to focus on the code-generation process in
Chapter 11 without having to explain or understand the details of a machine's
instruction set. For example, the Java Virtual Machine (JVM) contains an
instruction (invokevirtual) that performs a virtual method call. This single
instruction simplifies the discussion of code-generation strategies in Chap-
ter 11. At a lower level, many instructions must be generated to accomplish
the call and its return, as described in Section 13.1.3 on page 496.
The comparatively high level of the instructions found in intermediate
representations assumes also that a fair amount of runtime support is present
in the virtual machine that interprets the intermediate representation. Contin-
uing with the example of a virtual method invocation, runtime support must
be present for managing the storage that can be accessed by the method. The
details of providing such support are covered in Chapter 12.
Intermediate representations have many advantages, and most compilers
use one or more levels of intermediate representation before generating their
ultimate target code. Section 10.1 considers the rationale of using intermediate
representations. Section 10.2 presents an overviewof the Java Virtual Machine,
which is used extensively in Chapter 11, as an example of intermediate code
generation. Section 10.3 presents static single assignment form as an intermediate
representation with properties conducive to program optimization.
Studying these and other IRs o
ers insight into programming language
design as well as preparation for code generation.
ff
10.1 Overview
Most applications are written in relatively high-level source languages such
as C
er extensible data and control abstractions
that are conducive to algorithmic expression. However, most computers lack
any native comprehension of such high-level languages. They rely instead
on compilers to translate source programs into some target machine language,
the instructions of which typically operate on a dramatically reduced scale.
Compilers and other programming language translation tools bridge the se-
mantic gap between high- and low-level program representations. That gap
is typically traversed as a sequence of steps, each involving an intermediate
representation.
For example, a compiler might accept Java programs as input and ulti-
mately produce machine instructions for an Intel R
++
or Java. Such languages o
ff
architecture. Interposed
between the original source and ultimate target, a class file might be generated
according to the specification of the JVM. Other intermediate representations
may be produced as well, both before and after the class file is generated.
 
 
Search WWH ::




Custom Search