On Tue, Nov 22, 2011 at 12:10 AM, Dave Martin dave.martin@linaro.org wrote:
Defining a macro seems to eat up about half a megabyte of memory, due to the excessively large size of the macro arguments hash table (large enough for 65537 entries by default).
Hi Dave. Just bikshedding responses from me, but that's better than nothing.
As a result, gas memory consumption becomes rather huge when a modestly large number (hundreds) of macros are defined.
In fact, it appears to make little sense to force the size of macro argument hash tables to be the same as the size of other hash tables, since the typical number of macro arguments is very small compared with the number of opcodes, macros or symbols; and because the number of macros is not limited to a small constant number.
This patch uses a smaller default size for the macro argument hash tables (43) which should be enough for virtually everyone. hash_new_sized () is exported from hash.c in order to allow hash tables of multiple sizes to be created.
What's the most arguments you've seen in real code? Does recursion or nesting of macros ever blow out this number?
A new argument, --macro-args is added to allow this number to be customised.
I don't like this. The default should be high enough that no one ever needs the argument.
These numbers are deliberately conservative -- they could perhaps be reduced further.
Caveats:
* I'm not a hash table expert, so the exact size values I've chosen may not be optimal.
Does it matter? Is the hash table checked often, or is it just used as a convenient name/value container?