Browse Source

* don't add a separate high parameter for array-of-const parameters on the
JVM target (just like for open array parameters), since the array length
is already encoded in the array itself there

git-svn-id: trunk@22968 -

Jonas Maebe 12 years ago
parent
commit
d9e67fc835
5 changed files with 31 additions and 6 deletions
  1. 16 1
      compiler/jvm/cpupara.pas
  2. 6 3
      compiler/jvm/njvminl.pas
  3. 1 1
      compiler/ncal.pas
  4. 7 0
      compiler/paramgr.pas
  5. 1 1
      compiler/ppu.pas

+ 16 - 1
compiler/jvm/cpupara.pas

@@ -36,6 +36,7 @@ interface
 
 
       TJVMParaManager=class(TParaManager)
       TJVMParaManager=class(TParaManager)
         function  push_high_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;override;
         function  push_high_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;override;
+        function  keep_para_array_range(varspez: tvarspez; def: tdef; calloption: tproccalloption): boolean; override;
         function  push_addr_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;override;
         function  push_addr_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;override;
         function  push_copyout_param(varspez: tvarspez; def: tdef; calloption: tproccalloption): boolean; override;
         function  push_copyout_param(varspez: tvarspez; def: tdef; calloption: tproccalloption): boolean; override;
         function  push_size(varspez: tvarspez; def: tdef; calloption: tproccalloption): longint;override;
         function  push_size(varspez: tvarspez; def: tdef; calloption: tproccalloption): longint;override;
@@ -73,13 +74,27 @@ implementation
       begin
       begin
         { we don't need a separate high parameter, since all arrays in Java
         { we don't need a separate high parameter, since all arrays in Java
           have an implicit associated length }
           have an implicit associated length }
-        if not is_open_array(def) then
+        if not is_open_array(def) and
+           not is_array_of_const(def) then
           result:=inherited
           result:=inherited
         else
         else
           result:=false;
           result:=false;
       end;
       end;
 
 
 
 
+    function TJVMParaManager.keep_para_array_range(varspez: tvarspez; def: tdef; calloption: tproccalloption): boolean;
+      begin
+        { even though these don't need a high parameter (see push_high_param),
+          we do have to keep the original parameter's array length because it's
+          used by the compiler (to determine the size of the array to construct
+          to pass to an array of const parameter)  }
+        if not is_array_of_const(def) then
+          result:=inherited
+        else
+          result:=true;
+      end;
+
+
     { true if a parameter is too large to copy and only the address is pushed }
     { true if a parameter is too large to copy and only the address is pushed }
     function TJVMParaManager.push_addr_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;
     function TJVMParaManager.push_addr_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;
       begin
       begin

+ 6 - 3
compiler/jvm/njvminl.pas

@@ -89,7 +89,8 @@ implementation
       begin
       begin
         typecheckpass(left);
         typecheckpass(left);
         if is_open_array(left.resultdef) or
         if is_open_array(left.resultdef) or
-           is_dynamic_array(left.resultdef) then
+           is_dynamic_array(left.resultdef) or
+           is_array_of_const(left.resultdef) then
           begin
           begin
             resultdef:=s32inttype;
             resultdef:=s32inttype;
             result:=nil;
             result:=nil;
@@ -102,7 +103,8 @@ implementation
       begin
       begin
         typecheckpass(left);
         typecheckpass(left);
         if is_dynamic_array(left.resultdef) or
         if is_dynamic_array(left.resultdef) or
-           is_open_array(left.resultdef) then
+           is_open_array(left.resultdef) or
+           is_array_of_const(left.resultdef) then
           begin
           begin
             { replace with pred(length(arr)) }
             { replace with pred(length(arr)) }
             result:=cinlinenode.create(in_pred_x,false,
             result:=cinlinenode.create(in_pred_x,false,
@@ -629,7 +631,8 @@ implementation
     procedure tjvminlinenode.second_length;
     procedure tjvminlinenode.second_length;
       begin
       begin
         if is_dynamic_array(left.resultdef) or
         if is_dynamic_array(left.resultdef) or
-           is_open_array(left.resultdef) then
+           is_open_array(left.resultdef) or
+           is_array_of_const(left.resultdef) then
           begin
           begin
             location_reset(location,LOC_REGISTER,OS_S32);
             location_reset(location,LOC_REGISTER,OS_S32);
             location.register:=hlcg.getintregister(current_asmdata.CurrAsmList,s32inttype);
             location.register:=hlcg.getintregister(current_asmdata.CurrAsmList,s32inttype);

+ 1 - 1
compiler/ncal.pas

@@ -822,7 +822,7 @@ implementation
                     not(parasym.univpara) then
                     not(parasym.univpara) then
                    begin
                    begin
                       { Process open parameters }
                       { Process open parameters }
-                      if paramanager.push_high_param(parasym.varspez,parasym.vardef,aktcallnode.procdefinition.proccalloption) then
+                      if paramanager.keep_para_array_range(parasym.varspez,parasym.vardef,aktcallnode.procdefinition.proccalloption) then
                        begin
                        begin
                          { insert type conv but hold the ranges of the array }
                          { insert type conv but hold the ranges of the array }
                          olddef:=left.resultdef;
                          olddef:=left.resultdef;

+ 7 - 0
compiler/paramgr.pas

@@ -50,6 +50,7 @@ unit paramgr;
           function ret_in_param(def : tdef;calloption : tproccalloption) : boolean;virtual;
           function ret_in_param(def : tdef;calloption : tproccalloption) : boolean;virtual;
 
 
           function push_high_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;virtual;
           function push_high_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;virtual;
+          function keep_para_array_range(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;virtual;
 
 
           { Returns true if a parameter is too large to copy and only
           { Returns true if a parameter is too large to copy and only
             the address is pushed
             the address is pushed
@@ -197,6 +198,12 @@ implementation
       end;
       end;
 
 
 
 
+    function tparamanager.keep_para_array_range(varspez: tvarspez; def: tdef; calloption: tproccalloption): boolean;
+      begin
+        result:=push_high_param(varspez,def,calloption);
+      end;
+
+
     function tparamanager.push_copyout_param(varspez: tvarspez; def: tdef; calloption: tproccalloption): boolean;
     function tparamanager.push_copyout_param(varspez: tvarspez; def: tdef; calloption: tproccalloption): boolean;
       begin
       begin
         push_copyout_param:=false;
         push_copyout_param:=false;

+ 1 - 1
compiler/ppu.pas

@@ -43,7 +43,7 @@ type
 {$endif Test_Double_checksum}
 {$endif Test_Double_checksum}
 
 
 const
 const
-  CurrentPPUVersion = 154;
+  CurrentPPUVersion = 155;
 
 
 { buffer sizes }
 { buffer sizes }
   maxentrysize = 1024;
   maxentrysize = 1024;