A Caching compiler for C
Date
1994
Authors
Koehler, Brian Keith
Journal Title
Journal ISSN
Volume Title
Publisher
Abstract
Conventional C compilers tend to spend a great deal of time processing text contained in header files. Worse yet, the same text may be processed over and over. This occurs when a programmer is either engaged in the repetitive edit-compile-debug cycle or when a massive compilation is performed and the same header files are repeatedly included by several compilation units. One approach to this problem has been to design compilers which use precompiled versions of header files that can be processed much more rapidly than the original source text of the header files. The primary drawback of this strategy is that the meaning of a header file is contextually dependent on where it is included. Since precompiled headers must be generated in advance then, in instances where the current compilation context does not match the context in which the header was precompiled, the source text of the header file must be reprocessed. We present a more general, transparent, adaptive scheme whereby internal representations of header files are generated and reused as actual compilations are carried out. The principal benefit is that context information is taken directly from real compilations and if the context changes then new internal representations can be generated automatically. Our scheme performs at least as well as implementations using precompiled headers, but is more general and completely transparent to the user. It achieves savings of 60% on average in the repetitive case and 40% in the massive case over the conventional compiler from which the compilation server was derived. The improvement comes at the expense of some increased use of memory resources.