Java Reference
In-Depth Information
FIGURE 6.13 A stack frame.
FIGURE 6.14 Layout for an object.
The type tag identifies the type (that is, the class) of the object. The size in bytes is the
number of bytes that must be allocated to represent the object; this number is rounded up
to a multiple of 4 so that objects begin on word boundaries. The dispatch table pointer is
the address of a dispatch table, which contains the address of each method for the object's
class.
The dispatch table may be allocated in the data segment and keeps track of both in-
herited and defined methods. When code is generated for the class, entries in the table are
first copied from the superclass. Then entries for newly defined method are added; over-
riding method entries replace the overridden entries in the table and other method entries
are simply added at the end. Entries are added in the order they are declared in the class
declaration. In this way, the dispatch table for a class keeps track of the proper (inherited,
overriding, or newly defined) methods that are applicable to each class. A dispatch table
for class <class> may be labeled (and addressed) in the data segment using the name
 
Search WWH ::




Custom Search