Browse Source

* don't create (useless) temporary array/record/... for the result
of functions at the caller side, since these will already be allocated
at the callee side
* added comment to cpupara explaining why we never allocate the function
result on the caller side and then pass it as an invisible parameter,
but instead always let the callee allocate it

git-svn-id: branches/jvmbackend@18420 -

Jonas Maebe 14 years ago
parent
commit
254636ab84
2 changed files with 10 additions and 1 deletions
  1. 4 0
      compiler/jvm/cpupara.pas
  2. 6 1
      compiler/jvm/njvmcal.pas

+ 4 - 0
compiler/jvm/cpupara.pas

@@ -147,6 +147,10 @@ implementation
 
 
     function TJVMParaManager.ret_in_param(def: tdef; calloption: tproccalloption): boolean;
     function TJVMParaManager.ret_in_param(def: tdef; calloption: tproccalloption): boolean;
       begin
       begin
+        { not as efficient as returning in param for jvmimplicitpointertypes,
+          but in the latter case the routines are harder to use from Java
+          (especially for arrays), because the caller then manually has to
+          allocate the instance/array of the right size }
         Result:=false;
         Result:=false;
       end;
       end;
 
 

+ 6 - 1
compiler/jvm/njvmcal.pas

@@ -80,7 +80,12 @@ implementation
     procedure tjvmcallnode.set_result_location(realresdef: tstoreddef);
     procedure tjvmcallnode.set_result_location(realresdef: tstoreddef);
       begin
       begin
         location_reset_ref(location,LOC_REFERENCE,def_cgsize(realresdef),1);
         location_reset_ref(location,LOC_REFERENCE,def_cgsize(realresdef),1);
-        tg.gethltemp(current_asmdata.CurrAsmList,realresdef,realresdef.size,tt_normal,location.reference);
+        { in case of jvmimplicitpointertype(), the function will have allocated
+          it already and we don't have to allocate it again here }
+        if not jvmimplicitpointertype(realresdef) then
+          tg.gethltemp(current_asmdata.CurrAsmList,realresdef,realresdef.size,tt_normal,location.reference)
+        else
+          tg.gethltemp(current_asmdata.CurrAsmList,java_jlobject,java_jlobject.size,tt_normal,location.reference);
       end;
       end;