gccint: Type Information

1 
1 23 Memory Management and Type Information
1 *****************************************
1 
1 GCC uses some fairly sophisticated memory management techniques, which
1 involve determining information about GCC's data structures from GCC's
1 source code and using this information to perform garbage collection and
1 implement precompiled headers.
1 
1  A full C++ parser would be too complicated for this task, so a limited
1 subset of C++ is interpreted and special markers are used to determine
1 what parts of the source to look at.  All 'struct', 'union' and
1 'template' structure declarations that define data structures that are
1 allocated under control of the garbage collector must be marked.  All
1 global variables that hold pointers to garbage-collected memory must
1 also be marked.  Finally, all global variables that need to be saved and
1 restored by a precompiled header must be marked.  (The precompiled
1 header mechanism can only save static variables if they're scalar.
1 Complex data structures must be allocated in garbage-collected memory to
1 be saved in a precompiled header.)
1 
1  The full format of a marker is
1      GTY (([OPTION] [(PARAM)], [OPTION] [(PARAM)] ...))
1 but in most cases no options are needed.  The outer double parentheses
1 are still necessary, though: 'GTY(())'.  Markers can appear:
1 
1    * In a structure definition, before the open brace;
1    * In a global variable declaration, after the keyword 'static' or
1      'extern'; and
1    * In a structure field definition, before the name of the field.
1 
1  Here are some examples of marking simple data structures and globals.
1 
1      struct GTY(()) TAG
1      {
1        FIELDS...
1      };
1 
1      typedef struct GTY(()) TAG
1      {
1        FIELDS...
1      } *TYPENAME;
1 
1      static GTY(()) struct TAG *LIST;   /* points to GC memory */
1      static GTY(()) int COUNTER;        /* save counter in a PCH */
1 
1  The parser understands simple typedefs such as 'typedef struct TAG
1 *NAME;' and 'typedef int NAME;'.  These don't need to be marked.
1 
1  Since 'gengtype''s understanding of C++ is limited, there are several
1 constructs and declarations that are not supported inside
1 classes/structures marked for automatic GC code generation.  The
1 following C++ constructs produce a 'gengtype' error on
1 structures/classes marked for automatic GC code generation:
1 
1    * Type definitions inside classes/structures are not supported.
1    * Enumerations inside classes/structures are not supported.
1 
1  If you have a class or structure using any of the above constructs, you
1 need to mark that class as 'GTY ((user))' and provide your own marking
1 routines (see section ⇒User GC for details).
1 
1  It is always valid to include function definitions inside classes.
1 Those are always ignored by 'gengtype', as it only cares about data
1 members.
1 

Menu