constify is_class_type()
authorDodji Seketeli <dodji@redhat.com>
Fri, 2 Oct 2015 18:08:27 +0000 (20:08 +0200)
committerDodji Seketeli <dodji@redhat.com>
Sun, 4 Oct 2015 11:40:51 +0000 (13:40 +0200)
This the first patch of a series of 11 patches which aims at speeding
up the time taken by "abidw --noout libmozjs.so".  That shared library
is built among by the mongodb project, among others.  And abidw is
taking around 5 minutes on my old Lenovo X220 laptop.  After the
series of patches, the same command is taking one minute and a half.

The core of the optimization is to speed up type canonicalization that
happens at the end of DWARF reading, once libabigail has built the IR
or the ABI of the entire elf binary.  The optimization comes from an
insight derived from the One Definition Rule of C++, as explained at
https://en.wikipedia.org/wiki/One_Definition_Rule.

But before being able to perform that optimization, several fixes and
code massaging were necessary.  I have split those changes up in the
first 10 patches of the series.  The last patch thus contains the crux
of the optimization.  Its cover letter also contains instructions on
how to build libmozjs.so, from mongodb, for those who want to
replicate the results I have seen.

Note that some of the first 10 patches incur adjustment in the test
suite, but don't carry those necessary adjustments.  All test suite
adjustments are carried by the last, 11Th patch.

The short description of the patches of the series are:

    constify is_class_type()
    Add missing deep equality operator for pointer and reference types
    Cleanup some IR type comparison operators
    Do not overly canonicalize types during typedef stripping
    Fix detection of changes in pointer diff in the comparison engine
    Prevent build_function_type from not canonicalizing certain types
    Do not use recursive type hashing when writing out function types
    Try harder to hash_type_or_decl avoid the slow path
    Fix infinite loop in peel_typedef_pointer_or_reference_type
    Late canonicalize all types that reference classes when reading DWARF
    Use the ODR to speed up type canonicalization

And below is the ChangeLog of this first patch.

* include/abg-fwd.h (is_class_type): Take a pointer to const.
* src/abg-ir.cc (is_class_type): Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
include/abg-fwd.h
src/abg-ir.cc

index 3613e19..50db61a 100644 (file)
@@ -224,10 +224,10 @@ shared_ptr<enum_type_decl>
 is_enum_type(const shared_ptr<decl_base>&);
 
 class_decl*
-is_class_type(decl_base*);
+is_class_type(const decl_base*);
 
 class_decl*
-is_class_type(type_base*);
+is_class_type(const type_base*);
 
 shared_ptr<class_decl>
 is_class_type(const shared_ptr<type_base>);
index fc846d7..f58b54c 100644 (file)
@@ -4603,8 +4603,8 @@ is_compatible_with_class_type(const decl_base_sptr t)
 ///
 /// @return the class_decl if @p t is a class_decl or null otherwise.
 class_decl*
-is_class_type(type_base* t)
-{return dynamic_cast<class_decl*>(t);}
+is_class_type(const type_base* t)
+{return dynamic_cast<class_decl*>(const_cast<type_base*>(t));}
 
 /// Test whether a type is a class.
 ///
@@ -4627,8 +4627,8 @@ is_class_type(const type_base_sptr t)
 ///
 /// @return the class_decl if @p t is a class_decl or null otherwise.
 class_decl*
-is_class_type(decl_base *d)
-{return dynamic_cast<class_decl*>(d);}
+is_class_type(const decl_base *d)
+{return dynamic_cast<class_decl*>(const_cast<decl_base*>(d));}
 
 /// Test whether a type is a class.
 ///