Browse Source

* properly calculate the value to add to esp at the end of a function
without framepointer
* use generic save/restore exception reason code for use_fixed_stack

git-svn-id: trunk@2846 -

Jonas Maebe 19 years ago
parent
commit
41eba7dffe
1 changed files with 14 additions and 3 deletions
  1. 14 3
      compiler/i386/cgcpu.pas

+ 14 - 3
compiler/i386/cgcpu.pas

@@ -260,6 +260,8 @@ unit cgcpu;
             if (current_procinfo.framepointer=NR_STACK_POINTER_REG) then
             if (current_procinfo.framepointer=NR_STACK_POINTER_REG) then
               begin
               begin
                 stacksize:=current_procinfo.calc_stackframe_size;
                 stacksize:=current_procinfo.calc_stackframe_size;
+                if (target_info.system = system_i386_darwin) then
+                  stacksize := align(stacksize+sizeof(aint),16) - sizeof(aint);
                 if (stacksize<>0) then
                 if (stacksize<>0) then
                   cg.a_op_const_reg(list,OP_ADD,OS_ADDR,stacksize,current_procinfo.framepointer);
                   cg.a_op_const_reg(list,OP_ADD,OS_ADDR,stacksize,current_procinfo.framepointer);
               end
               end
@@ -431,19 +433,28 @@ unit cgcpu;
 
 
     procedure tcg386.g_exception_reason_save(list : taasmoutput; const href : treference);
     procedure tcg386.g_exception_reason_save(list : taasmoutput; const href : treference);
       begin
       begin
-        list.concat(Taicpu.op_reg(A_PUSH,tcgsize2opsize[OS_INT],NR_FUNCTION_RESULT_REG));
+        if not use_fixed_stack then
+          list.concat(Taicpu.op_reg(A_PUSH,tcgsize2opsize[OS_INT],NR_FUNCTION_RESULT_REG))
+        else
+         inherited g_exception_reason_save(list,href);
       end;
       end;
 
 
 
 
     procedure tcg386.g_exception_reason_save_const(list : taasmoutput;const href : treference; a: aint);
     procedure tcg386.g_exception_reason_save_const(list : taasmoutput;const href : treference; a: aint);
       begin
       begin
-        list.concat(Taicpu.op_const(A_PUSH,tcgsize2opsize[OS_INT],a));
+        if not use_fixed_stack then
+          list.concat(Taicpu.op_const(A_PUSH,tcgsize2opsize[OS_INT],a))
+        else
+          inherited g_exception_reason_save_const(list,href,a);
       end;
       end;
 
 
 
 
     procedure tcg386.g_exception_reason_load(list : taasmoutput; const href : treference);
     procedure tcg386.g_exception_reason_load(list : taasmoutput; const href : treference);
       begin
       begin
-        list.concat(Taicpu.op_reg(A_POP,tcgsize2opsize[OS_INT],NR_FUNCTION_RESULT_REG));
+        if not use_fixed_stack then
+          list.concat(Taicpu.op_reg(A_POP,tcgsize2opsize[OS_INT],NR_FUNCTION_RESULT_REG))
+        else
+          inherited g_exception_reason_load(list,href);
       end;
       end;