Java Reference
In-Depth Information
FIGURE 6.12 Resolving Phi functions.
6.3.5 Simple Run-Time Environment
Introduction
An actual run-time environment supporting code produced for Java would require:
1. A naming convention.
2. A run-time stack.
3. A representation for arrays and objects.
4. A heap, that is, an area of memory from which arrays and objects may be dynamically
allocated. The heap should offer some sort of garbage collection, making objects that
are no longer in use available for (re-)allocation.
5. A run-time library of code that supports the Java API.
To do all of this here would be beyond the scope of this text. Given that our goal is to have a
taste of native code generation, including register allocation, we do much less. We implement
just enough of the run-time environment for supporting our running the Factorial example
(and a few more examples, which are included in our code tree).
Naming Convention
We use a simple naming mechanism that takes account of just classes and their members.
Methods are represented in SPIM by routines with assembly language names of the form
<class>.<name> , where <name> names a method in a class <class> . For example, the
computeIter() method in class Factorial would have the entry point
Factorial.computeIter:
Static fields are similarly named; for example, a static integer field staticIntField in class
Factorial would translate to SPIM assembly language as
Factorial.staticIntField: .word 0
String literals in the data segment have labels that suggest what they label, for example,
Constant..String1: .
 
Search WWH ::




Custom Search