UASM icon indicating copy to clipboard operation
UASM copied to clipboard

Why is stack probe disabled?

Open vid512 opened this issue 6 years ago • 1 comments

From https://github.com/Terraspace/UASM/blob/master/procJWasm.c:

/* STACKPROBE: emit a conditional "call __chkstk" inside the prologue

  • if stack space that is to be allocated exceeds 1000h bytes.
  • this is currently implemented for 64-bit only,
  • if OPTION FRAME:AUTO is set and the procedure has the FRAME attribute.
  • it's not active by default because, in a few cases, the listing might get messed. */ #define STACKPROBE 0
  1. Is there a more detailed info what gets wrong with listing, when stack probe enabled?

  2. When STACKPROBE is disabled, I think there should be an error if function declares more than 4KB of local variables.

  3. When enabled, the STACKPROBE feature uses the __chkstk from Microsoft's C runtime library:

#if STACKPROBE if ( info->localsize + resstack > 0x1000 ) { AddLineQueueX( *(ppfmt+2), T_RAX, NUMQUAL info->localsize, sym_ReservedStack->name ); AddLineQueue( "externdef __chkstk:PROC" ); AddLineQueue( "call __chkstk" ); AddLineQueueX( "mov %r, %r", T_RSP, T_RAX ); } else #endif

Is it really necessary to make UASM code dependant on Microsoft C runtime? I think the feature could be implemented with custom code touching each page. That's just 1 extra instruction per page when there are few pages, or very small loop otherwise. UASM already has all the information needed to generate such code, probably with less runtime overhead than __chkstk involves.

vid512 avatar Apr 21 '19 13:04 vid512

It definitely should if re-implemented not use any external lib. I will look into this.

john-terraspace avatar Apr 25 '19 15:04 john-terraspace