Re: Function prologs emitted by VC++ compiler



Up to the compiler/optimizer's whims, pretty much. In general, if frame
pointer omission (FPO) optimizations are enabled then you are likely to not
see ebp being used as a frame pointer reliably.

In either case, there is no hard guarantee that ebp will be used as a frame
pointer as far as I know.

--
Ken Johnson (Skywing)
Windows SDK MVP

"Ranjit" <ranjitiyer@xxxxxxxxx> wrote in message
news:1155591942.849030.183720@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi All,

Firstly, my apologies for posting this question across 2 groups -
(comp.compilers and windows.kernel). I was'nt sure which was the
appropriate forum for this question.

My questions is about function prologs.

Under what circumstances would a compiler not generate the standard
prolog -
(push ebp, mov ebp,esp) for a function.

I observed this anomaly for quite of a few functions exported from
Win32 dlls - kernel32.dll, ntdll.dll, etc. One such example function is
InterlockedIncrement() where the prolog is optimized away and the
function body starts directly by reading its parameters using offsets
from the ESP.

When do compilers decide to do such prolog optimizations. I was under
the impression that all functions (not naked/inline) have to start with
the standard prolog instructions. Is that a wrong assumption to make?

Could someone share their thoughts on this.

Thanks,
Ranjit



.



Relevant Pages

  • Re: Problem with DosSetPathInfo in version 14.103b kernel
    ... You can't tell that from a register dump alone. ... Just because ebp contains a value slightly higher than esp is not a proof that it's a frame pointer. ... It's a term commonly used in compiler development, because compilers typically have considerable freedom as to how they can transform leaf functions. ...
    (comp.os.os2.bugs)
  • Re: [RFC PATCH 1/4] powerpc 2.6.16-rt17: to build on powerpc w/ RT
    ... current implementation is very optimized to avoid even memory barriers ... although do let me know if you see places where the generic code ... could use any of the optimizations used in powerpc. ... There is an array of 2 of these and a pointer to the ...
    (Linux-Kernel)
  • Re: Function prologs emitted by VC++ compiler
    ... function body starts directly by reading its parameters using offsets ... When do compilers decide to do such prolog optimizations. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Pointer equality and dereferencing
    ... result that is defined for the right pointer. ... that the programmer needs to worry about. ... some optimizations, but that's a QoI detail. ...
    (comp.std.c)
  • Re: Which Prolog implementation works with Microsoft .NET?
    ... > Any bi-directional interface between prolog and OOP Language has to ... How to call a method of the instance bounded to a prolog variable? ... When you create an extended predicate in Amzi! ... make sure that object pointer is properly maintained under .NET. ...
    (comp.lang.prolog)