Browse Source

* changed getarraydef() into a tarraydef.getreusable() class method

git-svn-id: trunk@31147 -
Jonas Maebe 10 years ago
parent
commit
f40ea04540

+ 5 - 5
compiler/aasmcnst.pas

@@ -661,7 +661,7 @@ implementation
            if fvalues.count<>1 then
            if fvalues.count<>1 then
              internalerror(2014070105);
              internalerror(2014070105);
            tai_simpletypedconst(fvalues[0]).fdef:=
            tai_simpletypedconst(fvalues[0]).fdef:=
-             getarraydef(cansichartype,
+             carraydef.getreusable(cansichartype,
                tai_string(tai_simpletypedconst(fvalues[0]).val).len);
                tai_string(tai_simpletypedconst(fvalues[0]).val).len);
          end;
          end;
      end;
      end;
@@ -1165,7 +1165,7 @@ implementation
        move(data^,s^,len);
        move(data^,s^,len);
        s[len]:=#0;
        s[len]:=#0;
        { terminating zero included }
        { terminating zero included }
-       datadef:=getarraydef(cansichartype,len+1);
+       datadef:=carraydef.getreusable(cansichartype,len+1);
        datatcb.maybe_begin_aggregate(datadef);
        datatcb.maybe_begin_aggregate(datadef);
        datatcb.emit_tai(tai_string.create_pchar(s,len+1),datadef);
        datatcb.emit_tai(tai_string.create_pchar(s,len+1),datadef);
        datatcb.maybe_end_aggregate(datadef);
        datatcb.maybe_end_aggregate(datadef);
@@ -1214,7 +1214,7 @@ implementation
          end;
          end;
        if cwidechartype.size = 2 then
        if cwidechartype.size = 2 then
          begin
          begin
-           datadef:=getarraydef(cwidechartype,strlength+1);
+           datadef:=carraydef.getreusable(cwidechartype,strlength+1);
            datatcb.maybe_begin_aggregate(datadef);
            datatcb.maybe_begin_aggregate(datadef);
            for i:=0 to strlength-1 do
            for i:=0 to strlength-1 do
              datatcb.emit_tai(Tai_const.Create_16bit(pcompilerwidestring(data)^.data[i]),cwidechartype);
              datatcb.emit_tai(Tai_const.Create_16bit(pcompilerwidestring(data)^.data[i]),cwidechartype);
@@ -1242,11 +1242,11 @@ implementation
          functionality in place yet to reuse shortstringdefs of the same length
          functionality in place yet to reuse shortstringdefs of the same length
          and neither the lowlevel nor the llvm typedconst builder cares about
          and neither the lowlevel nor the llvm typedconst builder cares about
          this difference }
          this difference }
-       result:=getarraydef(cansichartype,length(str)+1);
+       result:=carraydef.getreusable(cansichartype,length(str)+1);
        maybe_begin_aggregate(result);
        maybe_begin_aggregate(result);
        emit_tai(Tai_const.Create_8bit(length(str)),u8inttype);
        emit_tai(Tai_const.Create_8bit(length(str)),u8inttype);
        if str<>'' then
        if str<>'' then
-         emit_tai(Tai_string.Create(str),getarraydef(cansichartype,length(str)));
+         emit_tai(Tai_string.Create(str),carraydef.getreusable(cansichartype,length(str)));
        maybe_end_aggregate(result);
        maybe_end_aggregate(result);
      end;
      end;
 
 

+ 2 - 2
compiler/arm/cpupara.pas

@@ -473,7 +473,7 @@ unit cpupara;
                             { LOC_REFERENCE always contains everything that's left }
                             { LOC_REFERENCE always contains everything that's left }
                             paraloc^.loc:=LOC_REFERENCE;
                             paraloc^.loc:=LOC_REFERENCE;
                             paraloc^.size:=int_cgsize(paralen);
                             paraloc^.size:=int_cgsize(paralen);
-                            paraloc^.def:=getarraydef(u8inttype,paralen);
+                            paraloc^.def:=carraydef.getreusable(u8inttype,paralen);
                             if (side=callerside) then
                             if (side=callerside) then
                               paraloc^.reference.index:=NR_STACK_POINTER_REG;
                               paraloc^.reference.index:=NR_STACK_POINTER_REG;
                             paraloc^.reference.offset:=stack_offset;
                             paraloc^.reference.offset:=stack_offset;
@@ -547,7 +547,7 @@ unit cpupara;
                             { LOC_REFERENCE always contains everything that's left }
                             { LOC_REFERENCE always contains everything that's left }
                             paraloc^.loc:=LOC_REFERENCE;
                             paraloc^.loc:=LOC_REFERENCE;
                             paraloc^.size:=int_cgsize(paralen);
                             paraloc^.size:=int_cgsize(paralen);
-                            paraloc^.def:=getarraydef(u8inttype,paralen);
+                            paraloc^.def:=carraydef.getreusable(u8inttype,paralen);
                             if (side=callerside) then
                             if (side=callerside) then
                               paraloc^.reference.index:=NR_STACK_POINTER_REG;
                               paraloc^.reference.index:=NR_STACK_POINTER_REG;
                             paraloc^.reference.offset:=stack_offset;
                             paraloc^.reference.offset:=stack_offset;

+ 1 - 1
compiler/jvm/njvmcal.pas

@@ -228,7 +228,7 @@ implementation
           arreledef:=cpointerdef.getreusable(orgparadef)
           arreledef:=cpointerdef.getreusable(orgparadef)
         else
         else
           arreledef:=parasym.vardef;
           arreledef:=parasym.vardef;
-        arrdef:=getarraydef(arreledef,1+ord(cs_check_var_copyout in current_settings.localswitches));
+        arrdef:=carraydef.getreusable(arreledef,1+ord(cs_check_var_copyout in current_settings.localswitches));
         { the -1 means "use the array's element count to determine the number
         { the -1 means "use the array's element count to determine the number
           of elements" in the JVM temp generator }
           of elements" in the JVM temp generator }
         arraytemp:=ctempcreatenode.create(arrdef,-1,tt_persistent,true);
         arraytemp:=ctempcreatenode.create(arrdef,-1,tt_persistent,true);

+ 2 - 2
compiler/llvm/nllvmcon.pas

@@ -72,13 +72,13 @@ implementation
                   constants (-> excludes terminating #0) and pchars (-> includes
                   constants (-> excludes terminating #0) and pchars (-> includes
                   terminating #0). The resultdef excludes the #0 while the data
                   terminating #0). The resultdef excludes the #0 while the data
                   includes it -> insert typecast from datadef to resultdef }
                   includes it -> insert typecast from datadef to resultdef }
-                datadef:=getarraydef(cansichartype,len+1);
+                datadef:=carraydef.getreusable(cansichartype,len+1);
               cst_shortstring:
               cst_shortstring:
                 { the resultdef of the string constant is the type of the
                 { the resultdef of the string constant is the type of the
                   string to which it is assigned, which can be longer or shorter
                   string to which it is assigned, which can be longer or shorter
                   than the length of the string itself -> typecast it to the
                   than the length of the string itself -> typecast it to the
                   correct string type }
                   correct string type }
-                datadef:=getarraydef(cansichartype,min(len,255)+1);
+                datadef:=carraydef.getreusable(cansichartype,min(len,255)+1);
               else
               else
                 internalerror(2014071203);
                 internalerror(2014071203);
             end;
             end;

+ 2 - 2
compiler/llvm/nllvmmem.pas

@@ -129,7 +129,7 @@ implementation
               size for extended, which is usually larger) into an extended }
               size for extended, which is usually larger) into an extended }
             if (llvmfielddef.typ=floatdef) and
             if (llvmfielddef.typ=floatdef) and
                (tfloatdef(llvmfielddef).floattype=s80real) then
                (tfloatdef(llvmfielddef).floattype=s80real) then
-              hlcg.g_ptrtypecast_ref(current_asmdata.CurrAsmList,cpointerdef.getreusable(getarraydef(u8inttype,10)),cpointerdef.getreusable(s80floattype),location.reference);
+              hlcg.g_ptrtypecast_ref(current_asmdata.CurrAsmList,cpointerdef.getreusable(carraydef.getreusable(u8inttype,10)),cpointerdef.getreusable(s80floattype),location.reference);
             { if it doesn't match the requested field exactly (variant record),
             { if it doesn't match the requested field exactly (variant record),
               adjust the type of the pointer }
               adjust the type of the pointer }
             if (vs.offsetfromllvmfield<>0) or
             if (vs.offsetfromllvmfield<>0) or
@@ -168,7 +168,7 @@ implementation
           10 bytes) }
           10 bytes) }
         if (resultdef.typ=floatdef) and
         if (resultdef.typ=floatdef) and
            (tfloatdef(resultdef).floattype=s80real) then
            (tfloatdef(resultdef).floattype=s80real) then
-          arrptrelementdef:=cpointerdef.getreusable(getarraydef(u8inttype,10))
+          arrptrelementdef:=cpointerdef.getreusable(carraydef.getreusable(u8inttype,10))
         else
         else
           arrptrelementdef:=cpointerdef.getreusable(resultdef);
           arrptrelementdef:=cpointerdef.getreusable(resultdef);
       end;
       end;

+ 1 - 1
compiler/ncal.pas

@@ -778,7 +778,7 @@ implementation
                 { don't increase/decrease the reference count here, will be done by
                 { don't increase/decrease the reference count here, will be done by
                   the callee (see (*) above) -> typecast to array of byte
                   the callee (see (*) above) -> typecast to array of byte
                   for the assignment to the temp }
                   for the assignment to the temp }
-                temparraydef:=getarraydef(u8inttype,left.resultdef.size);
+                temparraydef:=carraydef.getreusable(u8inttype,left.resultdef.size);
                 paratemp:=ctempcreatenode.create(temparraydef,temparraydef.size,tt_persistent,false);
                 paratemp:=ctempcreatenode.create(temparraydef,temparraydef.size,tt_persistent,false);
                 addstatement(initstat,paratemp);
                 addstatement(initstat,paratemp);
                 addstatement(initstat,
                 addstatement(initstat,

+ 2 - 2
compiler/ncgcon.pas

@@ -377,7 +377,7 @@ implementation
                           move(value_str^,pc[1],l);
                           move(value_str^,pc[1],l);
                           pc[0]:=chr(l);
                           pc[0]:=chr(l);
                           pc[l+1]:=#0;
                           pc[l+1]:=#0;
-                          datadef:=getarraydef(cansichartype,l+1);
+                          datadef:=carraydef.getreusable(cansichartype,l+1);
                           datatcb.maybe_begin_aggregate(datadef);
                           datatcb.maybe_begin_aggregate(datadef);
                           datatcb.emit_tai(Tai_string.Create_pchar(pc,l+1),datadef);
                           datatcb.emit_tai(Tai_string.Create_pchar(pc,l+1),datadef);
                           datatcb.maybe_end_aggregate(datadef);
                           datatcb.maybe_end_aggregate(datadef);
@@ -397,7 +397,7 @@ implementation
                             string can be used for pchar assignments (but it's
                             string can be used for pchar assignments (but it's
                             also used for array-of-char assignments, in which
                             also used for array-of-char assignments, in which
                             case the terminating #0 is not part of the data) }
                             case the terminating #0 is not part of the data) }
-                          datadef:=getarraydef(cansichartype,len+1);
+                          datadef:=carraydef.getreusable(cansichartype,len+1);
                           datatcb.maybe_begin_aggregate(datadef);
                           datatcb.maybe_begin_aggregate(datadef);
                           datatcb.emit_tai(Tai_string.Create_pchar(pc,len+1),datadef);
                           datatcb.emit_tai(Tai_string.Create_pchar(pc,len+1),datadef);
                           datatcb.maybe_end_aggregate(datadef);
                           datatcb.maybe_end_aggregate(datadef);

+ 7 - 7
compiler/ncgvmt.pas

@@ -240,14 +240,14 @@ implementation
            writenames(tcb,p^.l);
            writenames(tcb,p^.l);
          tcb.start_internal_data_builder(current_asmdata.AsmLists[al_const],sec_rodata_norel,'',datatcb,p^.nl);
          tcb.start_internal_data_builder(current_asmdata.AsmLists[al_const],sec_rodata_norel,'',datatcb,p^.nl);
          len:=length(p^.data.messageinf.str^);
          len:=length(p^.data.messageinf.str^);
-         datatcb.maybe_begin_aggregate(getarraydef(cansichartype,len+1));
+         datatcb.maybe_begin_aggregate(carraydef.getreusable(cansichartype,len+1));
          datatcb.emit_tai(tai_const.create_8bit(len),cansichartype);
          datatcb.emit_tai(tai_const.create_8bit(len),cansichartype);
          getmem(ca,len+1);
          getmem(ca,len+1);
          move(p^.data.messageinf.str^[1],ca^,len);
          move(p^.data.messageinf.str^[1],ca^,len);
          ca[len]:=#0;
          ca[len]:=#0;
-         datatcb.emit_tai(Tai_string.Create_pchar(ca,len),getarraydef(cansichartype,len));
-         datatcb.maybe_end_aggregate(getarraydef(cansichartype,len+1));
-         tcb.finish_internal_data_builder(datatcb,p^.nl,getarraydef(cansichartype,len+1),sizeof(pint));
+         datatcb.emit_tai(Tai_string.Create_pchar(ca,len),carraydef.getreusable(cansichartype,len));
+         datatcb.maybe_end_aggregate(carraydef.getreusable(cansichartype,len+1));
+         tcb.finish_internal_data_builder(datatcb,p^.nl,carraydef.getreusable(cansichartype,len+1),sizeof(pint));
          if assigned(p^.r) then
          if assigned(p^.r) then
            writenames(tcb,p^.r);
            writenames(tcb,p^.r);
       end;
       end;
@@ -259,7 +259,7 @@ implementation
 
 
          { write name label }
          { write name label }
          tcb.maybe_begin_aggregate(entrydef);
          tcb.maybe_begin_aggregate(entrydef);
-         tcb.emit_tai(Tai_const.Create_sym(p^.nl),cpointerdef.getreusable(getarraydef(cansichartype,length(p^.data.messageinf.str^)+1)));
+         tcb.emit_tai(Tai_const.Create_sym(p^.nl),cpointerdef.getreusable(carraydef.getreusable(cansichartype,length(p^.data.messageinf.str^)+1)));
          tcb.queue_init(voidcodepointertype);
          tcb.queue_init(voidcodepointertype);
          tcb.queue_emit_proc(p^.data);
          tcb.queue_emit_proc(p^.data);
          tcb.maybe_end_aggregate(entrydef);
          tcb.maybe_end_aggregate(entrydef);
@@ -774,7 +774,7 @@ implementation
           current_asmdata.RefAsmSymbol(
           current_asmdata.RefAsmSymbol(
             make_mangledname('IIDSTR',AImplIntf.IntfDef.owner,AImplIntf.IntfDef.objname^),
             make_mangledname('IIDSTR',AImplIntf.IntfDef.owner,AImplIntf.IntfDef.objname^),
             AT_DATA),
             AT_DATA),
-          cpointerdef.getreusable(getarraydef(cansichartype,length(AImplIntf.IntfDef.iidstr^)+1)));
+          cpointerdef.getreusable(carraydef.getreusable(cansichartype,length(AImplIntf.IntfDef.iidstr^)+1)));
         { IType }
         { IType }
         tcb.emit_ord_const(aint(AImplIntf.VtblImplIntf.IType),interfaceentrytypedef);
         tcb.emit_ord_const(aint(AImplIntf.VtblImplIntf.IType),interfaceentrytypedef);
         tcb.maybe_end_aggregate(interfaceentrydef);
         tcb.maybe_end_aggregate(interfaceentrydef);
@@ -815,7 +815,7 @@ implementation
         datatcb.emit_tai(Tai_const.Create_pint(_class.ImplementedInterfaces.count),search_system_type('SIZEUINT').typedef);
         datatcb.emit_tai(Tai_const.Create_pint(_class.ImplementedInterfaces.count),search_system_type('SIZEUINT').typedef);
         interfaceentrydef:=search_system_type('TINTERFACEENTRY').typedef;
         interfaceentrydef:=search_system_type('TINTERFACEENTRY').typedef;
         interfaceentrytypedef:=search_system_type('TINTERFACEENTRYTYPE').typedef;
         interfaceentrytypedef:=search_system_type('TINTERFACEENTRYTYPE').typedef;
-        interfacearray:=getarraydef(interfaceentrydef,_class.ImplementedInterfaces.count);
+        interfacearray:=carraydef.getreusable(interfaceentrydef,_class.ImplementedInterfaces.count);
         datatcb.maybe_begin_aggregate(interfacearray);
         datatcb.maybe_begin_aggregate(interfacearray);
         { Write vtbl references }
         { Write vtbl references }
         for i:=0 to _class.ImplementedInterfaces.count-1 do
         for i:=0 to _class.ImplementedInterfaces.count-1 do

+ 5 - 5
compiler/ngtcon.pas

@@ -552,7 +552,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
                   fillchar(ca[strlength],def.size-strlength-1,' ');
                   fillchar(ca[strlength],def.size-strlength-1,' ');
                   ca[strlength]:=#0;
                   ca[strlength]:=#0;
                   ca[def.size-1]:=#0;
                   ca[def.size-1]:=#0;
-                  ftcb.emit_tai(Tai_string.Create_pchar(ca,def.size-1),getarraydef(cansichartype,def.size-1));
+                  ftcb.emit_tai(Tai_string.Create_pchar(ca,def.size-1),carraydef.getreusable(cansichartype,def.size-1));
                   ftcb.maybe_end_aggregate(def);
                   ftcb.maybe_end_aggregate(def);
                 end;
                 end;
               st_ansistring:
               st_ansistring:
@@ -830,14 +830,14 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
                    len:=255;
                    len:=255;
                   getmem(ca,len+1);
                   getmem(ca,len+1);
                   move(tstringconstnode(node).value_str^,ca^,len+1);
                   move(tstringconstnode(node).value_str^,ca^,len+1);
-                  datadef:=getarraydef(cansichartype,len+1);
+                  datadef:=carraydef.getreusable(cansichartype,len+1);
                   datatcb.maybe_begin_aggregate(datadef);
                   datatcb.maybe_begin_aggregate(datadef);
                   datatcb.emit_tai(Tai_string.Create_pchar(ca,len+1),datadef);
                   datatcb.emit_tai(Tai_string.Create_pchar(ca,len+1),datadef);
                   datatcb.maybe_end_aggregate(datadef);
                   datatcb.maybe_end_aggregate(datadef);
                 end
                 end
               else if is_constcharnode(node) then
               else if is_constcharnode(node) then
                 begin
                 begin
-                  datadef:=getarraydef(cansichartype,2);
+                  datadef:=carraydef.getreusable(cansichartype,2);
                   datatcb.maybe_begin_aggregate(datadef);
                   datatcb.maybe_begin_aggregate(datadef);
                   datatcb.emit_tai(Tai_string.Create(char(byte(tordconstnode(node).value.svalue))+#0),datadef);
                   datatcb.emit_tai(Tai_string.Create(char(byte(tordconstnode(node).value.svalue))+#0),datadef);
                   datatcb.maybe_end_aggregate(datadef);
                   datatcb.maybe_end_aggregate(datadef);
@@ -845,7 +845,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
               else
               else
                 begin
                 begin
                   IncompatibleTypes(node.resultdef, def);
                   IncompatibleTypes(node.resultdef, def);
-                  datadef:=getarraydef(cansichartype,1);
+                  datadef:=carraydef.getreusable(cansichartype,1);
                 end;
                 end;
               ftcb.finish_internal_data_builder(datatcb,ll,datadef,varalign);
               ftcb.finish_internal_data_builder(datatcb,ll,datadef,varalign);
               { we now emit the address of the first element of the array
               { we now emit the address of the first element of the array
@@ -876,7 +876,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
                      datatcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_make_dead_strippable]);
                      datatcb:=ctai_typedconstbuilder.create([tcalo_is_lab,tcalo_make_dead_strippable]);
                      pw:=pcompilerwidestring(tstringconstnode(node).value_str);
                      pw:=pcompilerwidestring(tstringconstnode(node).value_str);
                      { include terminating #0 }
                      { include terminating #0 }
-                     datadef:=getarraydef(cwidechartype,tstringconstnode(node).len+1);
+                     datadef:=carraydef.getreusable(cwidechartype,tstringconstnode(node).len+1);
                      datatcb.maybe_begin_aggregate(datadef);
                      datatcb.maybe_begin_aggregate(datadef);
                      for i:=0 to tstringconstnode(node).len-1 do
                      for i:=0 to tstringconstnode(node).len-1 do
                        datatcb.emit_tai(Tai_const.Create_16bit(pw^.data[i]),cwidechartype);
                        datatcb.emit_tai(Tai_const.Create_16bit(pw^.data[i]),cwidechartype);

+ 1 - 1
compiler/paramgr.pas

@@ -621,7 +621,7 @@ implementation
         else if restlen in [1,2,4,8] then
         else if restlen in [1,2,4,8] then
           result:=cgsize_orddef(int_cgsize(restlen))
           result:=cgsize_orddef(int_cgsize(restlen))
         else
         else
-          result:=getarraydef(u8inttype,restlen);
+          result:=carraydef.getreusable(u8inttype,restlen);
       end;
       end;
 
 
 
 

+ 1 - 1
compiler/powerpc/cpupara.pas

@@ -570,7 +570,7 @@ unit cpupara;
                              if paraloc^.size<>OS_NO then
                              if paraloc^.size<>OS_NO then
                                paraloc^.def:=cgsize_orddef(paraloc^.size)
                                paraloc^.def:=cgsize_orddef(paraloc^.size)
                              else
                              else
-                               paraloc^.def:=getarraydef(u8inttype,paralen);
+                               paraloc^.def:=carraydef.getreusable(u8inttype,paralen);
                            end;
                            end;
                          else
                          else
                            internalerror(2006011101);
                            internalerror(2006011101);

+ 34 - 42
compiler/symdef.pas

@@ -490,6 +490,7 @@ interface
           function elecount : asizeuint;
           function elecount : asizeuint;
           constructor create_from_pointer(def:tpointerdef);virtual;
           constructor create_from_pointer(def:tpointerdef);virtual;
           constructor create(l,h:asizeint;def:tdef);virtual;
           constructor create(l,h:asizeint;def:tdef);virtual;
+          class function getreusable(def: tdef; elems: asizeint): tarraydef; virtual;
           constructor ppuload(ppufile:tcompilerppufile);
           constructor ppuload(ppufile:tcompilerppufile);
           destructor destroy; override;
           destructor destroy; override;
           function getcopy : tstoreddef;override;
           function getcopy : tstoreddef;override;
@@ -1125,10 +1126,6 @@ interface
 
 
     function use_vectorfpu(def : tdef) : boolean;
     function use_vectorfpu(def : tdef) : boolean;
 
 
-    { returns an arraydef for an array containing a single array of def, resuing
-      an existing one in case it exists in the current module }
-    function getsingletonarraydef(def: tdef): tarraydef;
-    function getarraydef(def: tdef; elecount: asizeint): tarraydef;
     { returns a procvardef that represents the address of a procdef }
     { returns a procvardef that represents the address of a procdef }
     function getprocaddressprocvar(def: tabstractprocdef): tprocvardef;
     function getprocaddressprocvar(def: tabstractprocdef): tprocvardef;
 
 
@@ -3423,6 +3420,39 @@ implementation
          symtable:=tarraysymtable.create(self);
          symtable:=tarraysymtable.create(self);
       end;
       end;
 
 
+
+    class function tarraydef.getreusable(def: tdef; elems: asizeint): tarraydef;
+      var
+        res: PHashSetItem;
+        oldsymtablestack: tsymtablestack;
+        arrdesc: packed record
+          def: tdef;
+          elecount: asizeint;
+        end;
+      begin
+        if not assigned(current_module) then
+          internalerror(2011081301);
+        arrdesc.def:=def;
+        arrdesc.elecount:=elems;
+        res:=current_module.arraydefs.FindOrAdd(@arrdesc,sizeof(arrdesc));
+        if not assigned(res^.Data) then
+          begin
+            { since these arraydef can be reused anywhere in the current
+              unit, add them to the global/staticsymtable }
+            oldsymtablestack:=symtablestack;
+            symtablestack:=nil;
+            res^.Data:=carraydef.create(0,elems-1,ptrsinttype);
+            tarraydef(res^.Data).elementdef:=def;
+            if assigned(current_module.localsymtable) then
+              current_module.localsymtable.insertdef(tdef(res^.Data))
+            else
+              current_module.globalsymtable.insertdef(tdef(res^.Data));
+            symtablestack:=oldsymtablestack;
+          end;
+        result:=tarraydef(res^.Data);
+      end;
+
+
     destructor tarraydef.destroy;
     destructor tarraydef.destroy;
       begin
       begin
         symtable.free;
         symtable.free;
@@ -7631,44 +7661,6 @@ implementation
       end;
       end;
 
 
 
 
-    function getsingletonarraydef(def: tdef): tarraydef;
-      begin
-        result:=getarraydef(def,1);
-      end;
-
-
-    function getarraydef(def: tdef; elecount: asizeint): tarraydef;
-      var
-        res: PHashSetItem;
-        oldsymtablestack: tsymtablestack;
-        arrdesc: packed record
-          def: tdef;
-          elecount: asizeint;
-        end;
-      begin
-        if not assigned(current_module) then
-          internalerror(2011081301);
-        arrdesc.def:=def;
-        arrdesc.elecount:=elecount;
-        res:=current_module.arraydefs.FindOrAdd(@arrdesc,sizeof(arrdesc));
-        if not assigned(res^.Data) then
-          begin
-            { since these arraydef can be reused anywhere in the current
-              unit, add them to the global/staticsymtable }
-            oldsymtablestack:=symtablestack;
-            symtablestack:=nil;
-            res^.Data:=carraydef.create(0,elecount-1,ptrsinttype);
-            tarraydef(res^.Data).elementdef:=def;
-            if assigned(current_module.localsymtable) then
-              current_module.localsymtable.insertdef(tdef(res^.Data))
-            else
-              current_module.globalsymtable.insertdef(tdef(res^.Data));
-            symtablestack:=oldsymtablestack;
-          end;
-        result:=tarraydef(res^.Data);
-      end;
-
-
     function getprocaddressprocvar(def: tabstractprocdef): tprocvardef;
     function getprocaddressprocvar(def: tabstractprocdef): tprocvardef;
       var
       var
         res: PHashSetItem;
         res: PHashSetItem;

+ 2 - 2
compiler/symsym.pas

@@ -2360,7 +2360,7 @@ implementation
          if assigned(def) then
          if assigned(def) then
            constdef:=def
            constdef:=def
          else
          else
-           constdef:=getarraydef(cansichartype,l);
+           constdef:=carraydef.getreusable(cansichartype,l);
          value.len:=l;
          value.len:=l;
       end;
       end;
 
 
@@ -2371,7 +2371,7 @@ implementation
          fillchar(value, sizeof(value), #0);
          fillchar(value, sizeof(value), #0);
          consttyp:=t;
          consttyp:=t;
          pcompilerwidestring(value.valueptr):=pw;
          pcompilerwidestring(value.valueptr):=pw;
-         constdef:=getarraydef(cwidechartype,getlengthwidestring(pw));
+         constdef:=carraydef.getreusable(cwidechartype,getlengthwidestring(pw));
          value.len:=getlengthwidestring(pw);
          value.len:=getlengthwidestring(pw);
       end;
       end;
 
 

+ 7 - 7
compiler/x86_64/cpupara.pas

@@ -288,7 +288,7 @@ unit cpupara;
         else
         else
           result:=class2;
           result:=class2;
         result.typ:=X86_64_SSE_CLASS;
         result.typ:=X86_64_SSE_CLASS;
-        result.def:=getarraydef(s32floattype,2)
+        result.def:=carraydef.getreusable(s32floattype,2)
       end;
       end;
 
 
 
 
@@ -401,7 +401,7 @@ unit cpupara;
                (classes[i-1].typ<>X86_64_SSEUP_CLASS) then
                (classes[i-1].typ<>X86_64_SSEUP_CLASS) then
               begin
               begin
                 classes[i].typ:=X86_64_SSE_CLASS;
                 classes[i].typ:=X86_64_SSE_CLASS;
-                classes[i].def:=getarraydef(s32floattype,2);
+                classes[i].def:=carraydef.getreusable(s32floattype,2);
               end;
               end;
 
 
             (*  If X86_64_X87UP_CLASS isn't preceded by X86_64_X87_CLASS,
             (*  If X86_64_X87UP_CLASS isn't preceded by X86_64_X87_CLASS,
@@ -443,7 +443,7 @@ unit cpupara;
               X86_64_SSESF_CLASS:
               X86_64_SSESF_CLASS:
                 begin
                 begin
                   classes[0].typ:=X86_64_SSE_CLASS;
                   classes[0].typ:=X86_64_SSE_CLASS;
-                  classes[0].def:=getarraydef(s32floattype,2);
+                  classes[0].def:=carraydef.getreusable(s32floattype,2);
                 end;
                 end;
             end;
             end;
           { 2) the second part is 32 bit, but the total size is > 12 bytes }
           { 2) the second part is 32 bit, but the total size is > 12 bytes }
@@ -457,7 +457,7 @@ unit cpupara;
               X86_64_SSESF_CLASS:
               X86_64_SSESF_CLASS:
                 begin
                 begin
                   classes[1].typ:=X86_64_SSE_CLASS;
                   classes[1].typ:=X86_64_SSE_CLASS;
-                  classes[1].def:=getarraydef(s32floattype,2);
+                  classes[1].def:=carraydef.getreusable(s32floattype,2);
                 end;
                 end;
             end;
             end;
 
 
@@ -613,7 +613,7 @@ unit cpupara;
                         { if we have e.g. a record with two successive "single"
                         { if we have e.g. a record with two successive "single"
                           fields, we need a 64 bit rather than a 32 bit load }
                           fields, we need a 64 bit rather than a 32 bit load }
                         classes[0].typ:=X86_64_SSE_CLASS;
                         classes[0].typ:=X86_64_SSE_CLASS;
-                        classes[0].def:=getarraydef(s32floattype,2);
+                        classes[0].def:=carraydef.getreusable(s32floattype,2);
                       end;
                       end;
                     result:=1;
                     result:=1;
                   end;
                   end;
@@ -639,9 +639,9 @@ unit cpupara;
                 s128real:
                 s128real:
                   begin
                   begin
                     classes[0].typ:=X86_64_SSE_CLASS;
                     classes[0].typ:=X86_64_SSE_CLASS;
-                    classes[0].def:=getarraydef(s32floattype,2);
+                    classes[0].def:=carraydef.getreusable(s32floattype,2);
                     classes[1].typ:=X86_64_SSEUP_CLASS;
                     classes[1].typ:=X86_64_SSEUP_CLASS;
-                    classes[1].def:=getarraydef(s32floattype,2);
+                    classes[1].def:=carraydef.getreusable(s32floattype,2);
                     result:=2;
                     result:=2;
                   end;
                   end;
                 else
                 else