summaryrefslogtreecommitdiff
path: root/runtime/jit/jit_code_cache.cc
diff options
context:
space:
mode:
author Almaz Mingaleev <mingaleev@google.com> 2024-05-30 15:42:20 +0000
committer Almaz Mingaleev <mingaleev@google.com> 2024-06-21 15:16:44 +0000
commitd92a43f4310e2d634d6e8f24103fc1e27557d784 (patch)
tree7994a8b199c76327544ee4623aeab93bcca6a916 /runtime/jit/jit_code_cache.cc
parentfc87179fb4998acdc32b3d326c101638e45b7211 (diff)
Revert^2 "x86_64: Add JIT support for LoadMethodType."
This reverts commit 69c9ea4f93a688ff50e08060be37bcfd3f3e9910. Instead of storing reversed method_code_map_, now just keep MethodType-s associated with a compiled code. Increasing constant in 979/Main.java to trigger jit more reliably. Bug: 297147201 Test: CtsPerfettoTestCases Test: ./art/test/testrunner/testrunner.py --host --64 --jit -b Test: ./art/test/testrunner/testrunner.py --host --64 -b Test: ./art/test.py --host -b Change-Id: I5ece80b63cd0d6dac2805c94649726dc62fe85db
Diffstat (limited to 'runtime/jit/jit_code_cache.cc')
-rw-r--r--runtime/jit/jit_code_cache.cc42
1 files changed, 41 insertions, 1 deletions
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 4b69dc5c01..5f0bb4e719 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -50,6 +50,7 @@
#include "jit/profiling_info.h"
#include "jit/jit_scoped_code_cache_write.h"
#include "linear_alloc.h"
+#include "mirror/method_type.h"
#include "oat/oat_file-inl.h"
#include "oat/oat_quick_method_header.h"
#include "object_callbacks.h"
@@ -59,6 +60,7 @@
#include "thread-current-inl.h"
#include "thread-inl.h"
#include "thread_list.h"
+#include "well_known_classes-inl.h"
namespace art HIDDEN {
namespace jit {
@@ -436,16 +438,30 @@ void JitCodeCache::SweepRootTables(IsMarkedVisitor* visitor) {
if (new_object != object) {
roots[i] = GcRoot<mirror::Object>(new_object);
}
- } else {
+ } else if (object->IsClass<kDefaultVerifyFlags>()) {
mirror::Object* new_klass = visitor->IsMarked(object);
if (new_klass == nullptr) {
roots[i] = GcRoot<mirror::Object>(Runtime::GetWeakClassSentinel());
} else if (new_klass != object) {
roots[i] = GcRoot<mirror::Object>(new_klass);
}
+ } else {
+ mirror::Object* new_method_type = visitor->IsMarked(object);
+
+ // The MethodType have been visited during VisitConcurrentRoots, so they must be live.
+ DCHECK_NE(new_method_type, nullptr) << "old-method-type" << object;
+ ObjPtr<mirror::Class> method_type_class =
+ WellKnownClasses::java_lang_invoke_MethodType.Get<kWithoutReadBarrier>();
+ DCHECK_EQ((new_method_type->GetClass<kVerifyNone, kWithoutReadBarrier>()),
+ method_type_class.Ptr());
+
+ if (new_method_type != object) {
+ roots[i] = GcRoot<mirror::Object>(new_method_type);
+ }
}
}
}
+
// Walk over inline caches to clear entries containing unloaded classes.
for (const auto& [_, info] : profiling_infos_) {
InlineCache* caches = info->GetInlineCaches();
@@ -567,6 +583,7 @@ void JitCodeCache::RemoveMethodsIn(Thread* self, const LinearAlloc& alloc) {
if (alloc.ContainsUnsafe(it->second)) {
method_headers.insert(OatQuickMethodHeader::FromCodePointer(it->first));
VLOG(jit) << "JIT removed " << it->second->PrettyMethod() << ": " << it->first;
+ method_types_map_.erase(it->first);
zombie_code_.erase(it->first);
processed_zombie_code_.erase(it->first);
it = method_code_map_.erase(it);
@@ -755,6 +772,27 @@ bool JitCodeCache::Commit(Thread* self,
} else {
ScopedDebugDisallowReadBarriers sddrb(self);
method_code_map_.Put(code_ptr, method);
+
+ // Searching for MethodType-s in roots. They need to be treated as strongly reachable while
+ // the corresponding compiled code is not removed.
+ ObjPtr<mirror::Class> method_type_class =
+ WellKnownClasses::java_lang_invoke_MethodType.Get<kWithoutReadBarrier>();
+
+ auto method_types_in_roots = std::vector<GcRoot<mirror::MethodType>>();
+
+ for (auto root : roots) {
+ ObjPtr<mirror::Class> klass = root->GetClass<kDefaultVerifyFlags, kWithoutReadBarrier>();
+ if (klass == method_type_class ||
+ klass == ReadBarrier::IsMarked(method_type_class.Ptr()) ||
+ ReadBarrier::IsMarked(klass.Ptr()) == method_type_class) {
+ ObjPtr<mirror::MethodType> mt = ObjPtr<mirror::MethodType>::DownCast(root.Get());
+ method_types_in_roots.emplace_back(GcRoot(mt));
+ }
+ }
+
+ if (!method_types_in_roots.empty()) {
+ method_types_map_.Put(code_ptr, method_types_in_roots);
+ }
}
if (compilation_kind == CompilationKind::kOsr) {
ScopedDebugDisallowReadBarriers sddrb(self);
@@ -854,6 +892,7 @@ bool JitCodeCache::RemoveMethodLocked(ArtMethod* method, bool release_memory) {
FreeCodeAndData(it->first);
}
VLOG(jit) << "JIT removed " << it->second->PrettyMethod() << ": " << it->first;
+ method_types_map_.erase(it->first);
it = method_code_map_.erase(it);
} else {
++it;
@@ -1108,6 +1147,7 @@ void JitCodeCache::RemoveUnmarkedCode(Thread* self) {
} else {
OatQuickMethodHeader* header = OatQuickMethodHeader::FromCodePointer(code_ptr);
method_headers.insert(header);
+ method_types_map_.erase(header->GetCode());
method_code_map_.erase(header->GetCode());
VLOG(jit) << "JIT removed " << *it;
it = processed_zombie_code_.erase(it);