Parcourir la source

* first load para's to temps before calling entry code (profile

peter il y a 21 ans
Parent
commit
1bcda5c022
2 fichiers modifiés avec 28 ajouts et 21 suppressions
  1. 11 7
      compiler/ncgutil.pas
  2. 17 14
      compiler/psub.pas

+ 11 - 7
compiler/ncgutil.pas

@@ -1265,12 +1265,13 @@ implementation
            not(po_assembler in current_procinfo.procdef.procoptions) then
           begin
             { non-win32 can call mcout even in main }
-            if not (target_info.system in [system_i386_win32,system_i386_wdosx])  then
-              cg.g_profilecode(list)
-            else
-            { wdosx, and win32 should not call mcount before monstartup has been called }
-            if not (current_procinfo.procdef.proctypeoption=potype_proginit) then
-              cg.g_profilecode(list);
+            if not (target_info.system in [system_i386_win32,system_i386_wdosx]) or
+               not (current_procinfo.procdef.proctypeoption=potype_proginit) then
+              begin
+                cg.allocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_cdecl));
+                cg.g_profilecode(list);
+                cg.deallocexplicitregisters(list,R_INTREGISTER,paramanager.get_volatile_registers_int(pocall_cdecl));
+              end;
           end;
 
         { call startup helpers from main program }
@@ -2133,7 +2134,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.202  2004-05-23 15:23:30  peter
+  Revision 1.203  2004-05-28 21:14:13  peter
+    * first load para's to temps before calling entry code (profile
+
+  Revision 1.202  2004/05/23 15:23:30  peter
     * fixed qword(longint) that removed sign from the number
     * removed code in the compiler that relied on wrong qword(longint)
       code generation

+ 17 - 14
compiler/psub.pas

@@ -570,8 +570,8 @@ implementation
             addstatement(codestatement,bodyexitcode);
             addstatement(codestatement,final_asmnode);
             { Initialize before try...finally...end frame }
-            addstatement(newstatement,entry_asmnode);
             addstatement(newstatement,loadpara_asmnode);
+            addstatement(newstatement,entry_asmnode);
             addstatement(newstatement,init_asmnode);
             addstatement(newstatement,bodyentrycode);
             aktfilepos:=entrypos;
@@ -585,8 +585,8 @@ implementation
           end
         else
           begin
-            addstatement(newstatement,entry_asmnode);
             addstatement(newstatement,loadpara_asmnode);
+            addstatement(newstatement,entry_asmnode);
             addstatement(newstatement,init_asmnode);
             addstatement(newstatement,bodyentrycode);
             addstatement(newstatement,code);
@@ -1001,7 +1001,6 @@ implementation
 
          { parse the code ... }
          code:=block(current_module.islibrary);
-
          { save exit info }
          exitswitches:=aktlocalswitches;
          exitpos:=last_endtoken_filepos;
@@ -1009,8 +1008,18 @@ implementation
          { the procedure is now defined }
          procdef.forwarddef:=false;
 
+         if assigned(code) then
+           begin
+             { get a better entry point }
+             entrypos:=code.fileinfo;
+
+             { Finish type checking pass }
+             do_resulttypepass(code);
+           end;
+
          { Check for unused labels, forwards, symbols for procedures. Static
-           symtable is checked in pmodules }
+           symtable is checked in pmodules.
+           The check must be done after the resulttypepass }
          if (Errorcount=0) and
             (tstoredsymtable(procdef.localst).symtabletype<>staticsymtable) then
            begin
@@ -1028,15 +1037,6 @@ implementation
                end;
            end;
 
-         if assigned(code) then
-           begin
-             { get a better entry point }
-             entrypos:=code.fileinfo;
-
-             { Finish type checking pass }
-             do_resulttypepass(code);
-           end;
-
          { store a copy of the original tree for inline, for
            normal procedures only store a reference to the
            current tree }
@@ -1389,7 +1389,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.193  2004-05-24 17:31:12  peter
+  Revision 1.194  2004-05-28 21:14:13  peter
+    * first load para's to temps before calling entry code (profile
+
+  Revision 1.193  2004/05/24 17:31:12  peter
     * also check local typed const
 
   Revision 1.192  2004/05/23 18:28:41  peter