简体   繁体   中英

What is .noframe in delphi 64-bit assembly?

What is .noframe in delphi 64-bit assembly?

I have seen x64 assembly code like this.

procedure test;
{$IFDEF CPUX64}
asm
  .noframe
..
..

What is the meaning of .noframe and why should I care?

From the documentation :

Forcibly disables the generation of a stack frame as long as there are no local variables declared and the parameter count <= 4. Use only for leaf functions.

A leaf function is one that does not call another function. That is one that is always at the bottom of the call tree.

From http://blogs.embarcadero.com/abauer/2011/10/10/38940

.NOFRAME

Some functions never make calls to other functions. These are called “leaf” functions because the don't do any further “branching” out to other functions, so like a tree, they represent the “leaf” For functions such as this, having a full stack frame may be extra overhead you want eliminate. While the compiler does try and eliminate the stack frame if it can, there are times that it simply cannot automatically figure this out. If you are certain a frame is unnecessary, you can use this directive as a hint to the compiler.

As far as I know the correct answer wouldn't imply the “leaf function” condition. You can use the .noframe when you are sure that

  1. the parameter count is ≤ 4, as stated above;
  2. you don't need to create a frame for local variables,
  3. the (1), (2) and (3) are also true for all the functions you want to call from this routine.

If the “leaf function” statement was true it would mean that you wouldn't use the stack at all in such functions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM