Forráskód Böngészése

* stackpointer_alloc added for adjusting ESP. Win32 needs
this for the pageprotection

peter 22 éve
szülő
commit
af98b48c22
4 módosított fájl, 66 hozzáadás és 20 törlés
  1. 10 1
      compiler/cgobj.pas
  2. 30 7
      compiler/i386/cpupara.pas
  3. 10 8
      compiler/ncgutil.pas
  4. 16 4
      compiler/x86/cgx86.pas

+ 10 - 1
compiler/cgobj.pas

@@ -375,6 +375,11 @@ unit cgobj;
              behavior does nothing, should be overriden as required.
           }
           procedure g_profilecode(list : taasmoutput);virtual;
+          {# Emits instruction for allocating @var(size) bytes at the stackpointer
+
+             @param(size Number of bytes to allocate)
+          }
+          procedure g_stackpointer_alloc(list : taasmoutput;size : longint);virtual; abstract;
           {# Emits instruction for allocating the locals in entry
              code of a routine. This is one of the first
              routine called in @var(genentrycode).
@@ -1620,7 +1625,11 @@ finalization
 end.
 {
   $Log$
-  Revision 1.68  2002-12-20 18:14:04  peter
+  Revision 1.69  2002-12-24 15:56:50  peter
+    * stackpointer_alloc added for adjusting ESP. Win32 needs
+      this for the pageprotection
+
+  Revision 1.68  2002/12/20 18:14:04  peter
     * removed some runerror and writeln
 
   Revision 1.67  2002/12/14 15:02:03  carl

+ 30 - 7
compiler/i386/cpupara.pas

@@ -79,12 +79,31 @@ unit cpupara;
 
     function ti386paramanager.push_addr_param(def : tdef;calloption : tproccalloption) : boolean;
       begin
-        if ((target_info.system=system_i386_win32) and
-            (calloption=pocall_stdcall) and
-            (def.deftype=recorddef) and (def.size<=8)) then
-         result:=false
-        else
-         result:=inherited push_addr_param(def,calloption);
+        case target_info.system of
+          system_i386_win32 :
+            begin
+              case def.deftype of
+                recorddef :
+                  begin
+                    if (calloption=pocall_stdcall) and (def.size<=8) then
+                     begin  
+                       result:=false;
+                       exit;
+                     end;  
+                  end;
+                arraydef :
+                  begin
+                    if (tarraydef(def).highrange>=tarraydef(def).lowrange) and
+                       (calloption in [pocall_cdecl,pocall_cppdecl]) then
+                     begin  
+                       result:=false;
+                       exit;
+                     end;  
+                  end;     
+              end;    
+            end;
+        end;   
+        result:=inherited push_addr_param(def,calloption);
       end;
 
     function ti386paramanager.getintparaloc(nr : longint) : tparalocation;
@@ -111,7 +130,11 @@ begin
 end.
 {
   $Log$
-  Revision 1.6  2002-12-17 22:19:33  peter
+  Revision 1.7  2002-12-24 15:56:50  peter
+    * stackpointer_alloc added for adjusting ESP. Win32 needs
+      this for the pageprotection
+
+  Revision 1.6  2002/12/17 22:19:33  peter
     * fixed pushing of records>8 bytes with stdcall
     * simplified hightree loading
 

+ 10 - 8
compiler/ncgutil.pas

@@ -719,7 +719,7 @@ implementation
                   size:=align(tfloatdef(p.resulttype.def).size,alignment);
                   inc(pushedparasize,size);
                   if calloption<>pocall_inline then
-                   cg.a_op_const_reg(exprasmlist,OP_SUB,size,STACK_POINTER_REG);
+                   cg.g_stackpointer_alloc(exprasmlist,size);
 {$ifdef GDB}
                   if (cs_debuginfo in aktmoduleswitches) and
                      (exprasmList.first=exprasmList.last) then
@@ -781,7 +781,7 @@ implementation
               { push on stack }
               size:=align(p.resulttype.def.size,alignment);
               inc(pushedparasize,size);
-              cg.a_op_const_reg(exprasmlist,OP_SUB,size,STACK_POINTER_REG);
+              cg.g_stackpointer_alloc(exprasmlist,size);
               reference_reset_base(href,STACK_POINTER_REG,0);
               cg.g_concatcopy(exprasmlist,p.location.reference,href,size,false,false);
             end
@@ -1338,8 +1338,7 @@ function returns in a register and the caller receives it in an other one}
         inittempvariables(list);
 
         { generate copies of call by value parameters }
-        if not(po_assembler in aktprocdef.procoptions) and
-           not(aktprocdef.proccalloption in [pocall_cdecl,pocall_cppdecl,pocall_palmossyscall,pocall_system]) then
+        if not(po_assembler in aktprocdef.procoptions) then
           aktprocdef.parast.foreach_static({$ifndef TP}@{$endif}copyvalueparas,list);
 
         if assigned(aktprocdef.parast) then
@@ -1494,7 +1493,7 @@ function returns in a register and the caller receives it in an other one}
               else
                 parasize:=aktprocdef.parast.datasize+procinfo.para_offset-4;
               if stackframe<>0 then
-                cg.a_op_const_reg(stackalloclist,OP_SUB,stackframe,procinfo.framepointer);
+                cg.g_stackpointer_alloc(stackalloclist,stackframe);
             end
            else
 {$endif powerpc}
@@ -1720,8 +1719,7 @@ function returns in a register and the caller receives it in an other one}
           registers saved on the stack }
         if ((po_saveregisters in aktprocdef.procoptions) or
             (po_savestdregs in aktprocdef.procoptions)) and
-           not(po_assembler in aktprocdef.procoptions) and
-           not(aktprocdef.proccalloption in [pocall_cdecl,pocall_cppdecl,pocall_palmossyscall,pocall_system]) then
+           not(po_assembler in aktprocdef.procoptions) then
           aktprocdef.parast.foreach_static({$ifndef TP}@{$endif}removevalueparas,list);
 
         { for the save all registers we can simply use a pusha,popa which
@@ -1902,7 +1900,11 @@ function returns in a register and the caller receives it in an other one}
 end.
 {
   $Log$
-  Revision 1.70  2002-12-05 14:39:21  florian
+  Revision 1.71  2002-12-24 15:56:50  peter
+    * stackpointer_alloc added for adjusting ESP. Win32 needs
+      this for the pageprotection
+
+  Revision 1.70  2002/12/05 14:39:21  florian
     * added missing then, Carl did you really a make fullcycle :) ?
 
   Revision 1.69  2002/12/03 22:13:39  carl

+ 16 - 4
compiler/x86/cgx86.pas

@@ -111,6 +111,7 @@ unit cgx86;
         procedure g_interrupt_stackframe_entry(list : taasmoutput);override;
         procedure g_interrupt_stackframe_exit(list : taasmoutput;selfused,accused,acchiused:boolean);override;
         procedure g_profilecode(list : taasmoutput);override;
+        procedure g_stackpointer_alloc(list : taasmoutput;localsize : longint);override;
         procedure g_stackframe_entry(list : taasmoutput;localsize : longint);override;
         procedure g_restore_frame_pointer(list : taasmoutput);override;
         procedure g_return_from_proc(list : taasmoutput;parasize : aword);override;
@@ -1440,14 +1441,12 @@ unit cgx86;
       end;
 
 
-    procedure tcgx86.g_stackframe_entry(list : taasmoutput;localsize : longint);
+    procedure tcgx86.g_stackpointer_alloc(list : taasmoutput;localsize : longint);
       var
         href : treference;
         i : integer;
         again : tasmlabel;
       begin
-        list.concat(Taicpu.Op_reg(A_PUSH,S_L,R_EBP));
-        list.concat(Taicpu.Op_reg_reg(A_MOV,S_L,R_ESP,R_EBP));
         if localsize>0 then
          begin
 {$ifndef NOTARGETWIN32}
@@ -1487,6 +1486,15 @@ unit cgx86;
       end;
 
 
+    procedure tcgx86.g_stackframe_entry(list : taasmoutput;localsize : longint);
+      begin
+        list.concat(Taicpu.Op_reg(A_PUSH,S_L,R_EBP));
+        list.concat(Taicpu.Op_reg_reg(A_MOV,S_L,R_ESP,R_EBP));
+        if localsize>0 then
+          g_stackpointer_alloc(list,localsize);
+      end;
+
+
     procedure tcgx86.g_restore_frame_pointer(list : taasmoutput);
       begin
         list.concat(Taicpu.Op_none(A_LEAVE,S_NO));
@@ -1672,7 +1680,11 @@ unit cgx86;
 end.
 {
   $Log$
-  Revision 1.23  2002-11-25 18:43:34  carl
+  Revision 1.24  2002-12-24 15:56:50  peter
+    * stackpointer_alloc added for adjusting ESP. Win32 needs
+      this for the pageprotection
+
+  Revision 1.23  2002/11/25 18:43:34  carl
    - removed the invalid if <> checking (Delphi is strange on this)
    + implemented abstract warning on instance creation of class with
       abstract methods.