summaryrefslogtreecommitdiffstats
path: root/compiler/driver
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2015-04-20 18:53:51 -0700
committerAndreas Gampe <agampe@google.com>2015-04-20 19:51:44 -0700
commitb1fceadbd42b3047a9c06a8af6239c737d67344e (patch)
tree605389efc1479fa58b85481c4c291bc072ba0d78 /compiler/driver
parent4474073ee836d463af29329c86d49354559a41c5 (diff)
downloadart-b1fceadbd42b3047a9c06a8af6239c737d67344e.zip
art-b1fceadbd42b3047a9c06a8af6239c737d67344e.tar.gz
art-b1fceadbd42b3047a9c06a8af6239c737d67344e.tar.bz2
ART: Change image_classes and compiled_classes to unordered set
These lists can be large, and the soon-to-follow compiled_methods will be potentially even larger. Use a hash set instead of a tree set. Change-Id: I7d25c075540f47771354c6f49928b4fd0c76eb2e
Diffstat (limited to 'compiler/driver')
-rw-r--r--compiler/driver/compiler_driver.cc39
-rw-r--r--compiler/driver/compiler_driver.h19
2 files changed, 33 insertions, 25 deletions
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 538d969..1832647 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -76,6 +76,10 @@ static constexpr bool kTimeCompileMethod = !kIsDebugBuild;
// Whether to produce 64-bit ELF files for 64-bit targets. Leave this off for now.
static constexpr bool kProduce64BitELFFiles = false;
+// Whether classes-to-compile is only applied to the boot image, or, when given, too all
+// compilations.
+static constexpr bool kRestrictCompilationFiltersToImage = true;
+
static double Percentage(size_t x, size_t y) {
return 100.0 * (static_cast<double>(x)) / (static_cast<double>(x + y));
}
@@ -343,9 +347,9 @@ CompilerDriver::CompilerDriver(const CompilerOptions* compiler_options,
Compiler::Kind compiler_kind,
InstructionSet instruction_set,
const InstructionSetFeatures* instruction_set_features,
- bool image, std::set<std::string>* image_classes,
- std::set<std::string>* compiled_classes, size_t thread_count,
- bool dump_stats, bool dump_passes,
+ bool image, std::unordered_set<std::string>* image_classes,
+ std::unordered_set<std::string>* compiled_classes,
+ size_t thread_count, bool dump_stats, bool dump_passes,
const std::string& dump_cfg_file_name, CumulativeLogger* timer,
int swap_fd, const std::string& profile_file)
: swap_space_(swap_fd == -1 ? nullptr : new SwapSpace(swap_fd, 10 * MB)),
@@ -656,14 +660,14 @@ bool CompilerDriver::IsImageClass(const char* descriptor) const {
}
bool CompilerDriver::IsClassToCompile(const char* descriptor) const {
- if (!IsImage()) {
+ if (kRestrictCompilationFiltersToImage && !IsImage()) {
+ return true;
+ }
+
+ if (classes_to_compile_ == nullptr) {
return true;
- } else {
- if (classes_to_compile_ == nullptr) {
- return true;
- }
- return classes_to_compile_->find(descriptor) != classes_to_compile_->end();
}
+ return classes_to_compile_->find(descriptor) != classes_to_compile_->end();
}
static void ResolveExceptionsForMethod(MutableHandle<mirror::ArtMethod> method_handle,
@@ -723,7 +727,8 @@ static bool ResolveCatchBlockExceptionsClassVisitor(mirror::Class* c, void* arg)
static bool RecordImageClassesVisitor(mirror::Class* klass, void* arg)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- std::set<std::string>* image_classes = reinterpret_cast<std::set<std::string>*>(arg);
+ std::unordered_set<std::string>* image_classes =
+ reinterpret_cast<std::unordered_set<std::string>*>(arg);
std::string temp;
image_classes->insert(klass->GetDescriptor(&temp));
return true;
@@ -795,7 +800,8 @@ void CompilerDriver::LoadImageClasses(TimingLogger* timings)
CHECK_NE(image_classes_->size(), 0U);
}
-static void MaybeAddToImageClasses(Handle<mirror::Class> c, std::set<std::string>* image_classes)
+static void MaybeAddToImageClasses(Handle<mirror::Class> c,
+ std::unordered_set<std::string>* image_classes)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Thread* self = Thread::Current();
StackHandleScope<1> hs(self);
@@ -804,7 +810,8 @@ static void MaybeAddToImageClasses(Handle<mirror::Class> c, std::set<std::string
std::string temp;
while (!klass->IsObjectClass()) {
const char* descriptor = klass->GetDescriptor(&temp);
- std::pair<std::set<std::string>::iterator, bool> result = image_classes->insert(descriptor);
+ std::pair<std::unordered_set<std::string>::iterator, bool> result =
+ image_classes->insert(descriptor);
if (!result.second) { // Previously inserted.
break;
}
@@ -826,8 +833,8 @@ static void MaybeAddToImageClasses(Handle<mirror::Class> c, std::set<std::string
// Note: we can use object pointers because we suspend all threads.
class ClinitImageUpdate {
public:
- static ClinitImageUpdate* Create(std::set<std::string>* image_class_descriptors, Thread* self,
- ClassLinker* linker, std::string* error_msg) {
+ static ClinitImageUpdate* Create(std::unordered_set<std::string>* image_class_descriptors,
+ Thread* self, ClassLinker* linker, std::string* error_msg) {
std::unique_ptr<ClinitImageUpdate> res(new ClinitImageUpdate(image_class_descriptors, self,
linker));
if (res->art_method_class_ == nullptr) {
@@ -867,7 +874,7 @@ class ClinitImageUpdate {
}
private:
- ClinitImageUpdate(std::set<std::string>* image_class_descriptors, Thread* self,
+ ClinitImageUpdate(std::unordered_set<std::string>* image_class_descriptors, Thread* self,
ClassLinker* linker)
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) :
image_class_descriptors_(image_class_descriptors), self_(self) {
@@ -933,7 +940,7 @@ class ClinitImageUpdate {
}
mutable std::unordered_set<mirror::Object*> marked_objects_;
- std::set<std::string>* const image_class_descriptors_;
+ std::unordered_set<std::string>* const image_class_descriptors_;
std::vector<mirror::Class*> image_classes_;
const mirror::Class* art_method_class_;
const mirror::Class* dex_cache_class_;
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index bd9d7c1..bd4ed06 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -19,6 +19,7 @@
#include <set>
#include <string>
+#include <unordered_set>
#include <vector>
#include "arch/instruction_set.h"
@@ -101,8 +102,8 @@ class CompilerDriver {
Compiler::Kind compiler_kind,
InstructionSet instruction_set,
const InstructionSetFeatures* instruction_set_features,
- bool image, std::set<std::string>* image_classes,
- std::set<std::string>* compiled_classes,
+ bool image, std::unordered_set<std::string>* image_classes,
+ std::unordered_set<std::string>* compiled_classes,
size_t thread_count, bool dump_stats, bool dump_passes,
const std::string& dump_cfg_file_name,
CumulativeLogger* timer, int swap_fd,
@@ -154,7 +155,7 @@ class CompilerDriver {
return image_;
}
- const std::set<std::string>* GetImageClasses() const {
+ const std::unordered_set<std::string>* GetImageClasses() const {
return image_classes_.get();
}
@@ -420,7 +421,7 @@ class CompilerDriver {
// Checks if class specified by type_idx is one of the image_classes_
bool IsImageClass(const char* descriptor) const;
- // Checks if the provided class should be compiled, i.e., is in classes_to_compile_.
+ // Checks whether the provided class should be compiled, i.e., is in classes_to_compile_.
bool IsClassToCompile(const char* descriptor) const;
void RecordClassStatus(ClassReference ref, mirror::Class::Status status)
@@ -585,12 +586,12 @@ class CompilerDriver {
// If image_ is true, specifies the classes that will be included in
// the image. Note if image_classes_ is nullptr, all classes are
// included in the image.
- std::unique_ptr<std::set<std::string>> image_classes_;
+ std::unique_ptr<std::unordered_set<std::string>> image_classes_;
- // If image_ is true, specifies the classes that will be compiled in
- // the image. Note if classes_to_compile_ is nullptr, all classes are
- // included in the image.
- std::unique_ptr<std::set<std::string>> classes_to_compile_;
+ // Specifies the classes that will be compiled. Note that if classes_to_compile_ is nullptr,
+ // all classes are eligible for compilation (duplication filters etc. will still apply).
+ // This option may be restricted to the boot image, depending on a flag in the implementation.
+ std::unique_ptr<std::unordered_set<std::string>> classes_to_compile_;
bool had_hard_verifier_failure_;