deep

a Cross Development Platform for Java

User Tools

Site Tools


dev:crosscompiler:interfaces

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
dev:crosscompiler:interfaces [2019/07/09 14:25] – [Methods] ursgrafdev:crosscompiler:interfaces [2019/07/09 14:34] – [Methods] ursgraf
Line 73: Line 73:
 === Case 2 === === Case 2 ===
 If a class implements one interface with several methods or several interfaces -> in the type descriptor we place the address of a //delegate// method at the index //interfaceDelegateMethod//. This method is a [[.:backend_ppc:code_generator#compiler_specific_subroutines|Compiler Specific Subroutine]]. The //delegate// method fetches the proper interface from the interface table (adjacent to the delegate method in the type descriptor). Each interface has an entry with 32 bit. The first 16 bit are reserved for the //id//, whereas the next 16 bit contain an offset into the method table. The offset is taken from the field //size//. With this offset the address of the desired method can finally be found.\\ If a class implements one interface with several methods or several interfaces -> in the type descriptor we place the address of a //delegate// method at the index //interfaceDelegateMethod//. This method is a [[.:backend_ppc:code_generator#compiler_specific_subroutines|Compiler Specific Subroutine]]. The //delegate// method fetches the proper interface from the interface table (adjacent to the delegate method in the type descriptor). Each interface has an entry with 32 bit. The first 16 bit are reserved for the //id//, whereas the next 16 bit contain an offset into the method table. The offset is taken from the field //size//. With this offset the address of the desired method can finally be found.\\
-Important: For jumping into the interface method the LR cannot be used anymore, because the LR contains the address of the caller and the LR was not saved so far. This happens only at the start of the interface method. +Important: For jumping into the interface method the LR cannot be used anymore, because the LR contains the address of the caller and the LR was not saved so far. This happens only at the start of the interface method. For practical implementation see notes in the code generator for the desired architecture[[dev:crosscompiler:backend:start|Backend]].
- +
-==== Practical Implementation ==== +
-Case 2 needs 3 auxiliary registers. At compile time we cannot reserve such auxiliary registers as these registers must always be the same. Therefore, we use parameter registers. They are volatile and can be freely used though this means, that interface methods can pass less parameters, which is generally true. If not true, the compiler will report.\\ +
-R0 holds the necessary information for the delegate method. The first two bytes are the ID of the sought-after interfacetho last to bytes contain the method offset. Loading of R0 should happen after parameter copying as R0 is used then+
  
 ==== Special Case ==== ==== Special Case ====
dev/crosscompiler/interfaces.txt · Last modified: 2019/07/11 19:34 by ursgraf