Menu

#24 Flags-preserving stack-cleanup

open
nobody
None
5
2011-03-04
2011-03-04
No

Hi Japheth,

I am using a slightly modified JWASM, which means that I cannot use or test new versions of JWASM before they are final (since you don't release the source code for betas or RCs).

I have a very large codebase (both 32-bit and 64-bit) that I compile with JWASM, so it would benefit the both of us if I could test RCs (especially when there are 25 of them ;-)

Therefore I'd like to request either of two things:
A) You implement the modification I need as an option in JWASM.
or
B) You share the source code for betas and RCs with me.

The modification I need is that the epilogue and the caller stack-cleanup code in win64 fastcall preserves the flags.
Normally, the epilogue and the caller stack-cleanup both includes an ADD RSP,X... Use LEA instead, and all is peachy.
(The epilogue I could possibly handle by using a custom epilogue, but not the stack-cleanup - so I have to modify JWASM).

Kind Regards,
Terry

Discussion

  • japheth

    japheth - 2011-03-05

    > A) You implement the modification I need as an option in JWASM.

    Is LEA "allowed" according to the Win64 ABI? I vaguely remember some rather strict commandments concerning the acceptable formats of function epilogues.

    > B) You share the source code for betas and RCs with me.

    Given my laziness, this most likely won't work and will end in frustration and disaster.

     
  • Terry Philips

    Terry Philips - 2011-03-05

    Well no, lea isn't allowed according to the documentation. IIRC there are only two allowed epilogues according to the documentation. However, I've been using my lea-epilogue in production code for half a year without any issues.

    Then again, I'm not sure if exception handling might get screwed up because of the non-conforming epilogue...

    Regarding B), I perfectly understand, I'd give the same reply to such a request :-)

     
  • Terry Philips

    Terry Philips - 2011-03-06

    oh... I remembered incorrectly. lea is allowed:

    http://msdn.microsoft.com/en-us/library/tawsa7cb.aspx

    This is the change I've made in write_win64_default_epilogue:

    // AddLineQueueX( "add %r, %d", stackreg[ModuleInfo.Ofssize], NUMQUAL info->localsize + sizexmm );
    uint_16 sizestack = 0;
    if (CurrProc->e.procinfo->regslist != NULL) sizestack = *CurrProc->e.procinfo->regslist*8;
    AddLineQueueX( "lea %r, [%r-%d]", stackreg[ModuleInfo.Ofssize], basereg[ModuleInfo.Ofssize], sizestack );

    Seems I did actually read the documentation properly when I made that change, and just forgot about it :-)

     

Log in to post a comment.