reader: Remove useless support for WIP types

Message ID 87blkorfo7.fsf@redhat.com
State Committed
Headers
Series reader: Remove useless support for WIP types |

Commit Message

Dodji Seketeli July 9, 2020, 1:17 p.m. UTC
  Hello,

In the abixml reader, WIP types are tracked to know if a type has been
fully constructed yet or not.  This information is later useful to
know if a given type should be canonicalized right away, or if its
canonicalization should be delayed until the entire abixml file has
been read.

Right now, with all the evolutions that happened in the abixml reader,
only scalar types are canonicalized right away.  All other types are
canonicalized late, meaning, after the entire abixml file is read.
This doesn't have any noticeable performance impact because the volume
of types coming from an abixml file is relatively small enough,
compared to what we can see in a DWARF/ELF binary due to type
duplication.

So the whole WIP tracking becomes is now pretty much useless, in
practise.  So this patch does away with it altogether.

	* src/abg-reader.cc (read_context::m_wip_types_map): Remove data
	member.
	(read_context::{clear_wip_classes_map, mark_type_as_wip,
	unmark_type_as_wip, is_wip_type}): Remove member functions.
	(read_context::maybe_canonicalize_type): Remove use of
	is_wip_type.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>

Applied to master.

---
 src/abg-reader.cc | 67 -------------------------------------------------------
 1 file changed, 67 deletions(-)
  

Patch

diff --git a/src/abg-reader.cc b/src/abg-reader.cc
index ce90aca..e72a5de 100644
--- a/src/abg-reader.cc
+++ b/src/abg-reader.cc
@@ -119,7 +119,6 @@  private:
   unordered_map<string, vector<type_base_sptr> >	m_types_map;
   unordered_map<string, shared_ptr<function_tdecl> >	m_fn_tmpl_map;
   unordered_map<string, shared_ptr<class_tdecl> >	m_class_tmpl_map;
-  unordered_map<string, size_t>			m_wip_types_map;
   vector<type_base_sptr>				m_types_to_canonicalize;
   string_xml_node_map					m_id_xml_node_map;
   xml_node_decl_base_sptr_map				m_xml_node_decl_map;
@@ -518,65 +517,6 @@  public:
   clear_types_to_canonicalize()
   {m_types_to_canonicalize.clear();}
 
-  /// Clean the map of classes that are "Work In Progress"; that is,
-  /// the map of the class that are currently being built, but at not
-  /// yet fully built.
-  void
-  clear_wip_classes_map()
-  {m_wip_types_map.clear();}
-
-  /// Mark a given type as being "Work In Progress"; that is, mark it
-  /// as being currently built.
-  ///
-  /// @param t the class to mark as being "Work In Progress".
-  void
-  mark_type_as_wip(const type_base_sptr t)
-  {
-    if (!t)
-      return;
-    string qname = get_type_name(t, /*qualified=*/true);
-    unordered_map<string, size_t>::iterator it = m_wip_types_map.find(qname);
-    if (it == m_wip_types_map.end())
-      m_wip_types_map[qname] = 1;
-    else
-      ++it->second;
-  }
-
-  /// Mark a given class as being *NOT* "Work In Progress" anymore;
-  /// that is, mark it as being fully built.
-  ///
-  /// @param t the type to mark as being built.
-  void
-  unmark_type_as_wip(const type_base_sptr t)
-  {
-    if (!t)
-      return;
-
-    string qname = get_type_name(t, /*qualified=*/true);
-    unordered_map<string, size_t>::iterator it = m_wip_types_map.find(qname);
-    if (it == m_wip_types_map.end())
-      return;
-    if (it->second)
-      --it->second;
-    if (it->second == 0)
-      m_wip_types_map.erase(it);
-  }
-
-  /// Test if a type is being currently built; that is, if it's "Work
-  /// In Progress".
-  ///
-  /// @param t the type to consider.
-  bool
-  is_wip_type(const type_base_sptr t) const
-  {
-    if (!t)
-      return false;
-
-    string qname = get_type_name(t, /*qualified=*/true);
-    unordered_map<string, size_t>::const_iterator i =
-      m_wip_types_map.find(qname);
-    return i != m_wip_types_map.end();
-  }
 
   /// Test if two types are equal, without comparing them structurally.
   ///
@@ -883,7 +823,6 @@  public:
 	&& !type_has_non_canonicalized_subtype(t)
 	&& !is_class_type(t)
 	&& !is_union_type(t)
-	&& !is_wip_type(t)
 	// Below are types that *must* be canonicalized only after
 	// they are added to their context; but then this function
 	// might be called to early, before they are actually added to
@@ -3818,7 +3757,6 @@  build_function_type(read_context&	ctxt,
 						parms, size, align));
 
   ctxt.get_translation_unit()->bind_function_type_life_time(fn_type);
-  ctxt.mark_type_as_wip(fn_type);
   ctxt.key_type_decl(fn_type, id);
 
   for (xmlNodePtr n = node->children; n ; n = n->next)
@@ -3845,7 +3783,6 @@  build_function_type(read_context&	ctxt,
     }
 
   fn_type->set_parameters(parms);
-  ctxt.unmark_type_as_wip(fn_type);
 
   return fn_type;
 }
@@ -4543,7 +4480,6 @@  build_class_decl(read_context&		ctxt,
   ctxt.push_decl_to_current_scope(decl, add_to_current_scope);
 
   ctxt.map_xml_node_to_decl(node, decl);
-  ctxt.mark_type_as_wip(decl);
   ctxt.key_type_decl(decl, id);
 
   // If this class has a naming typedef, get it and refer to it.
@@ -4767,7 +4703,6 @@  build_class_decl(read_context&		ctxt,
     }
 
   ctxt.pop_scope_or_abort(decl);
-  ctxt.unmark_type_as_wip(decl);
 
   return decl;
 }
@@ -4950,7 +4885,6 @@  build_union_decl(read_context& ctxt,
   ctxt.push_decl_to_current_scope(decl, add_to_current_scope);
 
   ctxt.map_xml_node_to_decl(node, decl);
-  ctxt.mark_type_as_wip(decl);
   ctxt.key_type_decl(decl, id);
 
   for (xmlNodePtr n = node->children; !is_decl_only && n; n = n->next)
@@ -5102,7 +5036,6 @@  build_union_decl(read_context& ctxt,
     }
 
   ctxt.pop_scope_or_abort(decl);
-  ctxt.unmark_type_as_wip(decl);
 
   return decl;
 }