2
0
Эх сурвалжийг харах

* free unregistered elements of the localsymtable after a module has been
compiled

git-svn-id: trunk@32160 -

Jonas Maebe 9 жил өмнө
parent
commit
7d5262ef78
1 өөрчлөгдсөн 26 нэмэгдсэн , 0 устгасан
  1. 26 0
      compiler/pmodules.pas

+ 26 - 0
compiler/pmodules.pas

@@ -550,6 +550,30 @@ implementation
       end;
 
 
+    procedure free_unregistered_localsymtable_elements;
+      var
+        i: longint;
+        def: tdef;
+        sym: tsym;
+      begin
+        { from high to low so we hopefully have moves of less data }
+        for i:=current_module.localsymtable.symlist.count-1 downto 0 do
+          begin
+            sym:=tsym(current_module.localsymtable.symlist[i]);
+            { this also frees sym, as the symbols are owned by the symtable }
+            if not sym.is_registered then
+              current_module.localsymtable.Delete(sym);
+          end;
+        for i:=current_module.localsymtable.deflist.count-1 downto 0 do
+          begin
+            def:=tdef(current_module.localsymtable.deflist[i]);
+            { this also frees def, as the defs are owned by the symtable }
+            if not def.is_registered then
+              current_module.localsymtable.deletedef(def);
+          end;
+      end;
+
+
     procedure setupglobalswitches;
       begin
         if (cs_create_pic in current_settings.moduleswitches) then
@@ -1256,6 +1280,8 @@ type
              Message1(unit_u_implementation_crc_changed,current_module.ppufilename);
 {$endif EXTDEBUG}
 
+         { release unregistered defs/syms from the localsymtable }
+         free_unregistered_localsymtable_elements;
          { release local symtables that are not needed anymore }
          free_localsymtables(current_module.globalsymtable);
          free_localsymtables(current_module.localsymtable);