Răsfoiți Sursa

* keep stack aligned to 16 byte borders on winx64

git-svn-id: trunk@3212 -
florian 19 ani în urmă
părinte
comite
2d3d4a66f6
3 a modificat fișierele cu 17 adăugiri și 4 ștergeri
  1. 2 2
      compiler/x86/cgx86.pas
  2. 7 0
      compiler/x86_64/cgcpu.pas
  3. 8 2
      compiler/x86_64/cpupara.pas

+ 2 - 2
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

+ 7 - 0
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

+ 8 - 2
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);