Просмотр исходного кода

* fixed calling cdecl functions which return a large record with
use_fixed_stack on i386

git-svn-id: trunk@2872 -

Jonas Maebe 19 лет назад
Родитель
Сommit
5f0f08dd18
2 измененных файлов с 12 добавлено и 3 удалено
  1. 11 1
      compiler/i386/n386cal.pas
  2. 1 2
      compiler/ncgutil.pas

+ 11 - 1
compiler/i386/n386cal.pas

@@ -70,7 +70,17 @@ implementation
         hreg : tregister;
       begin
         if (use_fixed_stack) then
-          exit;
+          begin
+            { very weird: in this case the callee does a "ret $4" and the }
+            { caller immediately a "subl $4,%esp". Possibly this is for   }
+            { use_fixed_stack code to be able to transparently call       }
+            { old-style code (JM)                                         }
+            dec(pop_size,pushedparasize);
+            if (pop_size < 0) then
+              exprasmlist.concat(taicpu.op_const_reg(A_SUB,S_L,-pop_size,NR_ESP));
+            exit;
+          end;
+
         { better than an add on all processors }
         if pop_size=4 then
           begin

+ 1 - 2
compiler/ncgutil.pas

@@ -1845,8 +1845,7 @@ implementation
         if current_procinfo.procdef.proccalloption in clearstack_pocalls then
           begin
             parasize:=0;
-            if not(use_fixed_stack) and
-               paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
+            if paramanager.ret_in_param(current_procinfo.procdef.rettype.def,current_procinfo.procdef.proccalloption) then
               inc(parasize,sizeof(aint));
           end
         else