From 2d3d4a66f69e14d0026f78b8f7f9a8c96e8e3fab Mon Sep 17 00:00:00 2001 From: florian Date: Sat, 15 Apr 2006 16:48:28 +0000 Subject: [PATCH] * keep stack aligned to 16 byte borders on winx64 git-svn-id: trunk@3212 - --- compiler/x86/cgx86.pas | 4 ++-- compiler/x86_64/cgcpu.pas | 7 +++++++ compiler/x86_64/cpupara.pas | 10 ++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/compiler/x86/cgx86.pas b/compiler/x86/cgx86.pas index 50b8785891..5af7fb0860 100644 --- a/compiler/x86/cgx86.pas +++ b/compiler/x86/cgx86.pas @@ -1833,12 +1833,12 @@ unit cgx86; { allocate stackframe space } if (localsize<>0) or - ((target_info.system = system_i386_darwin) and + ((target_info.system in [system_i386_darwin,system_x86_64_win64]) and (stackmisalignment <> 0) and ((pi_do_call in current_procinfo.flags) or (po_assembler in current_procinfo.procdef.procoptions))) then begin - if (target_info.system = system_i386_darwin) then + if (target_info.system in [system_i386_darwin,system_x86_64_win64]) then localsize := align(localsize+stackmisalignment,16)-stackmisalignment; cg.g_stackpointer_alloc(list,localsize); if current_procinfo.framepointer=NR_STACK_POINTER_REG then diff --git a/compiler/x86_64/cgcpu.pas b/compiler/x86_64/cgcpu.pas index 17f21d1215..0e27e0d4a5 100644 --- a/compiler/x86_64/cgcpu.pas +++ b/compiler/x86_64/cgcpu.pas @@ -73,6 +73,13 @@ unit cgcpu; if (current_procinfo.framepointer=NR_STACK_POINTER_REG) then begin stacksize:=current_procinfo.calc_stackframe_size; + if (target_info.system = system_x86_64_win64) and + ((stacksize <> 0) or + (pi_do_call in current_procinfo.flags) or + { can't detect if a call in this case -> use nostackframe } + { if you (think you) know what you are doing } + (po_assembler in current_procinfo.procdef.procoptions)) then + stacksize := align(stacksize+sizeof(aint),16) - sizeof(aint); if (stacksize<>0) then cg.a_op_const_reg(list,OP_ADD,OS_ADDR,stacksize,current_procinfo.framepointer); end diff --git a/compiler/x86_64/cpupara.pas b/compiler/x86_64/cpupara.pas index 4a5f146aff..46aa5861ed 100644 --- a/compiler/x86_64/cpupara.pas +++ b/compiler/x86_64/cpupara.pas @@ -495,7 +495,10 @@ unit cpupara; begin intparareg:=0; mmparareg:=0; - parasize:=0; + if target_info.system=system_x86_64_win64 then + parasize:=4*8 + else + parasize:=0; { calculate the registers for the normal parameters } create_paraloc_info_intern(p,callerside,p.paras,intparareg,mmparareg,parasize); { append the varargs } @@ -513,7 +516,10 @@ unit cpupara; begin intparareg:=0; mmparareg:=0; - parasize:=0; + if target_info.system=system_x86_64_win64 then + parasize:=4*8 + else + parasize:=0; create_paraloc_info_intern(p,side,p.paras,intparareg,mmparareg,parasize); { Create Function result paraloc } create_funcretloc_info(p,side);