On 30/03/2005, at 10:36 PM, Per Bothner wrote:
* Note that we compile the gch file as it were the main file - i.e. it has the MAIN_FILE_P property, and it is not included from any file. This means the restored line_table is slightly anomalous. One solution to this is when we generate the gch file, we pretend the .h file is included in a dummy file, which we may call <main>. This adds two line_map entries: one for <main> before the LC_ENTER of the .h file, and one at the end to LC_LEAVE the .h file. Then when we restore, we patch both of these to replace "<main>" by the real main file name.
This is PR 9471, and your solution sounds like a good one.
* Any source_location values handed out before the #include that restores the gch will become invalid. They will be re-mapped to that in the pre-compiled header. Presumably that's ok - there's no declartions or expressions in the main file at that point, or the restore would have failed. Any declarations that are <builtin> or in the <command line> will presumably be the same either way.
Another way of putting this is that source_location values should be in GCed memory. I think they all are, certainly all declarations and macro definitions are.
* Presumably we need custom code to save and restore the line-map. Zack experimented with having the entire line_table we gc-allocated, and thus making using of the GTY machinery. This addes an extra indirection for each access to the line_table (probably not a big deal - cpplib accesses are via the cpp_reader and thus unchanged). But note we still need custom restore code.
Custom restore code is problematic because it means doing something at PCH restore time, and so it's always speed-critical. Changing two pointers is not too expensive (especially if you can arrange for those pointers to be on the same page), but copying a data structure (especially a large one) is not a good idea.
You may be able to avoid even changing the two pointers, by pointing them at a static variable (a char array) and marking them as "skip". If you do that they'll continue to point to the static variable after the PCH is loaded, and you can just change the static variable. (You can get away with this because they are char *.)
smime.p7s
Description: S/MIME cryptographic signature