symbol_table: Don't maintain the HT as we're destroying the table.
authorEmma Anholt <emma@anholt.net>
Wed, 12 Apr 2023 18:55:13 +0000 (11:55 -0700)
committerMarge Bot <emma+marge@anholt.net>
Sat, 15 Apr 2023 18:33:25 +0000 (18:33 +0000)
Release Mesa build runtime of
KHR-Single-GL46.arrays_of_arrays_gl.SizedDeclarationsPrimitive -5.05801%
+/- 3.41206% (n=12)

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22451>

src/mesa/program/symbol_table.c

index ccf611a..7df2713 100644 (file)
@@ -296,8 +296,20 @@ _mesa_symbol_table_ctor(void)
 void
 _mesa_symbol_table_dtor(struct _mesa_symbol_table *table)
 {
-   while (table->current_scope != NULL) {
-      _mesa_symbol_table_pop_scope(table);
+   /* Free all the scopes and symbols left in the table.  This is like repeated
+    * _mesa_symbol_table_pop_scope(), but not maintining the hash table as we
+    * blow it all away.
+    */
+   while (table->current_scope) {
+      struct scope_level *scope = table->current_scope;
+      table->current_scope = scope->next;
+
+      while (scope->symbols) {
+         struct symbol *sym = scope->symbols;
+         scope->symbols = sym->next_with_same_scope;
+         free(sym);
+      }
+      free(scope);
    }
 
    _mesa_hash_table_destroy(table->ht, NULL);