mirror of
git://sourceware.org/git/libabigail.git
synced 2025-02-02 14:51:49 +00:00
35162bd4e3
3 Commits
Author | SHA1 | Message | Date | |
---|---|---|---|---|
Dodji Seketeli
|
bc2d2ce660 |
Serialize canonical types to avoid testing if types have been emitted
When emitting abixml, profiling shows that we spend a great deal of time testing if a given type has been emitted already, to avoid emitting a given type more than once. This makes the serialization phase take more time than the binary analysis phase! This patch leverages the fact that we already have the set of canonical types in the system. While emitting that set entirely, we don't need to test if a type has been emitted already because we know by definition that every type is present just once in that set, more or less. OK, because there are also types that don't have canonical types (for instance, declaration-only class/structs), we'll still have to check of those types have already been emitted, but this is a very small set to handle. The patch thus organizes the canonical types per scope, so that when emitting a scope and the canonical types within it, the type is emitted in its correct namespace. Then, when emitting a translation unit and each namespaces in it, the patch emits the canonical types of those namespaces. The patch arranges for some ancillary things that are needed to make the whole picture be coherent enough for things to keep working. Testing shows that we gained ~ 30% of performance by doing this, while analysing the whole linux kernel 5.1 version. We went from ~ 3m30s minutes to less than 2m30s. With this patch, the serialization phase now takes less time than the analysis time. * include/abg-fwd.h (is_decl_slow) (peel_pointer_or_reference_type): Declare new functions. * include/abg-ir.h (struct canonical_type_hash): Define new type. (type_base_ptr_set_type, type_base_ptrs_type) (type_base_sptrs_type, canonical_type_sptr_set_type): Define new typedefs. (environment::get_canonical_types_map): Declare new member function. (scope_decl::{get_canonical_types, get_sorted_canonical_types}): Declare new member functions. * src/abg-ir.cc (is_ptr_ref_or_qual_type) (peel_pointer_or_reference_type, is_decl_slow): Define new functions. (environment::{get_canonical_types_map}): Define new member functions. (canonical_type_hash::operator()): Likewise. (scope_decl::{get_canonical_types, get_sorted_canonical_types}): Likewise. (struct type_topo_comp): Define new comparison functor type. (environment::{sorted_canonical_types_}): Define new data member. (scope_decl::priv::{canonical_types_, sorted_canonical_types_}): Likewise. (scope_decl::is_empty): Take the presence of canonical types into account when determining if a scope is empty or not. (is_decl): Make this work for cases where the artifact at hand is a type which has a declaration, as opposed to being a pure declaration like a variable or a function. (canonicalize): Add the canonical type the list of canonical types of its scope. * src/abg-dwarf-reader.cc (read_context::die_is_in_cplus_plus): Define new member function. * src/abg-writer.cc (write_type, write_canonical_types_of_scope): Define new static functions. (fn_type_ptr_set_type): Define new typedef. (write_context::{m_referenced_fn_types_set, m_referenced_non_canonical_types_set}): Add new data members. (write_context::m_referenced_types_set): Renamed m_referenced_types_map into this. (write_context::get_referenced_types): Adjust. (write_context::get_referenced_{function_types, non_canonical_types}): (write_context::record_type_as_referenced): Adjust to add the referenced type in the proper set which would be one of the three following: write_context::{get_referenced_types, get_referenced_function_types, get_referenced_non_canonical_types}. (write_context::{type_is_referenced, clear_referenced}): Adjust. (write_translation_unit): Use the new write_canonical_types_of_scope. Also emit declaration-only classes that have member types. Do not test if a given type of a given scope has been emitted, in general, as this was super slow given the number of types. Emit referenced function types (as these don't belong to any scope). Rather than using the expensive "is_function_type" on *all* the referenced types, just walk the set write_context::get_referenced_function_types. Likewise, rather than using type_base::get_naked_canonical_type on *all* the referenced types, just walk the set write_context::get_referenced_non_canonical_types (write_class): Use write_canonical_types_of_scope here. * tools/abilint.cc (main): Support linting corpus group abixml files. * tests/data/test-annotate/libtest23.so.abi: Adjust. * tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Likewise. * tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise. * tests/data/test-annotate/test-anonymous-members-0.o.abi: Likewise. * tests/data/test-annotate/test0.abi: Likewise. * tests/data/test-annotate/test1.abi: Likewise. * tests/data/test-annotate/test13-pr18894.so.abi: Likewise. * tests/data/test-annotate/test14-pr18893.so.abi: Likewise. * tests/data/test-annotate/test15-pr18892.so.abi: Likewise. * tests/data/test-annotate/test17-pr19027.so.abi: Likewise. * tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Likewise. * tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise. * tests/data/test-annotate/test2.so.abi: Likewise. * tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise. * tests/data/test-annotate/test21-pr19092.so.abi: Likewise. * tests/data/test-annotate/test4.so.abi: Likewise. * tests/data/test-annotate/test6.so.abi: Likewise. * tests/data/test-annotate/test7.so.abi: Likewise. * tests/data/test-annotate/test8-qualified-this-pointer.so.abi: Likewise. * tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi: Likewise. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise. * tests/data/test-read-dwarf/PR24378-fn-is-not-scope.abi: Likewise. * tests/data/test-read-dwarf/libtest23.so.abi: Likewise. * tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi: Likewise. * tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise. * tests/data/test-read-dwarf/test0.abi: Likewise. * tests/data/test-read-dwarf/test1.abi: Likewise. * tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise. * tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise. * tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise. * tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise. * tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise. * tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise. * tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise. * tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise. * tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi: Likewise. * tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise. * tests/data/test-read-dwarf/test2.so.abi: Likewise. * tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.so.abi: Likewise. * tests/data/test-read-dwarf/test21-pr19092.so.abi: Likewise. * tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Likewise. * tests/data/test-read-dwarf/test4.so.abi: Likewise. * tests/data/test-read-dwarf/test6.so.abi: Likewise. * tests/data/test-read-dwarf/test7.so.abi: Likewise. * tests/data/test-read-dwarf/test8-qualified-this-pointer.so.abi: Likewise. * tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise. * tests/data/test-read-write/test10.xml: Likewise. * tests/data/test-read-write/test14.xml: Likewise. * tests/data/test-read-write/test15.xml: Likewise. * tests/data/test-read-write/test17.xml: Likewise. * tests/data/test-read-write/test18.xml: Likewise. * tests/data/test-read-write/test19.xml: Likewise. * tests/data/test-read-write/test2.xml: Likewise. * tests/data/test-read-write/test20.xml: Likewise. * tests/data/test-read-write/test21.xml: Likewise. * tests/data/test-read-write/test22.xml: Likewise. * tests/data/test-read-write/test23.xml: Likewise. * tests/data/test-read-write/test24.xml: Likewise. * tests/data/test-read-write/test25.xml: Likewise. * tests/data/test-read-write/test26.xml: Likewise. * tests/data/test-read-write/test27.xml: Likewise. * tests/data/test-read-write/test28-without-std-fns-ref.xml: Likewise. * tests/data/test-read-write/test28-without-std-vars-ref.xml: Likewise. * tests/data/test-read-write/test3.xml: Likewise. * tests/data/test-read-write/test6.xml: Likewise. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
2c9fb3e70d |
Support new 'abi-corpus' native XML format (.abi)
* include/abg-reader.h (read_corpus_from_native_xml) (read_corpus_from_native_xml_file): Declare new entry points. * include/abg-writer.h (write_corpus_to_native_xml) (write_corpus_to_native_xml_file): Likewise. * src/abg-reader.cc (read_translation_unit_from_input): Renamed read_input into this. Support new 'path' attribute for 'abi-instr' XML element. (read_corpus_from_input): New static function. (read_translation_unit_from_file) (read_translation_unit_from_buffer) (read_translation_unit_from_istream): Update wrt read_input -> read_translation_unit_from_input. (read_corpus_from_native_xml, read_corpus_from_native_xml) (read_corpus_from_native_xml_file): Define new entry points. * src/abg-writer.cc (write_translation_unit): Write 'path' attribute into the 'abi-instr' xml element. (write_corpus_to_native_xml, write_corpus_to_native_xml_file): Define new entry points. * tools/abg-tools-utils.h (file_type::{FILE_TYPE_XML_CORPUS, FILE_TYPE_ZIP_CORPUS}): New enumerators. * tools/abg-tools-utils.cc (guess_file_type): Support detection of the new xml file format containing a document root 'abi-corpus' root element. * tools/bidiff.cc (main): Support diffing xml corpus-es and zip corpus-es. * tools/bidw.cc (main): Recognize elf files before reading them. * tools/bilint.cc (main): Support reading xml/zip corpus-es too. * tests/data/test-read-write/test[0-23].xml: Update 'path' attribute. Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
Dodji Seketeli
|
57d8b7da41 |
Support qualified types & Misc ancillary fixes
* src/abg-ir.h (struct type_base_hash, struct dynamic_type_hash) (struct type_shared_ptr_hash, struct scope_type_decl_hash, class qualified_type_def, struct qualified_type_def_hash): New. (decl_base_hash::operator()): Constify. Don't crash if the scope of the decl we are hashing is null. (class type_decl): Add comment at the end. (type_decl_hash::operator()): Constify. Reuse the new type_base_hash hasher. (class namespace_decl): Add comment. * src/abg-ir.cc (qualified_type_def::qualified_type_def) (qualified_type_def::~qualified_type_def) (qualified_type_def::get_cv_quals) (qualified_type_def::set_cv_quals) (qualified_type_def::get_underlying_type) (dynamic_type_hash::operator()): New function definitions. * src/abg-reader.cc (handle_qualified_type_decl): New. (read_file): Handle elements named "qualified-type-def". (read::context::add_type_decl): Assert that the type being associated to the unique ID is non-null. (handle_type_decl): Fix this in the process; don't crash if some attributes are not present. Associate the unique id present in the xml document with the type we just parsed. (handle_namespace_decl): Add some comments. Don't crash if the name attribute is not present. * src/abg-writer.cc (write_context::get_id_for_type) (write_context::m_type_id_map, write_decl_location) (write_qualified_type_def): New. (write_decl): Handle instances of qualified_type_def. (write_type_decl): Use the new write_decl_location and write_context::get_id_for_type. * tests/data/test-read-write/test0.xml: Update id format since we are now using the new write_context::get_id_for_type to generate it. * tests/data/test-read-write/test1.xml: Likewise. * tests/data/test-read-write/test2.xml: Likewise. * tests/data/test-read-write/test3.xml: New test. * tests/test-read-write.cc: Test De-serializing tests/data/test-read-write/test3.xml and serializing it back. Also don't bail out if we fail on one input. * tests/Makefile.am: Add tests/data/test-read-write/test3.xml to the distribution. |