diff options
author | 2022-11-28 14:02:48 +0000 | |
---|---|---|
committer | 2022-11-30 08:06:50 +0000 | |
commit | 64fdbedd880bda36215e6e680d23bc2c361d2bfb (patch) | |
tree | a5d20f1b0bd5e4f73e121c9f3027277f0dd6ef3c /runtime/jit/jit_code_cache.cc | |
parent | 1dd292be0d0eea800f4c92f536388c4ab1eeee53 (diff) |
Reland "ART: Rewrite compiled code check in FaultHandler."
This reverts commit 263883a3d710c6cb3d683defb5c5da340ee5f88d.
Reason for revert: Reland with a fix for semi-space GC
which holds the mutator lock exclusively when calling
`ClassLinker::CleanupClassLoaders()`.
Change-Id: I262f4d317f42250b7a4c0594e45c4b496747a91f
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing --jit
Test: run-gtests.sh
Test: testrunner.py --target --optimizing
Bug: 38383823
Diffstat (limited to 'runtime/jit/jit_code_cache.cc')
-rw-r--r-- | runtime/jit/jit_code_cache.cc | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc index ee5d5c7ce3..f4b26284e1 100644 --- a/runtime/jit/jit_code_cache.cc +++ b/runtime/jit/jit_code_cache.cc @@ -220,9 +220,10 @@ JitCodeCache* JitCodeCache::Create(bool used_only_for_profile_data, } } - size_t initial_capacity = Runtime::Current()->GetJITOptions()->GetCodeCacheInitialCapacity(); + Runtime* runtime = Runtime::Current(); + size_t initial_capacity = runtime->GetJITOptions()->GetCodeCacheInitialCapacity(); // Check whether the provided max capacity in options is below 1GB. - size_t max_capacity = Runtime::Current()->GetJITOptions()->GetCodeCacheMaxCapacity(); + size_t max_capacity = runtime->GetJITOptions()->GetCodeCacheMaxCapacity(); // We need to have 32 bit offsets from method headers in code cache which point to things // in the data cache. If the maps are more than 4G apart, having multiple maps wouldn't work. // Ensure we're below 1 GB to be safe. @@ -244,6 +245,11 @@ JitCodeCache* JitCodeCache::Create(bool used_only_for_profile_data, return nullptr; } + if (region.HasCodeMapping()) { + const MemMap* exec_pages = region.GetExecPages(); + runtime->AddGeneratedCodeRange(exec_pages->Begin(), exec_pages->Size()); + } + std::unique_ptr<JitCodeCache> jit_code_cache(new JitCodeCache()); if (is_zygote) { // Zygote should never collect code to share the memory with the children. @@ -278,7 +284,16 @@ JitCodeCache::JitCodeCache() histogram_profiling_info_memory_use_("Memory used for profiling info", 16) { } -JitCodeCache::~JitCodeCache() {} +JitCodeCache::~JitCodeCache() { + if (private_region_.HasCodeMapping()) { + const MemMap* exec_pages = private_region_.GetExecPages(); + Runtime::Current()->RemoveGeneratedCodeRange(exec_pages->Begin(), exec_pages->Size()); + } + if (shared_region_.HasCodeMapping()) { + const MemMap* exec_pages = shared_region_.GetExecPages(); + Runtime::Current()->RemoveGeneratedCodeRange(exec_pages->Begin(), exec_pages->Size()); + } +} bool JitCodeCache::PrivateRegionContainsPc(const void* ptr) const { return private_region_.IsInExecSpace(ptr); @@ -1844,7 +1859,8 @@ void JitCodeCache::PostForkChildAction(bool is_system_server, bool is_zygote) { // We do this now and not in Jit::PostForkChildAction, as system server calls // JitCodeCache::PostForkChildAction first, and then does some code loading // that may result in new JIT tasks that we want to keep. - ThreadPool* pool = Runtime::Current()->GetJit()->GetThreadPool(); + Runtime* runtime = Runtime::Current(); + ThreadPool* pool = runtime->GetJit()->GetThreadPool(); if (pool != nullptr) { pool->RemoveAllTasks(self); } @@ -1855,7 +1871,7 @@ void JitCodeCache::PostForkChildAction(bool is_system_server, bool is_zygote) { // to write to them. shared_region_.ResetWritableMappings(); - if (is_zygote || Runtime::Current()->IsSafeMode()) { + if (is_zygote || runtime->IsSafeMode()) { // Don't create a private region for a child zygote. Regions are usually map shared // (to satisfy dual-view), and we don't want children of a child zygote to inherit it. return; @@ -1870,8 +1886,8 @@ void JitCodeCache::PostForkChildAction(bool is_system_server, bool is_zygote) { histogram_code_memory_use_.Reset(); histogram_profiling_info_memory_use_.Reset(); - size_t initial_capacity = Runtime::Current()->GetJITOptions()->GetCodeCacheInitialCapacity(); - size_t max_capacity = Runtime::Current()->GetJITOptions()->GetCodeCacheMaxCapacity(); + size_t initial_capacity = runtime->GetJITOptions()->GetCodeCacheInitialCapacity(); + size_t max_capacity = runtime->GetJITOptions()->GetCodeCacheMaxCapacity(); std::string error_msg; if (!private_region_.Initialize(initial_capacity, max_capacity, @@ -1880,6 +1896,10 @@ void JitCodeCache::PostForkChildAction(bool is_system_server, bool is_zygote) { &error_msg)) { LOG(WARNING) << "Could not create private region after zygote fork: " << error_msg; } + if (private_region_.HasCodeMapping()) { + const MemMap* exec_pages = private_region_.GetExecPages(); + runtime->AddGeneratedCodeRange(exec_pages->Begin(), exec_pages->Size()); + } } JitMemoryRegion* JitCodeCache::GetCurrentRegion() { |