Przeglądaj źródła

* fixed calculation of fpu resources

git-svn-id: trunk@8779 -
florian 18 lat temu
rodzic
commit
f66916fc95
3 zmienionych plików z 36 dodań i 17 usunięć
  1. 1 0
      .gitattributes
  2. 14 17
      compiler/nutils.pas
  3. 21 0
      tests/webtbs/tw9919.pp

+ 1 - 0
.gitattributes

@@ -8482,6 +8482,7 @@ tests/webtbs/tw9827.pp svneol=native#text/plain
 tests/webtbs/tw9894.pp svneol=native#text/plain
 tests/webtbs/tw9894a.pp svneol=native#text/plain
 tests/webtbs/tw9897.pp svneol=native#text/plain
+tests/webtbs/tw9919.pp -text
 tests/webtbs/ub1873.pp svneol=native#text/plain
 tests/webtbs/ub1883.pp svneol=native#text/plain
 tests/webtbs/uw0555.pp svneol=native#text/plain

+ 14 - 17
compiler/nutils.pas

@@ -718,26 +718,23 @@ implementation
         res1:=0;
         res2:=0;
         res3:=0;
-        if p.inheritsfrom(ttertiarynode) and assigned(ttertiarynode(p).third) then
-          res3:=node_resources_fpu(ttertiarynode(p).third)
-        else if p.inheritsfrom(tbinarynode) and assigned(tbinarynode(p).right) then
-          res2:=node_resources_fpu(tbinarynode(p).right)
-        else
-          if p.inheritsfrom(tunarynode) and assigned(tunarynode(p).left) then
-            res1:=node_resources_fpu(tunarynode(p).left);
+        if p.inheritsfrom(tunarynode) then
+          begin
+            if assigned(tunarynode(p).left) then
+              res1:=node_resources_fpu(tunarynode(p).left);
+            if p.inheritsfrom(tbinarynode) then
+              begin
+                if assigned(tbinarynode(p).right) then
+                  res2:=node_resources_fpu(tbinarynode(p).right);
+                if p.inheritsfrom(ttertiarynode) and assigned(ttertiarynode(p).third) then
+                  res3:=node_resources_fpu(ttertiarynode(p).third)
+              end;
+          end;
         result:=max(max(res1,res2),res3);
         case p.nodetype of
           calln:
-            begin
-{$ifdef i386}
-              if tcallnode(p).procdefinition.typ=procdef then
-                result:=max(result,tprocdef(tcallnode(p).procdefinition).fpu_used)
-              else
-                result:=maxfpuregs;
-{$else i386}
-              result:=maxfpuregs;
-{$endif i386}
-            end;
+            { it could be a recursive call, so we never really know the number of used fpu registers }
+            result:=maxfpuregs;
           realconstn,
           typeconvn,
           loadn :

+ 21 - 0
tests/webtbs/tw9919.pp

@@ -0,0 +1,21 @@
+type
+  TForm1 = class
+    function crash(n:integer):real;
+  end;
+
+function TForm1.crash(n:integer):real;
+begin
+  case n of
+  0: Result:=0;
+  1..100: Result:=crash(n-1)+crash(n-1);
+  end;
+end;
+
+var
+  f : TForm1;
+
+begin
+  f:=TForm1.create;
+  writeln(f.crash(15));
+  f.Free;
+end.