Refactor profiles to use TypeReference instead of ClassReference
Refactor type reference into runtime and use it for profiles.
ClassReference was just duplicated code since it wasn't even using
the class def indexes.
Test: test-art-host
Bug: 62040831
Change-Id: Ia92f21c0e85c00321f52c97bb7a90158d882849b
diff --git a/compiler/oat_writer.h b/compiler/oat_writer.h
index e778f75..66b70ad 100644
--- a/compiler/oat_writer.h
+++ b/compiler/oat_writer.h
@@ -31,7 +31,7 @@
#include "os.h"
#include "safe_map.h"
#include "string_reference.h"
-#include "utils/type_reference.h"
+#include "type_reference.h"
namespace art {
diff --git a/compiler/optimizing/code_generator.h b/compiler/optimizing/code_generator.h
index 9ef692a..c2b2ebf 100644
--- a/compiler/optimizing/code_generator.h
+++ b/compiler/optimizing/code_generator.h
@@ -33,8 +33,8 @@
#include "read_barrier_option.h"
#include "stack_map_stream.h"
#include "string_reference.h"
+#include "type_reference.h"
#include "utils/label.h"
-#include "utils/type_reference.h"
namespace art {
diff --git a/compiler/optimizing/code_generator_arm.h b/compiler/optimizing/code_generator_arm.h
index fa1c14d..2409a4d 100644
--- a/compiler/optimizing/code_generator_arm.h
+++ b/compiler/optimizing/code_generator_arm.h
@@ -24,8 +24,8 @@
#include "nodes.h"
#include "string_reference.h"
#include "parallel_move_resolver.h"
+#include "type_reference.h"
#include "utils/arm/assembler_thumb2.h"
-#include "utils/type_reference.h"
namespace art {
namespace arm {
diff --git a/compiler/optimizing/code_generator_arm64.h b/compiler/optimizing/code_generator_arm64.h
index 71e221d..7a4b3d4 100644
--- a/compiler/optimizing/code_generator_arm64.h
+++ b/compiler/optimizing/code_generator_arm64.h
@@ -25,8 +25,8 @@
#include "nodes.h"
#include "parallel_move_resolver.h"
#include "string_reference.h"
+#include "type_reference.h"
#include "utils/arm64/assembler_arm64.h"
-#include "utils/type_reference.h"
// TODO(VIXL): Make VIXL compile with -Wshadow.
#pragma GCC diagnostic push
diff --git a/compiler/optimizing/code_generator_arm_vixl.h b/compiler/optimizing/code_generator_arm_vixl.h
index 91e9a3ed..ef80951 100644
--- a/compiler/optimizing/code_generator_arm_vixl.h
+++ b/compiler/optimizing/code_generator_arm_vixl.h
@@ -24,8 +24,8 @@
#include "nodes.h"
#include "string_reference.h"
#include "parallel_move_resolver.h"
+#include "type_reference.h"
#include "utils/arm/assembler_arm_vixl.h"
-#include "utils/type_reference.h"
// TODO(VIXL): make vixl clean wrt -Wshadow.
#pragma GCC diagnostic push
diff --git a/compiler/optimizing/code_generator_mips.h b/compiler/optimizing/code_generator_mips.h
index ff1fde6..736b507 100644
--- a/compiler/optimizing/code_generator_mips.h
+++ b/compiler/optimizing/code_generator_mips.h
@@ -23,8 +23,8 @@
#include "nodes.h"
#include "parallel_move_resolver.h"
#include "string_reference.h"
+#include "type_reference.h"
#include "utils/mips/assembler_mips.h"
-#include "utils/type_reference.h"
namespace art {
namespace mips {
diff --git a/compiler/optimizing/code_generator_mips64.h b/compiler/optimizing/code_generator_mips64.h
index f49ad49..8405040 100644
--- a/compiler/optimizing/code_generator_mips64.h
+++ b/compiler/optimizing/code_generator_mips64.h
@@ -21,8 +21,8 @@
#include "driver/compiler_options.h"
#include "nodes.h"
#include "parallel_move_resolver.h"
+#include "type_reference.h"
#include "utils/mips64/assembler_mips64.h"
-#include "utils/type_reference.h"
namespace art {
namespace mips64 {
diff --git a/profman/profman.cc b/profman/profman.cc
index 366b4de..e565171 100644
--- a/profman/profman.cc
+++ b/profman/profman.cc
@@ -39,10 +39,11 @@
#include "bytecode_utils.h"
#include "dex_file.h"
#include "jit/profile_compilation_info.h"
+#include "profile_assistant.h"
#include "runtime.h"
+#include "type_reference.h"
#include "utils.h"
#include "zip_archive.h"
-#include "profile_assistant.h"
namespace art {
@@ -560,7 +561,7 @@
// Return true if the definition of the class was found in any of the dex_files.
bool FindClass(const std::vector<std::unique_ptr<const DexFile>>& dex_files,
const std::string& klass_descriptor,
- /*out*/ProfileMethodInfo::ProfileClassReference* class_ref) {
+ /*out*/TypeReference* class_ref) {
for (const std::unique_ptr<const DexFile>& dex_file_ptr : dex_files) {
const DexFile* dex_file = dex_file_ptr.get();
const DexFile::TypeId* type_id = dex_file->FindTypeId(klass_descriptor.c_str());
@@ -580,8 +581,7 @@
}
// Find the method specified by method_spec in the class class_ref.
- uint32_t FindMethodIndex(const ProfileMethodInfo::ProfileClassReference& class_ref,
- const std::string& method_spec) {
+ uint32_t FindMethodIndex(const TypeReference& class_ref, const std::string& method_spec) {
std::vector<std::string> name_and_signature;
Split(method_spec, kProfileParsingFirstCharInSignature, &name_and_signature);
if (name_and_signature.size() != 2) {
@@ -623,7 +623,7 @@
// The format of the method spec is "inlinePolymorphic(LSuper;)I+LSubA;,LSubB;,LSubC;".
//
// TODO(calin): support INVOKE_INTERFACE and the range variants.
- bool HasSingleInvoke(const ProfileMethodInfo::ProfileClassReference& class_ref,
+ bool HasSingleInvoke(const TypeReference& class_ref,
uint16_t method_index,
/*out*/uint32_t* dex_pc) {
const DexFile* dex_file = class_ref.dex_file;
@@ -672,7 +672,7 @@
method_str = line.substr(method_sep_index + kMethodSep.size());
}
- ProfileMethodInfo::ProfileClassReference class_ref;
+ TypeReference class_ref;
if (!FindClass(dex_files, klass, &class_ref)) {
LOG(WARNING) << "Could not find class: " << klass;
return false;
@@ -743,7 +743,7 @@
if (!HasSingleInvoke(class_ref, method_index, &dex_pc)) {
return false;
}
- std::vector<ProfileMethodInfo::ProfileClassReference> classes(inline_cache_elems.size());
+ std::vector<TypeReference> classes(inline_cache_elems.size());
size_t class_it = 0;
for (const std::string& ic_class : inline_cache_elems) {
if (!FindClass(dex_files, ic_class, &(classes[class_it++]))) {
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 5ce5447..a39b7a3 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -1289,7 +1289,7 @@
}
for (size_t i = 0; i < info->number_of_inline_caches_; ++i) {
- std::vector<ProfileMethodInfo::ProfileClassReference> profile_classes;
+ std::vector<TypeReference> profile_classes;
const InlineCache& cache = info->cache_[i];
ArtMethod* caller = info->GetMethod();
bool is_missing_types = false;
diff --git a/runtime/jit/profile_compilation_info.cc b/runtime/jit/profile_compilation_info.cc
index 10ab62f..1e720c0 100644
--- a/runtime/jit/profile_compilation_info.cc
+++ b/runtime/jit/profile_compilation_info.cc
@@ -603,7 +603,7 @@
FindOrAddDexPc(inline_cache, cache.dex_pc)->SetIsMissingTypes();
continue;
}
- for (const ProfileMethodInfo::ProfileClassReference& class_ref : cache.classes) {
+ for (const TypeReference& class_ref : cache.classes) {
DexFileData* class_dex_data = GetOrAddDexFileData(
GetProfileDexFileKey(class_ref.dex_file->GetLocation()),
class_ref.dex_file->GetLocationChecksum());
diff --git a/runtime/jit/profile_compilation_info.h b/runtime/jit/profile_compilation_info.h
index 09f1548..e903e2d 100644
--- a/runtime/jit/profile_compilation_info.h
+++ b/runtime/jit/profile_compilation_info.h
@@ -28,6 +28,7 @@
#include "dex_file_types.h"
#include "method_reference.h"
#include "safe_map.h"
+#include "type_reference.h"
namespace art {
@@ -36,24 +37,15 @@
* without the need to hold GC-able objects.
*/
struct ProfileMethodInfo {
- struct ProfileClassReference {
- ProfileClassReference() : dex_file(nullptr) {}
- ProfileClassReference(const DexFile* dex, const dex::TypeIndex index)
- : dex_file(dex), type_index(index) {}
-
- const DexFile* dex_file;
- dex::TypeIndex type_index;
- };
-
struct ProfileInlineCache {
ProfileInlineCache(uint32_t pc,
bool missing_types,
- const std::vector<ProfileClassReference>& profile_classes)
+ const std::vector<TypeReference>& profile_classes)
: dex_pc(pc), is_missing_types(missing_types), classes(profile_classes) {}
const uint32_t dex_pc;
const bool is_missing_types;
- const std::vector<ProfileClassReference> classes;
+ const std::vector<TypeReference> classes;
};
ProfileMethodInfo(const DexFile* dex, uint32_t method_index)
diff --git a/runtime/jit/profile_compilation_info_test.cc b/runtime/jit/profile_compilation_info_test.cc
index b0fceee..1cfa355 100644
--- a/runtime/jit/profile_compilation_info_test.cc
+++ b/runtime/jit/profile_compilation_info_test.cc
@@ -25,9 +25,10 @@
#include "mirror/class-inl.h"
#include "mirror/class_loader.h"
#include "handle_scope-inl.h"
-#include "linear_alloc.h"
#include "jit/profile_compilation_info.h"
+#include "linear_alloc.h"
#include "scoped_thread_state_change-inl.h"
+#include "type_reference.h"
namespace art {
@@ -123,13 +124,13 @@
std::vector<ProfileMethodInfo::ProfileInlineCache> caches;
// Monomorphic
for (uint16_t dex_pc = 0; dex_pc < 11; dex_pc++) {
- std::vector<ProfileMethodInfo::ProfileClassReference> classes;
+ std::vector<TypeReference> classes;
classes.emplace_back(method->GetDexFile(), dex::TypeIndex(0));
caches.emplace_back(dex_pc, /*is_missing_types*/false, classes);
}
// Polymorphic
for (uint16_t dex_pc = 11; dex_pc < 22; dex_pc++) {
- std::vector<ProfileMethodInfo::ProfileClassReference> classes;
+ std::vector<TypeReference> classes;
for (uint16_t k = 0; k < InlineCache::kIndividualCacheSize / 2; k++) {
classes.emplace_back(method->GetDexFile(), dex::TypeIndex(k));
}
@@ -137,7 +138,7 @@
}
// Megamorphic
for (uint16_t dex_pc = 22; dex_pc < 33; dex_pc++) {
- std::vector<ProfileMethodInfo::ProfileClassReference> classes;
+ std::vector<TypeReference> classes;
for (uint16_t k = 0; k < 2 * InlineCache::kIndividualCacheSize; k++) {
classes.emplace_back(method->GetDexFile(), dex::TypeIndex(k));
}
@@ -145,7 +146,7 @@
}
// Missing types
for (uint16_t dex_pc = 33; dex_pc < 44; dex_pc++) {
- std::vector<ProfileMethodInfo::ProfileClassReference> classes;
+ std::vector<TypeReference> classes;
caches.emplace_back(dex_pc, /*is_missing_types*/true, classes);
}
ProfileMethodInfo pmi(method->GetDexFile(), method->GetDexMethodIndex(), caches);
diff --git a/compiler/utils/type_reference.h b/runtime/type_reference.h
similarity index 85%
rename from compiler/utils/type_reference.h
rename to runtime/type_reference.h
index a0fa1a4..b7e964b 100644
--- a/compiler/utils/type_reference.h
+++ b/runtime/type_reference.h
@@ -14,8 +14,8 @@
* limitations under the License.
*/
-#ifndef ART_COMPILER_UTILS_TYPE_REFERENCE_H_
-#define ART_COMPILER_UTILS_TYPE_REFERENCE_H_
+#ifndef ART_RUNTIME_TYPE_REFERENCE_H_
+#define ART_RUNTIME_TYPE_REFERENCE_H_
#include <stdint.h>
@@ -29,7 +29,9 @@
// A type is located by its DexFile and the string_ids_ table index into that DexFile.
struct TypeReference {
- TypeReference(const DexFile* file, dex::TypeIndex index) : dex_file(file), type_index(index) { }
+ TypeReference(const DexFile* file = nullptr, dex::TypeIndex index = dex::TypeIndex())
+ : dex_file(file),
+ type_index(index) {}
const DexFile* dex_file;
dex::TypeIndex type_index;
@@ -48,4 +50,4 @@
} // namespace art
-#endif // ART_COMPILER_UTILS_TYPE_REFERENCE_H_
+#endif // ART_RUNTIME_TYPE_REFERENCE_H_