Add hooks to avoid collecting code for run-tests.
ensureJitCompiled ensures a method gets compiled, but does
not prevent it from being GC'ed. Add a hammer hook to avoid
doing any JIT code cache GC.
test: test-art-host with gcstress and jit.
Change-Id: I3881f10f454ded9c7a3b385d326c2e08932d39bf
diff --git a/runtime/jit/jit_code_cache.h b/runtime/jit/jit_code_cache.h
index 33a792f..c970979 100644
--- a/runtime/jit/jit_code_cache.h
+++ b/runtime/jit/jit_code_cache.h
@@ -229,6 +229,12 @@
void MoveObsoleteMethod(ArtMethod* old_method, ArtMethod* new_method)
REQUIRES(!lock_) REQUIRES(Locks::mutator_lock_);
+ // Dynamically change whether we want to garbage collect code. Should only be used
+ // by tests.
+ void SetGarbageCollectCode(bool value) {
+ garbage_collect_code_ = value;
+ }
+
private:
// Take ownership of maps.
JitCodeCache(MemMap* code_map,
@@ -359,8 +365,8 @@
// It is atomic to avoid locking when reading it.
Atomic<uint64_t> last_update_time_ns_;
- // Whether we can do garbage collection.
- const bool garbage_collect_code_;
+ // Whether we can do garbage collection. Not 'const' as tests may override this.
+ bool garbage_collect_code_;
// The size in bytes of used memory for the data portion of the code cache.
size_t used_memory_for_data_ GUARDED_BY(lock_);