[fpc-devel] estimating function code size
zilvinas.ledas at dict.lt
Wed Jan 18 14:17:38 CET 2012
On 2012-01-18 15:08, Gennadiy Poryev wrote:
>> Do you think it's granted that there is only one return in a function ?
>> Maybe optimization or "exit" could create additional returns
> Actually I do. Because I write this function :)
> It uses quite a lot of loops and ifs, but no exits.
> And what I need is a reliable way to get its code size at runtime without manually inspecting it on every rebuild.
I had similar problem a year and a half ago. I ended up looking for
"ret" using disassembler.
Regarding one ret per function, I got this response from Jonas at that time:
On 2010-07-18 15:42, Jonas Maebe wrote:
> On 18 Jul 2010, at 13:14, Žilvinas Ledas wrote:
>> I want to use it this way:
>> 1) Gel all @unitname.function addresses.
>> 2) Use disassembler to find nearest next RET.
>> 3) Then I assume that I have start and end of the function in the binary file.
>> It works at least for the concept-showing app with some functions and enabled optimizations when compiling. Do I have some conceptual flaw?
> Yes: there is no guarantee that a function will contain only one "ret" (it is that way currently for compiler-generated code, but that can change at any time).
More information about the fpc-devel