Merge "Write DWARF strings inline and remove .debug_str section."
diff --git a/compiler/dwarf/dedup_vector.h b/compiler/dwarf/dedup_vector.h
deleted file mode 100644
index 7fb21b7..0000000
--- a/compiler/dwarf/dedup_vector.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef ART_COMPILER_DWARF_DEDUP_VECTOR_H_
-#define ART_COMPILER_DWARF_DEDUP_VECTOR_H_
-
-#include <vector>
-#include <unordered_map>
-
-namespace art {
-namespace dwarf {
-  class DedupVector {
-   public:
-    // Returns an offset to previously inserted identical block of data,
-    // or appends the data at the end of the vector and returns offset to it.
-    size_t Insert(const uint8_t* ptr, size_t num_bytes) {
-      // See http://en.wikipedia.org/wiki/Fowler%E2%80%93Noll%E2%80%93Vo_hash_function
-      uint32_t hash = 2166136261u;
-      for (size_t i = 0; i < num_bytes; i++) {
-        hash = (hash ^ ptr[i]) * 16777619u;
-      }
-      // Try to find existing copy of the data.
-      const auto& range = hash_to_offset_.equal_range(hash);
-      for (auto it = range.first; it != range.second; ++it) {
-        const size_t offset = it->second;
-        if (offset + num_bytes <= vector_.size() &&
-            memcmp(vector_.data() + offset, ptr, num_bytes) == 0) {
-          return offset;
-        }
-      }
-      // Append the data at the end of the vector.
-      const size_t new_offset = vector_.size();
-      hash_to_offset_.emplace(hash, new_offset);
-      vector_.insert(vector_.end(), ptr, ptr + num_bytes);
-      return new_offset;
-    }
-
-    const std::vector<uint8_t>& Data() const { return vector_; }
-
-   private:
-    struct IdentityHash {
-      size_t operator()(uint32_t v) const { return v; }
-    };
-
-    // We store the full hash as the key to simplify growing of the table.
-    // It avoids storing or referencing the actual data in the hash-table.
-    std::unordered_multimap<uint32_t, size_t, IdentityHash> hash_to_offset_;
-
-    std::vector<uint8_t> vector_;
-  };
-}  // namespace dwarf
-}  // namespace art
-
-#endif  // ART_COMPILER_DWARF_DEDUP_VECTOR_H_
diff --git a/compiler/elf_writer_debug.cc b/compiler/elf_writer_debug.cc
index e1116fd..d1f5007 100644
--- a/compiler/elf_writer_debug.cc
+++ b/compiler/elf_writer_debug.cc
@@ -27,7 +27,6 @@
 #include "compiled_method.h"
 #include "dex_file-inl.h"
 #include "driver/compiler_driver.h"
-#include "dwarf/dedup_vector.h"
 #include "dwarf/expression.h"
 #include "dwarf/headers.h"
 #include "dwarf/method_debug_info.h"
@@ -497,9 +496,9 @@
       const uintptr_t cu_size = compilation_unit.high_pc_ - compilation_unit.low_pc_;
 
       info_.StartTag(DW_TAG_compile_unit);
-      info_.WriteStrp(DW_AT_producer, owner_->WriteString("Android dex2oat"));
+      info_.WriteString(DW_AT_producer, "Android dex2oat");
       info_.WriteData1(DW_AT_language, DW_LANG_Java);
-      info_.WriteStrp(DW_AT_comp_dir, owner_->WriteString("$JAVA_SRC_ROOT"));
+      info_.WriteString(DW_AT_comp_dir, "$JAVA_SRC_ROOT");
       info_.WriteAddr(DW_AT_low_pc, text_address + compilation_unit.low_pc_);
       info_.WriteUdata(DW_AT_high_pc, dchecked_integral_cast<uint32_t>(cu_size));
       info_.WriteSecOffset(DW_AT_stmt_list, compilation_unit.debug_line_offset_);
@@ -630,7 +629,7 @@
 
     void Write(const ArrayRef<mirror::Class*>& types) SHARED_REQUIRES(Locks::mutator_lock_) {
       info_.StartTag(DW_TAG_compile_unit);
-      info_.WriteStrp(DW_AT_producer, owner_->WriteString("Android dex2oat"));
+      info_.WriteString(DW_AT_producer, "Android dex2oat");
       info_.WriteData1(DW_AT_language, DW_LANG_Java);
 
       // Base class references to be patched at the end.
@@ -968,7 +967,7 @@
    private:
     void WriteName(const char* name) {
       if (name != nullptr) {
-        info_.WriteStrp(DW_AT_name, owner_->WriteString(name));
+        info_.WriteString(DW_AT_name, name);
       }
     }
 
@@ -1154,21 +1153,15 @@
     builder_->WritePatches(".debug_info.oat_patches",
                            ArrayRef<const uintptr_t>(debug_info_patches_));
     builder_->WriteSection(".debug_abbrev", &debug_abbrev_buffer_);
-    builder_->WriteSection(".debug_str", &debug_str_.Data());
     builder_->WriteSection(".debug_loc", &debug_loc_);
     builder_->WriteSection(".debug_ranges", &debug_ranges_);
   }
 
  private:
-  size_t WriteString(const char* str) {
-    return debug_str_.Insert(reinterpret_cast<const uint8_t*>(str), strlen(str) + 1);
-  }
-
   ElfBuilder<ElfTypes>* builder_;
   std::vector<uintptr_t> debug_info_patches_;
   std::vector<uint8_t> debug_abbrev_buffer_;
   DebugAbbrevWriter<> debug_abbrev_;
-  DedupVector debug_str_;
   std::vector<uint8_t> debug_loc_;
   std::vector<uint8_t> debug_ranges_;