From af4d5c898ad4da03dfebe9ae229eef4bb409df4f Mon Sep 17 00:00:00 2001 From: florian Date: Mon, 17 Apr 2006 19:00:53 +0000 Subject: [PATCH] + stack touching for win64 git-svn-id: trunk@3252 - --- compiler/x86/cgx86.pas | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/compiler/x86/cgx86.pas b/compiler/x86/cgx86.pas index 5af7fb0860..9efc36526a 100644 --- a/compiler/x86/cgx86.pas +++ b/compiler/x86/cgx86.pas @@ -1732,14 +1732,14 @@ unit cgx86; procedure tcgx86.g_stackpointer_alloc(list : TAsmList;localsize : longint); -{$ifdef i386} +{$ifdef x86} {$ifndef NOTARGETWIN} var href : treference; i : integer; again : tasmlabel; {$endif NOTARGETWIN} -{$endif i386} +{$endif x86} begin if localsize>0 then begin @@ -1780,6 +1780,42 @@ unit cgx86; else {$endif NOTARGETWIN} {$endif i386} +{$ifdef x86_64} +{$ifndef NOTARGETWIN} + { windows guards only a few pages for stack growing, } + { so we have to access every page first } + if (target_info.system=system_x86_64_win64) and + (localsize>=winstackpagesize) then + begin + if localsize div winstackpagesize<=5 then + begin + list.concat(Taicpu.Op_const_reg(A_SUB,S_Q,localsize,NR_RSP)); + for i:=1 to localsize div winstackpagesize do + begin + reference_reset_base(href,NR_RSP,localsize-i*winstackpagesize+4); + list.concat(Taicpu.op_reg_ref(A_MOV,S_L,NR_EAX,href)); + end; + reference_reset_base(href,NR_RSP,0); + list.concat(Taicpu.op_reg_ref(A_MOV,S_L,NR_EAX,href)); + end + else + begin + current_asmdata.getjumplabel(again); + getcpuregister(list,NR_R10); + list.concat(Taicpu.op_const_reg(A_MOV,S_Q,localsize div winstackpagesize,NR_R10)); + a_label(list,again); + list.concat(Taicpu.op_const_reg(A_SUB,S_Q,winstackpagesize,NR_RSP)); + reference_reset_base(href,NR_RSP,0); + list.concat(Taicpu.op_reg_ref(A_MOV,S_L,NR_EAX,href)); + list.concat(Taicpu.op_reg(A_DEC,S_Q,NR_R10)); + a_jmp_cond(list,OC_NE,again); + list.concat(Taicpu.op_const_reg(A_SUB,S_Q,localsize mod winstackpagesize-4,NR_RSP)); + ungetcpuregister(list,NR_R10); + end + end + else +{$endif NOTARGETWIN} +{$endif x86_64} list.concat(Taicpu.Op_const_reg(A_SUB,tcgsize2opsize[OS_ADDR],localsize,NR_STACK_POINTER_REG)); end; end;