diff options
| -rw-r--r-- | runtime/gc/accounting/bitmap.cc | 2 | ||||
| -rw-r--r-- | runtime/jit/jit_code_cache.cc | 19 | ||||
| -rw-r--r-- | runtime/jit/jit_code_cache.h | 15 |
3 files changed, 23 insertions, 13 deletions
diff --git a/runtime/gc/accounting/bitmap.cc b/runtime/gc/accounting/bitmap.cc index 8a15af2fbc..bd1a326bb9 100644 --- a/runtime/gc/accounting/bitmap.cc +++ b/runtime/gc/accounting/bitmap.cc @@ -97,7 +97,7 @@ MemoryRangeBitmap<kAlignment>* MemoryRangeBitmap<kAlignment>::CreateFromMemMap( } template class MemoryRangeBitmap<CardTable::kCardSize>; -template class MemoryRangeBitmap<jit::kJitCodeAlignment>; +template class MemoryRangeBitmap<jit::kJitCodeAccountingBytes>; } // namespace accounting } // namespace gc diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc index 20c35c3109..fe2d309333 100644 --- a/runtime/jit/jit_code_cache.cc +++ b/runtime/jit/jit_code_cache.cc @@ -645,8 +645,19 @@ bool JitCodeCache::WaitForPotentialCollectionToComplete(Thread* self) { return in_collection; } +static size_t GetJitCodeAlignment() { + if (kRuntimeISA == InstructionSet::kArm || kRuntimeISA == InstructionSet::kThumb2) { + // Some devices with 32-bit ARM kernels need additional JIT code alignment when using dual + // view JIT (b/132205399). The alignment returned here coincides with the typical ARM d-cache + // line (though the value should be probed ideally). Both the method header and code in the + // cache are aligned to this size. Anything less than 64-bytes exhibits the problem. + return 64; + } + return GetInstructionSetAlignment(kRuntimeISA); +} + static uintptr_t FromCodeToAllocation(const void* code) { - size_t alignment = GetInstructionSetAlignment(kRuntimeISA); + size_t alignment = GetJitCodeAlignment(); return reinterpret_cast<uintptr_t>(code) - RoundUp(sizeof(OatQuickMethodHeader), alignment); } @@ -990,7 +1001,7 @@ uint8_t* JitCodeCache::CommitCodeInternal(Thread* self, { ScopedCodeCacheWrite scc(this); - size_t alignment = GetInstructionSetAlignment(kRuntimeISA); + size_t alignment = GetJitCodeAlignment(); // Ensure the header ends up at expected instruction alignment. size_t header_size = RoundUp(sizeof(OatQuickMethodHeader), alignment); size_t total_size = header_size + code_size; @@ -2160,9 +2171,9 @@ void JitCodeCache::InvalidateCompiledCodeFor(ArtMethod* method, uint8_t* JitCodeCache::AllocateCode(size_t allocation_size) { // Each allocation should be on its own set of cache lines. The allocation must be large enough // for header, code, and any padding. + size_t alignment = GetJitCodeAlignment(); uint8_t* result = reinterpret_cast<uint8_t*>( - mspace_memalign(exec_mspace_, kJitCodeAlignment, allocation_size)); - size_t alignment = GetInstructionSetAlignment(kRuntimeISA); + mspace_memalign(exec_mspace_, alignment, allocation_size)); size_t header_size = RoundUp(sizeof(OatQuickMethodHeader), alignment); // Ensure the header ends up at expected instruction alignment. DCHECK_ALIGNED_PARAM(reinterpret_cast<uintptr_t>(result + header_size), alignment); diff --git a/runtime/jit/jit_code_cache.h b/runtime/jit/jit_code_cache.h index a3e10c75af..df58f19722 100644 --- a/runtime/jit/jit_code_cache.h +++ b/runtime/jit/jit_code_cache.h @@ -74,14 +74,13 @@ namespace jit { class MarkCodeClosure; class ScopedCodeCacheWrite; -// Alignment in bytes that will suit all architectures for JIT code cache allocations. The -// allocated block is used for method header followed by generated code. Allocations should be -// aligned to avoid sharing cache lines between different allocations. The alignment should be -// determined from the hardware, but this isn't readily exposed in userland plus some hardware -// misreports. -static constexpr int kJitCodeAlignment = 64; - -using CodeCacheBitmap = gc::accounting::MemoryRangeBitmap<kJitCodeAlignment>; +// Number of bytes represented by a bit in the CodeCacheBitmap. Value is reasonable for all +// architectures. +static constexpr int kJitCodeAccountingBytes = 16; + +// Type of bitmap used for tracking live functions in the JIT code cache for the purposes +// of garbage collecting code. +using CodeCacheBitmap = gc::accounting::MemoryRangeBitmap<kJitCodeAccountingBytes>; class JitCodeCache { public: |