deep

a Cross Development Platform for Java

User Tools

Site Tools


dev:crosscompiler:type_descriptor

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
dev:crosscompiler:type_descriptor [2015/04/18 08:40] – [Type Descriptor] ursgrafdev:crosscompiler:type_descriptor [2019/07/11 19:12] (current) – [Structure] ursgraf
Line 1: Line 1:
 ====== Type Descriptor ====== ====== Type Descriptor ======
-Each class needs a type descriptor in the constant block of this class (see [[dev:crosscompiler:linker32|Linker32]]). This type descriptor will be needed to find instance methods or to do type checking. All arrays - even arrays with elements being of an interface type - need a type descriptor. Interfaces themselves need no type descriptor because there cannot be instances of interfaces. \\+Each class needs a type descriptor in the constant block of this class (see [[dev:crosscompiler:backend_ppc:linker32|Linker32]]). This type descriptor will be needed to find instance methods or to do type checking. All arrays - even arrays with elements being of an interface type - need a type descriptor. Interfaces themselves need no type descriptor because there cannot be instances of interfaces. \\
 However, there is one exeption to this. If an object, which is of type "array of interface type", is checked with instructions like //instanceof// or //checkcast//, then the type descriptor of the array must have an entry //componentTD// (see below). And this entry must be a type descriptor of an interface. For such cases even an interface needs a type descriptor. This type descriptor can be very small and most entries may be ommitted. When parsing the classes, affected interfaces are inserted in a special list. However, there is one exeption to this. If an object, which is of type "array of interface type", is checked with instructions like //instanceof// or //checkcast//, then the type descriptor of the array must have an entry //componentTD// (see below). And this entry must be a type descriptor of an interface. For such cases even an interface needs a type descriptor. This type descriptor can be very small and most entries may be ommitted. When parsing the classes, affected interfaces are inserted in a special list.
  
Line 6: Line 6:
 [{{ .:typedescriptoroverview.png?700&direct | //Type descriptor for arrays and classes//}}] [{{ .:typedescriptoroverview.png?700&direct | //Type descriptor for arrays and classes//}}]
  
-The fields //size// indicates the size (in Bytes) of an object of this type (without tag, see [[.:objects|Objects]]). For arrays the entry is //arrayComponentSize//, which is the size (in Bytes) of one array element. The name of the class could be used for reflection. \\+The fields //size// indicates the size (in bytes) of an object of this type (without tag, see [[.:objects|Objects]]). For arrays the entry is //arrayComponentSize//, which is the size (in bytes) of one array element. The name of the class could be used for reflection. \\
  
-The entry //extensionLevel// gives the number of superclasses. The method table is discussed below. The type table and interface type table is used for [[.:type_checking|Type Checking]]. The interface method table serves to find the right interface method, see [[.:interfaces|Interfaces]]. \\ +The entry //extensionLevel// gives the number of superclasses. The method table is discussed below. The type table (//baseClassTD[0]// up to //baseClassTD[extLevel]//and interface type table (//interface ChkId1//, ...) is used for [[.:type_checking|Type Checking]]. The interface method table together with the //interfaceDelegateMethod// and the entries with //interface0Id, interface0MethodOffset// serves to find the right interface method, see [[.:interfaces|Interfaces]]. \\ 
-The garbage collector has to know which instance fields are references. For this there is a field //instPtrOffset//. This field has a fixed offset within the type descriptor. From there you can reach a list with all reference fields (//nofInstPtr//, //instPtrOffset[0]//, ... ). \\ \\+The garbage collector has to know which instance fields are references. For this there is a field //instPtrOffset//. This field has a fixed offset within the type descriptor. From there you can reach a list with all reference fields (//nofInstPtr//, //instPtrOffset[0]//, ... ). \\ 
  
-Type descriptors for arrays are solely used for type checking. They contain the references to all type descritors of the lower dimensional arrays of the same base type. If necessary, these lower dimensional types must be created by the class file reader. The field //arrayDimension// gives the number of dimension of this array. The bit //P// (primitive) indicates whether this is an array of base types, such as //byte//, //short//, ... (P = 1) or if its an array of regular classes (P = 0). For arrays of base types the value of //componentTD// is set to 0. The P-bit is also set in the higher dimensional type descriptors, e.g. in %%[S, [[S and [[[S%%. \\ \\+Type descriptors for arrays are solely used for type checking. They contain the references to all type descritors of the lower dimensional arrays of the same base type. If necessary, these lower dimensional types must be created by the class file reader. The field //arrayDimension// gives the number of dimension of this array. The bit //P// (primitive) indicates whether this is an array of base types, such as //byte//, //short//, ... (P = 1) or if its an array of regular classes (P = 0). For arrays of base types the value of //componentTD// is set to 0. The P-bit is also set in the higher dimensional type descriptors, e.g. in %%[S, [[S and [[[S%%. \\ 
  
 The reduced type descriptor for interfaces comprises the fields from //size// to //intfTypeChkOffset// and the interface table. The type table with the base classes can be omitted. Important: the table with the interface id's must include the own id! The reduced type descriptor for interfaces comprises the fields from //size// to //intfTypeChkOffset// and the interface table. The type table with the base classes can be omitted. Important: the table with the interface id's must include the own id!
dev/crosscompiler/type_descriptor.1429339208.txt.gz · Last modified: 2016/02/25 13:33 (external edit)