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
dev:crosscompiler:interfaces [2019/07/11 19:20] – [Methods] ursgrafdev:crosscompiler:interfaces [2019/07/11 19:34] (current) – [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]]. Before calling the //delegate// method, the compiler puts the information about the specific interface the method belongs to together with the method index into a scratch register. For this purpose all interfaces are given a unique id. To give an example. The scratch register contains 0x00020003 -> the interface has id=2 and the method no. 3 within this interface is called. 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]]. Before calling the //delegate// method, the compiler puts the information about the specific interface the method belongs to together with the method index into a scratch register. For this purpose all interfaces are given a unique id. To give an example. The scratch register contains 0x00020003 -> the interface has id=2 and the method no. 3 within this interface is called.
- +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 the offset into the method table. The offset is taken from the field //size//. With the first 16 bit given in the scratch register, the correct interface is searched. With the second half of the register you get the offset to the method table for this specific interface. Together with the method index from the scratch register the desired method can finally be found.\\
-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. For practical implementation see notes in the code generator for the desired architecture, [[dev:crosscompiler:backend:start|Backend]]. 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]].
  
dev/crosscompiler/interfaces.txt · Last modified: 2019/07/11 19:34 by ursgraf