(gccint.info.gz) Type Information

Info Catalog (gccint.info.gz) Header Dirs (gccint.info.gz) Top (gccint.info.gz) Funding
 
 22 Memory Management and Type Information
 *****************************************
 
 GCC uses some fairly sophisticated memory management techniques, which
 involve determining information about GCC's data structures from GCC's
 source code and using this information to perform garbage collection and
 implement precompiled headers.
 
  A full C parser would be too complicated for this task, so a limited
 subset of C is interpreted and special markers are used to determine
 what parts of the source to look at.  All `struct' and `union'
 declarations that define data structures that are allocated under
 control of the garbage collector must be marked.  All global variables
 that hold pointers to garbage-collected memory must also be marked.
 Finally, all global variables that need to be saved and restored by a
 precompiled header must be marked.  (The precompiled header mechanism
 can only save static variables if they're scalar.  Complex data
 structures must be allocated in garbage-collected memory to be saved in
 a precompiled header.)
 
  The full format of a marker is
      GTY (([OPTION] [(PARAM)], [OPTION] [(PARAM)] ...))
  but in most cases no options are needed.  The outer double parentheses
 are still necessary, though: `GTY(())'.  Markers can appear:
 
    * In a structure definition, before the open brace;
 
    * In a global variable declaration, after the keyword `static' or
      `extern'; and
 
    * In a structure field definition, before the name of the field.
 
  Here are some examples of marking simple data structures and globals.
 
      struct TAG GTY(())
      {
        FIELDS...
      };
 
      typedef struct TAG GTY(())
      {
        FIELDS...
      } *TYPENAME;
 
      static GTY(()) struct TAG *LIST;   /* points to GC memory */
      static GTY(()) int COUNTER;        /* save counter in a PCH */
 
  The parser understands simple typedefs such as `typedef struct TAG
 *NAME;' and `typedef int NAME;'.  These don't need to be marked.
 

Menu

 
* GTY Options         What goes inside a `GTY(())'.
* GGC Roots           Making global variables GGC roots.
* Files               How the generated files work.
* Invoking the garbage collector   How to invoke the garbage collector.
 
Info Catalog (gccint.info.gz) Header Dirs (gccint.info.gz) Top (gccint.info.gz) Funding
automatically generated by info2html