summaryrefslogtreecommitdiff
path: root/runtime/jit/jit_code_cache.h
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2018-11-20 10:03:13 +0000
committer Nicolas Geoffray <ngeoffray@google.com> 2018-11-21 11:09:49 +0000
commit7a2c7c2f7062d9fef21b72ff9c10ca8ef863eb8b (patch)
tree909d18e31d319313a0729019258418980c810d79 /runtime/jit/jit_code_cache.h
parentc754cc8e1c2dbcb1331ec2bed3ea0787bdd2b5c3 (diff)
Refactor code around JIT creation.
- Create the JIT early on. - Have dedicated zygote spaces, that get assign after the fork. - Re-parse compiler options after fork to take into account customization of debug flags by the child. Currently, we only create the thread pool in the child, so the zygote isn't jitting yet. Bug: 119800099 Test: test.py, device boots Change-Id: I591ce933ebf54a67937ab1d05206534f55ef2f65
Diffstat (limited to 'runtime/jit/jit_code_cache.h')
-rw-r--r--runtime/jit/jit_code_cache.h36
1 files changed, 25 insertions, 11 deletions
diff --git a/runtime/jit/jit_code_cache.h b/runtime/jit/jit_code_cache.h
index a5075638f2..7a838fddd6 100644
--- a/runtime/jit/jit_code_cache.h
+++ b/runtime/jit/jit_code_cache.h
@@ -89,10 +89,9 @@ class JitCodeCache {
// Create the code cache with a code + data capacity equal to "capacity", error message is passed
// in the out arg error_msg.
- static JitCodeCache* Create(size_t initial_capacity,
- size_t max_capacity,
- bool used_only_for_profile_data,
+ static JitCodeCache* Create(bool used_only_for_profile_data,
bool rwx_memory_allowed,
+ bool is_zygote,
std::string* error_msg);
~JitCodeCache();
@@ -262,14 +261,17 @@ class JitCodeCache {
REQUIRES(!lock_)
REQUIRES_SHARED(Locks::mutator_lock_);
+ void PostForkChildAction(bool is_system_server, bool is_zygote);
+
private:
- // Take ownership of maps.
- JitCodeCache(MemMap&& data_pages,
- MemMap&& exec_pages,
- MemMap&& non_exec_pages,
- size_t initial_data_capacity,
- size_t initial_exec_capacity,
- size_t max_capacity);
+ JitCodeCache();
+
+ void InitializeState(size_t initial_capacity, size_t max_capacity) REQUIRES(lock_);
+
+ bool InitializeMappings(bool rwx_memory_allowed, bool is_zygote, std::string* error_msg)
+ REQUIRES(lock_);
+
+ void InitializeSpaces() REQUIRES(lock_);
// Internal version of 'CommitCode' that will not retry if the
// allocation fails. Return null if the allocation fails.
@@ -421,6 +423,9 @@ class JitCodeCache {
// ProfilingInfo objects we have allocated.
std::vector<ProfilingInfo*> profiling_infos_ GUARDED_BY(lock_);
+ // The initial capacity in bytes this code cache starts with.
+ size_t initial_capacity_ GUARDED_BY(lock_);
+
// The maximum capacity in bytes this code cache can go to.
size_t max_capacity_ GUARDED_BY(lock_);
@@ -471,10 +476,19 @@ class JitCodeCache {
// Condition to wait on for accessing inline caches.
ConditionVariable inline_cache_cond_ GUARDED_BY(lock_);
+ // Mem map which holds zygote data (stack maps and profiling info).
+ MemMap zygote_data_pages_;
+ // Mem map which holds zygote code and has executable permission.
+ MemMap zygote_exec_pages_;
+ // The opaque mspace for allocating zygote data.
+ void* zygote_data_mspace_ GUARDED_BY(lock_);
+ // The opaque mspace for allocating zygote code.
+ void* zygote_exec_mspace_ GUARDED_BY(lock_);
+
friend class art::JitJniStubTestHelper;
friend class ScopedCodeCacheWrite;
- DISALLOW_IMPLICIT_CONSTRUCTORS(JitCodeCache);
+ DISALLOW_COPY_AND_ASSIGN(JitCodeCache);
};
} // namespace jit