Parcourir la source

Various checks for "weak" variables/parameters/fields.

psub.pas:
  * check_finalize_locals: don't finalize locals declared as "weak"
symsym.pas, tparavarsym:
  * needs_finalization: don't finalize parameters declared as "weak"
ncgcal.pas, tcgcallparanode:
  * secondcallparan: don't release out parameters declared as "weak"
ncgutil.pas:
  * init_paras: don't increase the reference count of parameters declared as "weak"
hlcgobj.pas, thlcgobj:
  * final_paras: don't finalize parameters declared as "weak"
  * init_paras: don't increase the reference count of parameters declared as "weak"

git-svn-id: branches/svenbarth/arc@28872 -
svenbarth il y a 10 ans
Parent
commit
3c800c5563
5 fichiers modifiés avec 15 ajouts et 5 suppressions
  1. 4 2
      compiler/hlcgobj.pas
  2. 1 0
      compiler/ncgcal.pas
  3. 2 1
      compiler/ncgutil.pas
  4. 2 1
      compiler/psub.pas
  5. 6 1
      compiler/symsym.pas

+ 4 - 2
compiler/hlcgobj.pas

@@ -4547,7 +4547,8 @@ implementation
       if not(tsym(p).typ=paravarsym) then
         exit;
       list:=TAsmList(arg);
-      if is_managed_type(tparavarsym(p).vardef) then
+      if is_managed_type(tparavarsym(p).vardef) and
+          not (vo_is_weakref in tparavarsym(p).varoptions) then
        begin
          if (tparavarsym(p).varspez=vs_value) then
           begin
@@ -4608,7 +4609,8 @@ implementation
                  { variants are already handled by the call to fpc_variant_copy_overwrite if
                    they are passed by reference }
                  if not((tparavarsym(p).vardef.typ=variantdef) and
-                   paramanager.push_addr_param(tparavarsym(p).varspez,tparavarsym(p).vardef,current_procinfo.procdef.proccalloption)) then
+                   paramanager.push_addr_param(tparavarsym(p).varspez,tparavarsym(p).vardef,current_procinfo.procdef.proccalloption)) and
+                     not (vo_is_weakref in tparavarsym(p).varoptions) then
                    begin
                      location_get_data_ref(list,tparavarsym(p).vardef,tparavarsym(p).initialloc,href,is_open_array(tparavarsym(p).vardef),sizeof(pint));
                      if is_open_array(tparavarsym(p).vardef) then

+ 1 - 0
compiler/ncgcal.pas

@@ -268,6 +268,7 @@ implementation
              { release memory for refcnt out parameters }
              if (parasym.varspez=vs_out) and
                 is_managed_type(left.resultdef) and
+                not (vo_is_weakref in parasym.varoptions) and
                 not(target_info.system in systems_garbage_collected_managed_types) then
                begin
                  hlcg.location_get_data_ref(current_asmdata.CurrAsmList,left.resultdef,left.location,href,false,sizeof(pint));

+ 2 - 1
compiler/ncgutil.pas

@@ -696,7 +696,8 @@ implementation
                  { variants are already handled by the call to fpc_variant_copy_overwrite if
                    they are passed by reference }
                  if not((tparavarsym(p).vardef.typ=variantdef) and
-                    paramanager.push_addr_param(tparavarsym(p).varspez,tparavarsym(p).vardef,current_procinfo.procdef.proccalloption)) then
+                    paramanager.push_addr_param(tparavarsym(p).varspez,tparavarsym(p).vardef,current_procinfo.procdef.proccalloption)) and
+                    not (vo_is_weakref in tparavarsym(p).varoptions) then
                    begin
                      hlcg.location_get_data_ref(list,tparavarsym(p).vardef,tparavarsym(p).initialloc,href,is_open_array(tparavarsym(p).vardef),sizeof(pint));
                      if is_open_array(tparavarsym(p).vardef) then

+ 2 - 1
compiler/psub.pas

@@ -278,7 +278,8 @@ implementation
         { occurs                                                            }
         if (tsym(p).typ=localvarsym) and
            (tlocalvarsym(p).refs>0) and
-           is_managed_type(tlocalvarsym(p).vardef) then
+           is_managed_type(tlocalvarsym(p).vardef) and
+           not (vo_is_weakref in tlocalvarsym(p).varoptions) then
           begin
             include(current_procinfo.flags,pi_needs_implicit_finally);
             if is_rtti_managed_type(tlocalvarsym(p).vardef) and

+ 6 - 1
compiler/symsym.pas

@@ -2176,7 +2176,12 @@ implementation
     function tparavarsym.needs_finalization:boolean;
       begin
         result:=(varspez=vs_value) and
-          (is_managed_type(vardef) or
+          (
+            (
+              is_managed_type(vardef) and
+              not (vo_is_weakref in varoptions)
+            )
+            or
             (
               (not (tabstractprocdef(owner.defowner).proccalloption in cdecl_pocalls)) and
               (not paramanager.use_stackalloc) and