Move the profiling info out of ArtMethod.
Instead, keep a map in JitCodeCache.
Bug: 112676029
Test: test.py
Change-Id: I5ab769a9b7b3214af7832478d1b06c9e9adbf8b8
diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc
index edc8321..b8f4011 100644
--- a/compiler/optimizing/code_generator_arm64.cc
+++ b/compiler/optimizing/code_generator_arm64.cc
@@ -1141,8 +1141,9 @@
}
if (GetGraph()->IsCompilingBaseline() && !Runtime::Current()->IsAotCompiler()) {
- ScopedObjectAccess soa(Thread::Current());
- ProfilingInfo* info = GetGraph()->GetArtMethod()->GetProfilingInfo(kRuntimePointerSize);
+ ScopedProfilingInfoUse spiu(
+ Runtime::Current()->GetJit(), GetGraph()->GetArtMethod(), Thread::Current());
+ ProfilingInfo* info = spiu.GetProfilingInfo();
if (info != nullptr) {
uint64_t address = reinterpret_cast64<uint64_t>(info);
vixl::aarch64::Label done;
@@ -4289,8 +4290,9 @@
GetGraph()->IsCompilingBaseline() &&
!Runtime::Current()->IsAotCompiler()) {
DCHECK(!instruction->GetEnvironment()->IsFromInlinedInvoke());
- ScopedObjectAccess soa(Thread::Current());
- ProfilingInfo* info = GetGraph()->GetArtMethod()->GetProfilingInfo(kRuntimePointerSize);
+ ScopedProfilingInfoUse spiu(
+ Runtime::Current()->GetJit(), GetGraph()->GetArtMethod(), Thread::Current());
+ ProfilingInfo* info = spiu.GetProfilingInfo();
if (info != nullptr) {
InlineCache* cache = info->GetInlineCache(instruction->GetDexPc());
uint64_t address = reinterpret_cast64<uint64_t>(cache);
diff --git a/compiler/optimizing/code_generator_arm_vixl.cc b/compiler/optimizing/code_generator_arm_vixl.cc
index ccb0609..5c6f835 100644
--- a/compiler/optimizing/code_generator_arm_vixl.cc
+++ b/compiler/optimizing/code_generator_arm_vixl.cc
@@ -2104,8 +2104,9 @@
}
if (GetGraph()->IsCompilingBaseline() && !Runtime::Current()->IsAotCompiler()) {
- ScopedObjectAccess soa(Thread::Current());
- ProfilingInfo* info = GetGraph()->GetArtMethod()->GetProfilingInfo(kRuntimePointerSize);
+ ScopedProfilingInfoUse spiu(
+ Runtime::Current()->GetJit(), GetGraph()->GetArtMethod(), Thread::Current());
+ ProfilingInfo* info = spiu.GetProfilingInfo();
if (info != nullptr) {
uint32_t address = reinterpret_cast32<uint32_t>(info);
vixl::aarch32::Label done;
@@ -3434,8 +3435,9 @@
GetGraph()->IsCompilingBaseline() &&
!Runtime::Current()->IsAotCompiler()) {
DCHECK(!instruction->GetEnvironment()->IsFromInlinedInvoke());
- ScopedObjectAccess soa(Thread::Current());
- ProfilingInfo* info = GetGraph()->GetArtMethod()->GetProfilingInfo(kRuntimePointerSize);
+ ScopedProfilingInfoUse spiu(
+ Runtime::Current()->GetJit(), GetGraph()->GetArtMethod(), Thread::Current());
+ ProfilingInfo* info = spiu.GetProfilingInfo();
if (info != nullptr) {
InlineCache* cache = info->GetInlineCache(instruction->GetDexPc());
uint32_t address = reinterpret_cast32<uint32_t>(cache);
diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc
index 370b839..3adf440 100644
--- a/compiler/optimizing/code_generator_x86.cc
+++ b/compiler/optimizing/code_generator_x86.cc
@@ -1096,8 +1096,9 @@
}
if (GetGraph()->IsCompilingBaseline() && !Runtime::Current()->IsAotCompiler()) {
- ScopedObjectAccess soa(Thread::Current());
- ProfilingInfo* info = GetGraph()->GetArtMethod()->GetProfilingInfo(kRuntimePointerSize);
+ ScopedProfilingInfoUse spiu(
+ Runtime::Current()->GetJit(), GetGraph()->GetArtMethod(), Thread::Current());
+ ProfilingInfo* info = spiu.GetProfilingInfo();
if (info != nullptr) {
uint32_t address = reinterpret_cast32<uint32_t>(info);
NearLabel done;
@@ -2468,8 +2469,9 @@
GetGraph()->IsCompilingBaseline() &&
!Runtime::Current()->IsAotCompiler()) {
DCHECK(!instruction->GetEnvironment()->IsFromInlinedInvoke());
- ScopedObjectAccess soa(Thread::Current());
- ProfilingInfo* info = GetGraph()->GetArtMethod()->GetProfilingInfo(kRuntimePointerSize);
+ ScopedProfilingInfoUse spiu(
+ Runtime::Current()->GetJit(), GetGraph()->GetArtMethod(), Thread::Current());
+ ProfilingInfo* info = spiu.GetProfilingInfo();
if (info != nullptr) {
InlineCache* cache = info->GetInlineCache(instruction->GetDexPc());
uint32_t address = reinterpret_cast32<uint32_t>(cache);
diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc
index b421079..37265ec 100644
--- a/compiler/optimizing/code_generator_x86_64.cc
+++ b/compiler/optimizing/code_generator_x86_64.cc
@@ -1416,8 +1416,9 @@
}
if (GetGraph()->IsCompilingBaseline() && !Runtime::Current()->IsAotCompiler()) {
- ScopedObjectAccess soa(Thread::Current());
- ProfilingInfo* info = GetGraph()->GetArtMethod()->GetProfilingInfo(kRuntimePointerSize);
+ ScopedProfilingInfoUse spiu(
+ Runtime::Current()->GetJit(), GetGraph()->GetArtMethod(), Thread::Current());
+ ProfilingInfo* info = spiu.GetProfilingInfo();
if (info != nullptr) {
uint64_t address = reinterpret_cast64<uint64_t>(info);
NearLabel done;
@@ -2689,8 +2690,9 @@
if (!instruction->GetLocations()->Intrinsified() &&
GetGraph()->IsCompilingBaseline() &&
!Runtime::Current()->IsAotCompiler()) {
- ScopedObjectAccess soa(Thread::Current());
- ProfilingInfo* info = GetGraph()->GetArtMethod()->GetProfilingInfo(kRuntimePointerSize);
+ ScopedProfilingInfoUse spiu(
+ Runtime::Current()->GetJit(), GetGraph()->GetArtMethod(), Thread::Current());
+ ProfilingInfo* info = spiu.GetProfilingInfo();
if (info != nullptr) {
InlineCache* cache = info->GetInlineCache(instruction->GetDexPc());
uint64_t address = reinterpret_cast64<uint64_t>(cache);
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc
index d3a4407..4530f1d 100644
--- a/compiler/optimizing/inliner.cc
+++ b/compiler/optimizing/inliner.cc
@@ -319,33 +319,6 @@
return index;
}
-class ScopedProfilingInfoInlineUse {
- public:
- explicit ScopedProfilingInfoInlineUse(ArtMethod* method, Thread* self)
- : method_(method),
- self_(self),
- // Fetch the profiling info ahead of using it. If it's null when fetching,
- // we should not call JitCodeCache::DoneInlining.
- profiling_info_(
- Runtime::Current()->GetJit()->GetCodeCache()->NotifyCompilerUse(method, self)) {
- }
-
- ~ScopedProfilingInfoInlineUse() {
- if (profiling_info_ != nullptr) {
- PointerSize pointer_size = Runtime::Current()->GetClassLinker()->GetImagePointerSize();
- DCHECK_EQ(profiling_info_, method_->GetProfilingInfo(pointer_size));
- Runtime::Current()->GetJit()->GetCodeCache()->DoneCompilerUse(method_, self_);
- }
- }
-
- ProfilingInfo* GetProfilingInfo() const { return profiling_info_; }
-
- private:
- ArtMethod* const method_;
- Thread* const self_;
- ProfilingInfo* const profiling_info_;
-};
-
HInliner::InlineCacheType HInliner::GetInlineCacheType(
const Handle<mirror::ObjectArray<mirror::Class>>& classes)
REQUIRES_SHARED(Locks::mutator_lock_) {
@@ -678,8 +651,8 @@
ArtMethod* caller = graph_->GetArtMethod();
// Under JIT, we should always know the caller.
DCHECK(caller != nullptr);
- ScopedProfilingInfoInlineUse spiis(caller, Thread::Current());
- ProfilingInfo* profiling_info = spiis.GetProfilingInfo();
+ ScopedProfilingInfoUse spiu(Runtime::Current()->GetJit(), caller, Thread::Current());
+ ProfilingInfo* profiling_info = spiu.GetProfilingInfo();
if (profiling_info == nullptr) {
return kInlineCacheNoData;