On Wed, Jun 30, 2010 at 11:51:46AM +0200, Paolo Bonzini wrote: > > Now: > > /* A zillion macros like this one: */ [...] > > > After: > > /* Two templates like these: */ > template <class T> static inline void > ggc_mark_all (T *const x) > { > if (x != NULL) ggc_mark_all_1 (x); > } > > template <class T> static inline void > ggc_mark_all_1 (T *const x) > { > gcc_unreachable(); > } > > /* Many specializations like this (generated by gengtype). */ > template <> void > ggc_mark_all_1 (struct eh_catch_d * const x) > { > if (ggc_test_and_set_mark (x)) > { > ggc_mark_all ((*x).next_catch); > ggc_mark_all ((*x).prev_catch); > ggc_mark_all ((*x).type_list); > ggc_mark_all ((*x).filter_list); > ggc_mark_all ((*x).label); > } > } > > /* A single specialization for all std::vectors, whose treatment > is simpler than VECs in gengtype: */ > template <std::vector<T, ggc_allocator> > void > ggc_mark_all_1 (std::vector<T, ggc_allocator> * const x) > { > typedef typename std::vector<T, ggc_allocator> vec_type; > typedef typename vec_type::iterator iterator; > > for (iterator p = x.begin(), q = x.end(); p != q; ++p) > gcc_mark_all (*p); > } > > > Of course it may be too bad for compilation times, it may require > other changes (e.g. to the way roots are enumerated, or because > templates require stuff to be in header files that used to be in > gtype-desc.c), it may not work at all. No idea. :)
Thanks for the nice explanations. Cheers. -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359 8, rue de la Faiencerie, 92340 Bourg La Reine, France *** opinions {are only mines, sont seulement les miennes} ***