Currently when a module is imported by the compiler, the source must be
re-parsed. Instead, we should serialize the AST and store it as metadata in the
bitcode file, so that it can be read by the compiler. The metadata need not
contain the entire AST, only enough to get type information for the compiled
symbols in the module. (In the case of templates, however, the entire AST will
need to be stored in order for the compiler to instantiate the template.)
The serialization format should have it's own set of enums for various node
types, so that if new node types are added to the compiler it won't break
compatibility with older bitcode files. An open question is how much type
information should be stored - that is, should the serialized data contain only
names and symbols (like an AST) and have the compiler re-generate the type
information from that, or should the serialized form be a fully-annotated
expression tree. This is less work for the compiler to read in, but won't work
for templates since template parameter types are unknown until the template is
instantiated.
The compiler should be able to load bitcode files containing single modules, or
a library bitcode file containing many modules. If the compiler has information
about the source files from which the bitcode file was compiled, it should be
able to choose whichever of the two is more recent; Otherwise, it should be
able to use the bitcode file without source if there is none.
Original issue reported on code.google.com by viri...@gmail.com on 1 Mar 2011 at 8:59
Original issue reported on code.google.com by
viri...@gmail.com
on 1 Mar 2011 at 8:59