[fpc-devel]default calling convention change for i386
Ingmar Tulva
juss_it at ut.ee
Fri Dec 26 14:16:53 CET 2003
On Wed, 24 Dec 2003, Peter Vreman wrote:
}Most important was compatibility, second is speed. In the drystone test
}there was a performance gain of at least 10%.
Okay, I think this answers the question :)
}> Register convention saves opcode space in the called function, because
}> within
}> the instruction opcode, registers are encoded with small bit fields,
}> whereas
}> offsets into a stack frame are encoded as (8-, 16-, or 32-bit) words,
}> unless
}> the processor supports something like short offsets. Actually, I don't
}> know
}> if the i386 does support such short offsets. AFAIK, the 68000 does not.
}
}Sorry, this is not correct. The code size is increased with register
}calling. The reason is that in the called routines the passed registers
}need to be saved in the local stackframe. When we have register variables
}support (currently not working for 1.9.x) this can be reduced.
This is exactly what makes me doubt in the benefits of register calling.
Because of the small number of registers to spare, the whole process of
calling and executing a subroutine looks like this to me:
1. Calculate values of parameters and push them into stack, one by one.
2. Pop the values into appropriate registers (omitted when not using
register convention)
3. Call the subroutine.
4. Push parameters into stack (omitted when not using register convention)
5. Access parameters in stack as they are needed.
Well, this is just an oversimplified theory. As Peter noted, the practice
might be somewhat more pleasant :)
------
Ingmar
------
"Experience is what you get when you don't get what you want"
More information about the fpc-devel
mailing list