summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--runtime/gc/collector_type.h2
-rw-r--r--runtime/gc/gc_cause.cc1
-rw-r--r--runtime/gc/gc_cause.h2
-rw-r--r--runtime/gc/heap.cc3
-rw-r--r--runtime/jit/jit_code_cache.cc4
-rw-r--r--runtime/jit/jit_code_cache.h3
6 files changed, 12 insertions, 3 deletions
diff --git a/runtime/gc/collector_type.h b/runtime/gc/collector_type.h
index c6020818ec..7899a7c310 100644
--- a/runtime/gc/collector_type.h
+++ b/runtime/gc/collector_type.h
@@ -51,6 +51,8 @@ enum CollectorType {
kCollectorTypeHomogeneousSpaceCompact,
// Class linker fake collector.
kCollectorTypeClassLinker,
+ // JIT Code cache fake collector.
+ kCollectorTypeJitCodeCache,
};
std::ostream& operator<<(std::ostream& os, const CollectorType& collector_type);
diff --git a/runtime/gc/gc_cause.cc b/runtime/gc/gc_cause.cc
index ad9bb92b17..1d377a4fbc 100644
--- a/runtime/gc/gc_cause.cc
+++ b/runtime/gc/gc_cause.cc
@@ -37,6 +37,7 @@ const char* PrettyCause(GcCause cause) {
case kGcCauseAddRemoveAppImageSpace: return "AddRemoveAppImageSpace";
case kGcCauseDebugger: return "Debugger";
case kGcCauseClassLinker: return "ClassLinker";
+ case kGcCauseJitCodeCache: return "JitCodeCache";
default:
LOG(FATAL) << "Unreachable";
UNREACHABLE();
diff --git a/runtime/gc/gc_cause.h b/runtime/gc/gc_cause.h
index 797ec3435e..4348a411a1 100644
--- a/runtime/gc/gc_cause.h
+++ b/runtime/gc/gc_cause.h
@@ -49,6 +49,8 @@ enum GcCause {
kGcCauseHomogeneousSpaceCompact,
// Class linker cause, used to guard filling art methods with special values.
kGcCauseClassLinker,
+ // Not a real GC cause, used to implement exclusion between code cache metadata and GC.
+ kGcCauseJitCodeCache,
};
const char* PrettyCause(GcCause cause);
diff --git a/runtime/gc/heap.cc b/runtime/gc/heap.cc
index 74e6c3cf31..a92cb2496c 100644
--- a/runtime/gc/heap.cc
+++ b/runtime/gc/heap.cc
@@ -2720,7 +2720,8 @@ collector::GcType Heap::CollectGarbageInternal(collector::GcType gc_type,
}
// It's time to clear all inline caches, in case some classes can be unloaded.
- if ((gc_type == collector::kGcTypeFull) && (runtime->GetJit() != nullptr)) {
+ if (((gc_type == collector::kGcTypeFull) || (gc_type == collector::kGcTypePartial)) &&
+ (runtime->GetJit() != nullptr)) {
runtime->GetJit()->GetCodeCache()->ClearGcRootsInInlineCaches(self);
}
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 6b6f5a5c15..8c1d7768ca 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -25,6 +25,7 @@
#include "debugger_interface.h"
#include "entrypoints/runtime_asm_entrypoints.h"
#include "gc/accounting/bitmap-inl.h"
+#include "gc/scoped_gc_critical_section.h"
#include "jit/jit.h"
#include "jit/profiling_info.h"
#include "linear_alloc.h"
@@ -727,6 +728,9 @@ void JitCodeCache::DoCollection(Thread* self, bool collect_profiling_info) {
RemoveUnmarkedCode(self);
if (collect_profiling_info) {
+ ScopedThreadSuspension sts(self, kSuspended);
+ gc::ScopedGCCriticalSection gcs(
+ self, gc::kGcCauseJitCodeCache, gc::kCollectorTypeJitCodeCache);
MutexLock mu(self, lock_);
// Free all profiling infos of methods not compiled nor being compiled.
auto profiling_kept_end = std::remove_if(profiling_infos_.begin(), profiling_infos_.end(),
diff --git a/runtime/jit/jit_code_cache.h b/runtime/jit/jit_code_cache.h
index 4df6762517..6dc15787bd 100644
--- a/runtime/jit/jit_code_cache.h
+++ b/runtime/jit/jit_code_cache.h
@@ -255,8 +255,7 @@ class JitCodeCache {
SHARED_REQUIRES(Locks::mutator_lock_);
bool CheckLiveCompiledCodeHasProfilingInfo()
- REQUIRES(lock_)
- SHARED_REQUIRES(Locks::mutator_lock_);
+ REQUIRES(lock_);
void FreeCode(uint8_t* code) REQUIRES(lock_);
uint8_t* AllocateCode(size_t code_size) REQUIRES(lock_);