* 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 -
This commit is contained in:
Jonas Maebe 2012-11-10 20:26:42 +00:00
parent d67f31a0e1
commit d9e67fc835
5 changed files with 31 additions and 6 deletions

View File

@ -36,6 +36,7 @@ interface
TJVMParaManager=class(TParaManager)
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_copyout_param(varspez: tvarspez; def: tdef; calloption: tproccalloption): boolean; override;
function push_size(varspez: tvarspez; def: tdef; calloption: tproccalloption): longint;override;
@ -73,13 +74,27 @@ implementation
begin
{ we don't need a separate high parameter, since all arrays in Java
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
else
result:=false;
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 }
function TJVMParaManager.push_addr_param(varspez:tvarspez;def : tdef;calloption : tproccalloption) : boolean;
begin

View File

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

View File

@ -822,7 +822,7 @@ implementation
not(parasym.univpara) then
begin
{ 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
{ insert type conv but hold the ranges of the array }
olddef:=left.resultdef;

View File

@ -50,6 +50,7 @@ unit paramgr;
function ret_in_param(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
the address is pushed
@ -197,6 +198,12 @@ implementation
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;
begin
push_copyout_param:=false;

View File

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