Next: , Previous: Plugins pass, Up: Plugins


23.4 Interacting with the GCC Garbage Collector

Some plugins may want to be informed when GGC (the GCC Garbage Collector) is running. They can register callbacks for the PLUGIN_GGC_START and PLUGIN_GGC_END events (for which the callback is called with a null gcc_data) to be notified of the start or end of the GCC garbage collection.

Some plugins may need to have GGC mark additional data. This can be done by registering a callback (called with a null gcc_data) for the PLUGIN_GGC_MARKING event. Such callbacks can call the ggc_set_mark routine, preferably through the ggc_mark macro (and conversely, these routines should usually not be used in plugins outside of the PLUGIN_GGC_MARKING event).

Some plugins may need to add extra GGC root tables, e.g. to handle their own GTY-ed data. This can be done with the PLUGIN_REGISTER_GGC_ROOTS pseudo-event with a null callback and the extra root table (of type struct ggc_root_tab*) as user_data. Plugins that want to use the if_marked hash table option can add the extra GGC cache tables generated by gengtype using the PLUGIN_REGISTER_GGC_CACHES pseudo-event with a null callback and the extra cache table (of type struct ggc_cache_tab*) as user_data. Running the gengtype -p source-dir file-list plugin*.c ... utility generates these extra root tables.

You should understand the details of memory management inside GCC before using PLUGIN_GGC_MARKING, PLUGIN_REGISTER_GGC_ROOTS or PLUGIN_REGISTER_GGC_CACHES.