summaryrefslogtreecommitdiff
path: root/dex2oat/driver/compiler_driver.cc
diff options
context:
space:
mode:
authorVladimir Marko <vmarko@google.com>2020-12-22 14:36:47 +0000
committerVladimir Marko <vmarko@google.com>2020-12-23 15:46:20 +0000
commit26de89604fdb6f7db3effcf775860f9f0dcd00f0 (patch)
tree2830f9340b2af2c7d5f3919a46a014f20ad04368 /dex2oat/driver/compiler_driver.cc
parentcea158fa671917938562c69c143ac5a8b2a29fc7 (diff)
downloadart-26de89604fdb6f7db3effcf775860f9f0dcd00f0.tar.gz
Use HashMap<> and HashSet<> in dex2oat.
Use HashMap<> instead of std::unordered_map<> in ImageWriter as it is much faster thanks to avoiding individual nodes that need malloc/free. However, for larger value types, such as `NativeObjectRelocation`, this can increase memory usage. Avoid storing individual ArtField relocations to reduce the memory usage and re-hashing time. Rename `pointer_arrays_` to `method_pointer_arrays_` and change it to HashSet<>, removing the unnecessary storage for `Bin`, as it has not been used for fields since https://android-review.googlesource.com/162796 . Avoid double-lookups for insertion CHECK()s by using the result of HashSet<>::insert(). Remove obsolete comments from the HashSet<>::insert() API that have been wrong since https://android-review.googlesource.com/1169846 . Similary, use HashSet<> instead of std::unordered_set<> in CompilerDriver. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: boots. Bug: 175869411 Change-Id: I538c3ac2ce8d7cad69bb14709702ac7ee0af810d
Diffstat (limited to 'dex2oat/driver/compiler_driver.cc')
-rw-r--r--dex2oat/driver/compiler_driver.cc11
1 files changed, 6 insertions, 5 deletions
diff --git a/dex2oat/driver/compiler_driver.cc b/dex2oat/driver/compiler_driver.cc
index b487c4c6ab..a43562a13a 100644
--- a/dex2oat/driver/compiler_driver.cc
+++ b/dex2oat/driver/compiler_driver.cc
@@ -23,7 +23,6 @@
#endif
#include <string_view>
-#include <unordered_set>
#include <vector>
#include "android-base/logging.h"
@@ -36,6 +35,7 @@
#include "base/array_ref.h"
#include "base/bit_vector.h"
#include "base/enums.h"
+#include "base/hash_set.h"
#include "base/logging.h" // For VLOG
#include "base/stl_util.h"
#include "base/string_view_cpp20.h"
@@ -860,6 +860,7 @@ class CreateConflictTablesVisitor : public ClassVisitor {
}
void FillAllIMTAndConflictTables() REQUIRES_SHARED(Locks::mutator_lock_) {
+ ScopedAssertNoThreadSuspension ants(__FUNCTION__);
for (Handle<mirror::Class> c : to_visit_) {
// Create the conflict tables.
FillIMTAndConflictTables(c.Get());
@@ -872,7 +873,7 @@ class CreateConflictTablesVisitor : public ClassVisitor {
if (!klass->ShouldHaveImt()) {
return;
}
- if (visited_classes_.find(klass) != visited_classes_.end()) {
+ if (visited_classes_.find(klass.Ptr()) != visited_classes_.end()) {
return;
}
if (klass->HasSuperClass()) {
@@ -881,12 +882,12 @@ class CreateConflictTablesVisitor : public ClassVisitor {
if (!klass->IsTemp()) {
Runtime::Current()->GetClassLinker()->FillIMTAndConflictTables(klass);
}
- visited_classes_.insert(klass);
+ visited_classes_.insert(klass.Ptr());
}
VariableSizedHandleScope& hs_;
std::vector<Handle<mirror::Class>> to_visit_;
- std::unordered_set<ObjPtr<mirror::Class>, HashObjPtr> visited_classes_;
+ HashSet<mirror::Class*> visited_classes_;
};
void CompilerDriver::PreCompile(jobject class_loader,
@@ -1389,7 +1390,7 @@ class ClinitImageUpdate {
mutable VariableSizedHandleScope hs_;
mutable std::vector<Handle<mirror::Class>> to_insert_;
- mutable std::unordered_set<mirror::Object*> marked_objects_;
+ mutable HashSet<mirror::Object*> marked_objects_;
HashSet<std::string>* const image_class_descriptors_;
std::vector<Handle<mirror::Class>> image_classes_;
Thread* const self_;