Stringpool stats. Also make Symbol_table support functions inline.
authorIan Lance Taylor <iant@google.com>
Wed, 5 Dec 2007 00:48:49 +0000 (00:48 +0000)
committerIan Lance Taylor <iant@google.com>
Wed, 5 Dec 2007 00:48:49 +0000 (00:48 +0000)
gold/layout.cc
gold/layout.h
gold/main.cc
gold/stringpool.cc
gold/stringpool.h
gold/symtab.cc

index 39008cd46fe2cfc42560fa31b8006dc522537eab..1139cf1baa38c75a4f11e9d3f6dfa5f8c75d01e9 100644 (file)
@@ -1958,6 +1958,16 @@ Layout::write_sections_after_input_sections(Output_file* of)
   this->section_headers_->write(of);
 }
 
+// Print statistical information to stderr.  This is used for --stats.
+
+void
+Layout::print_stats() const
+{
+  this->namepool_.print_stats("section name pool");
+  this->sympool_.print_stats("output symbol name pool");
+  this->dynpool_.print_stats("dynamic name pool");
+}
+
 // Write_sections_task methods.
 
 // We can always run this task.
index d909acec94baf9125b93775ba599dbb92c30808b..a7908925149cc9dcb24b0ba6bf9896f4107e8dec 100644 (file)
@@ -226,6 +226,10 @@ class Layout
   find_output_segment(elfcpp::PT type, elfcpp::Elf_Word set,
                      elfcpp::Elf_Word clear) const;
 
+  // Dump statistical information to stderr.
+  void
+  print_stats() const;
+
   // The list of segments.
 
   typedef std::vector<Output_segment*> Segment_list;
index fe56aade444a0a2f2ccfd72d617d7fddaaa6500a..921d14808d98c5d1c338f9aee9ffd79957e5b655 100644 (file)
@@ -107,6 +107,7 @@ main(int argc, char** argv)
       fprintf(stderr, _("%s: output file size: %lld bytes\n"),
              program_name, static_cast<long long>(layout.output_file_size()));
       symtab.print_stats();
+      layout.print_stats();
     }
 
   gold_exit(errors.error_count() == 0);
index 39bb9d0c358988a82c22a7d6b72dcb2afea8c438..19698e24c0bf5ab937becf62e15b9986ad6fd793 100644 (file)
@@ -457,6 +457,24 @@ Stringpool_template<Stringpool_char>::write(Output_file* of, off_t offset)
   of->write_output_view(offset, this->strtab_size_, view);
 }
 
+// Print statistical information to stderr.  This is used for --stats.
+
+template<typename Stringpool_char>
+void
+Stringpool_template<Stringpool_char>::print_stats(const char* name) const
+{
+#if defined(HAVE_TR1_UNORDERED_MAP) || defined(HAVE_EXT_HASH_MAP)
+  fprintf(stderr, _("%s: %s entries: %zu; buckets: %zu\n"),
+         program_name, name, this->string_set_.size(),
+         this->string_set_.bucket_count());
+#else
+  fprintf(stderr, _("%s: %s entries: %zu\n"),
+         program_name, name, this->table_.size());
+#endif
+  fprintf(stderr, _("%s: %s Stringdata structures: %zu\n"),
+         program_name, name, this->strings_.size());
+}
+
 // Instantiate the templates we need.
 
 template
index e902b8e4aae5757c77668e59db16f3c70fe71bb3..c5a3baf884bae628b14e39f44a80c64bd1c7f191 100644 (file)
@@ -149,6 +149,10 @@ class Stringpool_template
   void
   write_to_buffer(unsigned char* buffer, size_t buffer_size);
 
+  // Dump statistical information to stderr.
+  void
+  print_stats(const char*) const;
+
  private:
   Stringpool_template(const Stringpool_template&);
   Stringpool_template& operator=(const Stringpool_template&);
index 6094c2af1e08b40bcae0573746220999966f4b5f..40b308090057764f229294feb2e21b277467cc29 100644 (file)
@@ -306,20 +306,18 @@ Symbol_table::~Symbol_table()
 {
 }
 
-// The hash function.  The key is always canonicalized, so we use a
-// simple combination of the pointers.
+// The hash function.  The key values are Stringpool keys.
 
-size_t
+inline size_t
 Symbol_table::Symbol_table_hash::operator()(const Symbol_table_key& key) const
 {
   return key.first ^ key.second;
 }
 
-// The symbol table key equality function.  This is only called with
-// canonicalized name and version strings, so we can use pointer
-// comparison.
+// The symbol table key equality function.  This is called with
+// Stringpool keys.
 
-bool
+inline bool
 Symbol_table::Symbol_table_eq::operator()(const Symbol_table_key& k1,
                                          const Symbol_table_key& k2) const
 {
@@ -1909,6 +1907,7 @@ Symbol_table::print_stats() const
   fprintf(stderr, _("%s: symbol table entries: %zu\n"),
          program_name, this->table_.size());
 #endif
+  this->namepool_.print_stats("symbol table stringpool");
 }
 
 // We check for ODR violations by looking for symbols with the same
This page took 0.123787 seconds and 4 git commands to generate.