浏览代码

+ use 'push cs + call near' (which is both shorter and faster), instead of far
call, when calling a far proc in the same segment

git-svn-id: trunk@27621 -

nickysn 11 年之前
父节点
当前提交
70a7ecd0fa
共有 1 个文件被更改,包括 13 次插入2 次删除
  1. 13 2
      compiler/i8086/hlcgcpu.pas

+ 13 - 2
compiler/i8086/hlcgcpu.pas

@@ -88,7 +88,7 @@ implementation
     cpubase,cpuinfo,tgobj,cgobj,cgcpu,
     cpubase,cpuinfo,tgobj,cgobj,cgcpu,
     defutil,
     defutil,
     symconst,symcpu,
     symconst,symcpu,
-    procinfo,
+    procinfo,fmodule,
     aasmcpu;
     aasmcpu;
 
 
   { thlcgcpu }
   { thlcgcpu }
@@ -261,7 +261,18 @@ implementation
   function thlcgcpu.a_call_name(list: TAsmList; pd: tprocdef; const s: TSymStr; forceresdef: tdef; weak: boolean): tcgpara;
   function thlcgcpu.a_call_name(list: TAsmList; pd: tprocdef; const s: TSymStr; forceresdef: tdef; weak: boolean): tcgpara;
     begin
     begin
       if is_proc_far(pd) then
       if is_proc_far(pd) then
-        tcg8086(cg).a_call_name_far(list,s,weak)
+        begin
+          { far calls to the same module (in $HUGECODE off mode) can be optimized
+            to push cs + call near, because they are in the same segment }
+          if not (cs_huge_code in current_settings.moduleswitches) and
+                 (pd.procsym.owner=current_module.localsymtable) then
+            begin
+              list.concat(Taicpu.Op_reg(A_PUSH,S_W,NR_CS));
+              tcg8086(cg).a_call_name_near(list,s,weak);
+            end
+          else
+            tcg8086(cg).a_call_name_far(list,s,weak);
+        end
       else
       else
         tcg8086(cg).a_call_name_near(list,s,weak);
         tcg8086(cg).a_call_name_near(list,s,weak);
       result:=get_call_result_cgpara(pd,forceresdef);
       result:=get_call_result_cgpara(pd,forceresdef);