Browse Source

* decrease the fpu stack position counter after explicitly inserted
fist(t)pq instructions (mantis #22331)
* also internalerror in case the internal fpu stack position counter
becomes larger than 7, so we don't have to wait for the entire
byte to overflow before we detect a problem

git-svn-id: trunk@21734 -

Jonas Maebe 13 years ago
parent
commit
bb28a7cd08
4 changed files with 145 additions and 0 deletions
  1. 1 0
      .gitattributes
  2. 2 0
      compiler/x86/cgx86.pas
  3. 3 0
      compiler/x86/nx86inl.pas
  4. 139 0
      tests/webtbs/tw22331.pp

+ 1 - 0
.gitattributes

@@ -12665,6 +12665,7 @@ tests/webtbs/tw2226.pp svneol=native#text/plain
 tests/webtbs/tw2229.pp svneol=native#text/plain
 tests/webtbs/tw22320.pp svneol=native#text/plain
 tests/webtbs/tw2233.pp svneol=native#text/plain
+tests/webtbs/tw22331.pp svneol=native#text/plain
 tests/webtbs/tw2242.pp svneol=native#text/plain
 tests/webtbs/tw2250.pp svneol=native#text/plain
 tests/webtbs/tw2259.pp svneol=native#text/plain

+ 2 - 0
compiler/x86/cgx86.pas

@@ -266,6 +266,8 @@ unit cgx86;
 
     procedure tcgx86.inc_fpu_stack;
       begin
+        if rgfpu.fpuvaroffset>=7 then
+          internalerror(2012062901);
         inc(rgfpu.fpuvaroffset);
       end;
 

+ 3 - 0
compiler/x86/nx86inl.pas

@@ -271,6 +271,7 @@ implementation
             location_reset_ref(location,LOC_REFERENCE,OS_S64,0);
             tg.GetTemp(current_asmdata.CurrAsmList,resultdef.size,resultdef.alignment,tt_normal,location.reference);
             emit_ref(A_FISTP,S_IQ,location.reference);
+            tcgx86(cg).dec_fpu_stack;
             emit_none(A_FWAIT,S_NO);
            end;
        end;
@@ -306,6 +307,7 @@ implementation
                 location_reset_ref(location,LOC_REFERENCE,OS_S64,0);
                 tg.GetTemp(current_asmdata.CurrAsmList,resultdef.size,resultdef.alignment,tt_normal,location.reference);
                 emit_ref(A_FISTTP,S_IQ,location.reference);
+                tcgx86(cg).dec_fpu_stack;
               end
             else
               begin
@@ -319,6 +321,7 @@ implementation
                 location_reset_ref(location,LOC_REFERENCE,OS_S64,0);
                 tg.GetTemp(current_asmdata.CurrAsmList,resultdef.size,resultdef.alignment,tt_normal,location.reference);
                 emit_ref(A_FISTP,S_IQ,location.reference);
+                tcgx86(cg).dec_fpu_stack;
                 emit_ref(A_FLDCW,S_NO,oldcw);
                 emit_none(A_FWAIT,S_NO);
                 tg.UnGetTemp(current_asmdata.CurrAsmList,oldcw);

+ 139 - 0
tests/webtbs/tw22331.pp

@@ -0,0 +1,139 @@
+procedure X;
+var
+  w, h: integer;
+begin
+  w:=1;
+  h:=2;
+  writeln(round(w / 2 - 0), round(h - 0));
+  writeln(round(w / 2 - 138.809093), round(h - 661.165204));
+  writeln(round(w / 2 - 138.683051), round(h - 661.003245));
+  writeln(round(w / 2 - 138.556540), round(h - 660.840685));
+  writeln(round(w / 2 - 138.429558), round(h - 660.677449));
+  writeln(round(w / 2 - 138.302098), round(h - 660.513612));
+  writeln(round(w / 2 - 138.174178), round(h - 660.349250));
+  writeln(round(w / 2 - 138.045779), round(h - 660.184211));
+  writeln(round(w / 2 - 137.916911), round(h - 660.018571));
+  writeln(round(w / 2 - 137.787573), round(h - 659.852405));
+  writeln(round(w / 2 - 137.657765), round(h - 659.685563));
+  writeln(round(w / 2 - 137.527488), round(h - 659.518121));
+  writeln(round(w / 2 - 137.396732), round(h - 659.350077));
+  writeln(round(w / 2 - 137.265516), round(h - 659.181432));
+  writeln(round(w / 2 - 137.133821), round(h - 659.012187));
+  writeln(round(w / 2 - 137.001656), round(h - 658.842340));
+  writeln(round(w / 2 - 136.869023), round(h - 658.671892));
+  writeln(round(w / 2 - 136.735910), round(h - 658.500844));
+  writeln(round(w / 2 - 136.602337), round(h - 658.329119));
+  writeln(round(w / 2 - 136.468294), round(h - 658.156944));
+  writeln(round(w / 2 - 136.333773), round(h - 657.984017));
+  writeln(round(w / 2 - 136.198782), round(h - 657.810490));
+  writeln(round(w / 2 - 136.063322), round(h - 657.636437));
+  writeln(round(w / 2 - 135.927392), round(h - 657.461782));
+  writeln(round(w / 2 - 135.790993), round(h - 657.286452));
+  writeln(round(w / 2 - 135.654114), round(h - 657.110521));
+  writeln(round(w / 2 - 135.516776), round(h - 656.933988));
+  writeln(round(w / 2 - 135.378959), round(h - 656.756930));
+  writeln(round(w / 2 - 135.240672), round(h - 656.579196));
+  writeln(round(w / 2 - 135.101916), round(h - 656.400936));
+  writeln(round(w / 2 - 134.962690), round(h - 656.222000));
+  writeln(round(w / 2 - 134.822995), round(h - 656.042463));
+  writeln(round(w / 2 - 134.682821), round(h - 655.862325));
+  writeln(round(w / 2 - 134.542186), round(h - 655.681586));
+  writeln(round(w / 2 - 134.147430), round(h - 655.174225));
+  writeln(round(w / 2 - 134.006815), round(h - 654.993486));
+  writeln(round(w / 2 - 133.866669), round(h - 654.813348));
+  writeln(round(w / 2 - 133.727002), round(h - 654.633886));
+  writeln(round(w / 2 - 133.607551), round(h - 654.480415));
+  writeln(round(w / 2 - 133.488777), round(h - 654.287807));
+  writeln(round(w / 2 - 133.370406), round(h - 654.095800));
+  writeln(round(w / 2 - 133.252440), round(h - 653.904469));
+  writeln(round(w / 2 - 133.134877), round(h - 653.713814));
+  writeln(round(w / 2 - 133.017708), round(h - 653.523836));
+  writeln(round(w / 2 - 132.900953), round(h - 653.334458));
+  writeln(round(w / 2 - 132.784592), round(h - 653.145756));
+  writeln(round(w / 2 - 132.668644), round(h - 652.957730));
+  writeln(round(w / 2 - 132.553090), round(h - 652.770306));
+  writeln(round(w / 2 - 132.437940), round(h - 652.583557));
+  writeln(round(w / 2 - 132.323204), round(h - 652.397485));
+  writeln(round(w / 2 - 132.208862), round(h - 652.212088));
+  writeln(round(w / 2 - 132.094923), round(h - 652.027293));
+  writeln(round(w / 2 - 131.981379), round(h - 651.843098));
+  writeln(round(w / 2 - 131.868248), round(h - 651.659655));
+  writeln(round(w / 2 - 131.755521), round(h - 651.476812));
+  writeln(round(w / 2 - 131.643198), round(h - 651.294721));
+  writeln(round(w / 2 - 131.531269), round(h - 651.113231));
+  writeln(round(w / 2 - 131.419753), round(h - 650.932342));
+  writeln(round(w / 2 - 131.308631), round(h - 650.752129));
+  writeln(round(w / 2 - 131.197914), round(h - 650.572516));
+  writeln(round(w / 2 - 131.087609), round(h - 650.393655));
+  writeln(round(w / 2 - 130.977699), round(h - 650.215395));
+  writeln(round(w / 2 - 130.868193), round(h - 650.037812));
+  writeln(round(w / 2 - 130.759090), round(h - 649.860904));
+  writeln(round(w / 2 - 130.650391), round(h - 649.684597));
+  writeln(round(w / 2 - 130.542087), round(h - 649.508966));
+  writeln(round(w / 2 - 130.434196), round(h - 649.334011));
+  writeln(round(w / 2 - 130.326708), round(h - 649.159657));
+  writeln(round(w / 2 - 130.219615), round(h - 648.985980));
+  writeln(round(w / 2 - 130.112935), round(h - 648.813053));
+  writeln(round(w / 2 - 130.006650), round(h - 648.640577));
+  writeln(round(w / 2 - 129.900768), round(h - 648.468928));
+  writeln(round(w / 2 - 129.795290), round(h - 648.297879));
+  writeln(round(w / 2 - 129.690215), round(h - 648.127507));
+  writeln(round(w / 2 - 129.585554), round(h - 647.957735));
+  writeln(round(w / 2 - 129.481278), round(h - 647.788565));
+  writeln(round(w / 2 - 129.377415), round(h - 647.620146));
+  writeln(round(w / 2 - 129.273956), round(h - 647.452402));
+  writeln(round(w / 2 - 129.170901), round(h - 647.285260));
+  writeln(round(w / 2 - 129.068240), round(h - 647.118794));
+  writeln(round(w / 2 - 128.965992), round(h - 646.952929));
+  writeln(round(w / 2 - 128.864138), round(h - 646.787815));
+  writeln(round(w / 2 - 128.762689), round(h - 646.623302));
+  writeln(round(w / 2 - 128.661652), round(h - 646.459390));
+  writeln(round(w / 2 - 128.561010), round(h - 646.296154));
+  writeln(round(w / 2 - 128.460771), round(h - 646.133594));
+  writeln(round(w / 2 - 128.360937), round(h - 645.971710));
+  writeln(round(w / 2 - 128.261506), round(h - 645.810502));
+  writeln(round(w / 2 - 128.162469), round(h - 645.649895));
+  writeln(round(w / 2 - 128.063846), round(h - 645.489889));
+  writeln(round(w / 2 - 127.965627), round(h - 645.330635));
+  writeln(round(w / 2 - 127.894723), round(h - 645.215626));
+  writeln(round(w / 2 - 127.808626), round(h - 645.050587));
+  writeln(round(w / 2 - 127.722895), round(h - 644.886149));
+  writeln(round(w / 2 - 127.637511), round(h - 644.722462));
+  writeln(round(w / 2 - 127.552485), round(h - 644.559452));
+  writeln(round(w / 2 - 127.467815), round(h - 644.397042));
+  writeln(round(w / 2 - 127.383502), round(h - 644.235383));
+  writeln(round(w / 2 - 127.299537), round(h - 644.074476));
+  writeln(round(w / 2 - 127.215937), round(h - 643.914170));
+  writeln(round(w / 2 - 127.132695), round(h - 643.754540));
+  writeln(round(w / 2 - 127.049800), round(h - 643.595585));
+  writeln(round(w / 2 - 126.967261), round(h - 643.437307));
+  writeln(round(w / 2 - 126.885080), round(h - 643.279780));
+  writeln(round(w / 2 - 126.803255), round(h - 643.122854));
+  writeln(round(w / 2 - 126.721788), round(h - 642.966680));
+  writeln(round(w / 2 - 126.640677), round(h - 642.811106));
+  writeln(round(w / 2 - 126.559923), round(h - 642.656359));
+  writeln(round(w / 2 - 126.479516), round(h - 642.502137));
+  writeln(round(w / 2 - 126.399475), round(h - 642.348667));
+  writeln(round(w / 2 - 126.319782), round(h - 642.195872));
+  writeln(round(w / 2 - 126.240446), round(h - 642.043754));
+  writeln(round(w / 2 - 126.161467), round(h - 641.892312));
+  writeln(round(w / 2 - 126.082844), round(h - 641.741546));
+  writeln(round(w / 2 - 126.004578), round(h - 641.591456));
+  writeln(round(w / 2 - 125.926669), round(h - 641.442117));
+  writeln(round(w / 2 - 125.849108), round(h - 641.293379));
+  writeln(round(w / 2 - 125.771913), round(h - 641.145393));
+  writeln(round(w / 2 - 125.695065), round(h - 640.998007));
+  writeln(round(w / 2 - 125.618583), round(h - 640.851372));
+  writeln(round(w / 2 - 125.542449), round(h - 640.705414));
+  writeln(round(w / 2 - 125.466671), round(h - 640.560132));
+  writeln(round(w / 2 - 125.391251), round(h - 640.415525));
+  writeln(round(w / 2 - 125.316178), round(h - 640.271595));
+  writeln(round(w / 2 - 125.241471), round(h - 640.128341));
+  writeln(round(w / 2 - 125.167121), round(h - 639.985763));
+  writeln(round(w / 2 - 125.093118), round(h - 639.843861));
+  writeln(round(w / 2 - 125.019472), round(h - 639.702711));
+  writeln(round(w / 2 - 124.873260), round(h - 639.422287)); 
+end;
+begin
+  X
+end.