diff options
author | 2024-01-30 14:07:27 +0000 | |
---|---|---|
committer | 2024-04-11 12:38:25 +0000 | |
commit | 53ca944020bb86199f6f80d8594d5deb1b1d46dd (patch) | |
tree | 2898b11cbcd41c3e907de9c08b4031047a8d5187 /runtime/jit/jit_code_cache-inl.h | |
parent | a7bc7cbf3182cb5c66f7cf36611c0389e7b7cc0f (diff) |
x86_64: Add JIT support for LoadMethodType.
In aosp/2876518 JIT code made runtime calls.
Bug: 297147201
Test: ./art/test/testrunner/testrunner.py --host --64 --jit -b
Test: ./art/test/testrunner/testrunner.py --host --64 -b
Test: ./art/test.py --host -b
Change-Id: Ifdfd3ace9419b34f8079c9ec4b1b2de31cb50ef7
Diffstat (limited to 'runtime/jit/jit_code_cache-inl.h')
-rw-r--r-- | runtime/jit/jit_code_cache-inl.h | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/runtime/jit/jit_code_cache-inl.h b/runtime/jit/jit_code_cache-inl.h new file mode 100644 index 0000000000..6f2a9ddaae --- /dev/null +++ b/runtime/jit/jit_code_cache-inl.h @@ -0,0 +1,82 @@ +/* + * Copyright 2024 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_RUNTIME_JIT_JIT_CODE_CACHE_INL_H_ +#define ART_RUNTIME_JIT_JIT_CODE_CACHE_INL_H_ + +#include "jit/jit_code_cache.h" + +#include "base/macros.h" +#include "read_barrier.h" +#include "thread.h" +#include "well_known_classes-inl.h" + +namespace art HIDDEN { + +class ArtMethod; + +namespace jit { + +template<typename RootVisitorType> +EXPORT void JitCodeCache::VisitRootTables(ArtMethod* method, RootVisitorType& visitor) { + if (method->IsNative()) { + return; + } + + Thread* self = Thread::Current(); + ScopedDebugDisallowReadBarriers sddrb(self); + MutexLock mu(self, *Locks::jit_lock_); + + auto range = method_code_map_reversed_.equal_range(method); + + for (auto it = range.first; it != range.second; ++it) { + uint32_t number_of_roots = 0; + const uint8_t* root_table = GetRootTable(it->second, &number_of_roots); + uint8_t* roots_data = private_region_.IsInDataSpace(root_table) + ? private_region_.GetWritableDataAddress(root_table) + : shared_region_.GetWritableDataAddress(root_table); + GcRoot<mirror::Object>* roots = reinterpret_cast<GcRoot<mirror::Object>*>(roots_data); + for (uint32_t i = 0; i < number_of_roots; ++i) { + // This does not need a read barrier because this is called by GC. + mirror::Object* object = roots[i].Read<kWithoutReadBarrier>(); + if (!(object == nullptr || + object == Runtime::GetWeakClassSentinel() || + object->IsString<kDefaultVerifyFlags>() || + object->IsClass<kDefaultVerifyFlags>())) { + // We don't need to visit j.l.Class and j.l.String and the only remaining possible + // objects are MethodType-s. + if (kIsDebugBuild) { + ObjPtr<mirror::Class> method_type_class = + WellKnownClasses::java_lang_invoke_MethodType.Get<kWithoutReadBarrier>(); + ObjPtr<mirror::Class> klass = + object->GetClass<kDefaultVerifyFlags, kWithoutReadBarrier>(); + CHECK(klass == method_type_class || + klass == ReadBarrier::IsMarked(method_type_class.Ptr()) || + ReadBarrier::IsMarked(klass.Ptr()) == method_type_class); + } + + visitor.VisitRoot(roots[i].AddressWithoutBarrier()); + } + } + } +} + +} // namespace jit +} // namespace art + +#endif // ART_RUNTIME_JIT_JIT_CODE_CACHE_INL_H_ + + |