Page 1 of 1

Procedure Overhead

Posted: Tue May 09, 2006 12:41 am
by Dreglor
why is there so much overhead with procedure calls is there something that pb does that just kills speed?

Procedure calls are speedy by them selfs but add them up in a for/while loop and they bring your program to a halt...

Re: Procedure Overhead

Posted: Tue May 09, 2006 9:19 am
by traumatic
Could you please explain what you mean by "overhead" and "brings program to halt" ?

Code: Select all

Procedure doSomething(var.l)
  ProcedureReturn var.l*2
EndProcedure

For i=0 To 99
  doSomething(i)
Next
compiles to

Code: Select all

_Procedure0:
  PUSH   ebx
  MOV    ebx,dword [esp+8]
  ADD    ebx,ebx
  MOV    eax,ebx
  JMP   _EndProcedure1
  XOR    eax,eax
_EndProcedure1:
  POP    ebx
  RET    4


  MOV    dword [v_i],0
_For1:
  MOV    eax,99
  CMP    eax,dword [v_i]
  JL    _Next2

  PUSH   dword [v_i]
  CALL  _Procedure0

_NextContinue2:
  INC    dword [v_i]
  JMP   _For1
_Next2:
Can't see much overhead there.

Do you have any specific examples in which ASM generation fails or something?

Posted: Tue May 09, 2006 11:20 am
by Fred
May be there is a memory leak in the procedure, which could fill the memory and halt the program ?