Fix two bugs in jitzygote configuration.
- Fix a stalled ObjPtr reference.
- Fix DCHECKs now invalid with system server also using 'prejit'.
Bug: 119800099
Test: boots
Change-Id: If64e09115192f06763335237a7518df619965a3c
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 27ac3ff..d8399b4 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -664,16 +664,20 @@
class JitProfileTask final : public Task {
public:
JitProfileTask(const std::vector<std::unique_ptr<const DexFile>>& dex_files,
- ObjPtr<mirror::ClassLoader> class_loader) {
+ jobject class_loader) {
+ ScopedObjectAccess soa(Thread::Current());
+ StackHandleScope<1> hs(soa.Self());
+ Handle<mirror::ClassLoader> h_loader(hs.NewHandle(
+ soa.Decode<mirror::ClassLoader>(class_loader)));
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
for (const auto& dex_file : dex_files) {
dex_files_.push_back(dex_file.get());
// Register the dex file so that we can guarantee it doesn't get deleted
// while reading it during the task.
- class_linker->RegisterDexFile(*dex_file.get(), class_loader);
+ class_linker->RegisterDexFile(*dex_file.get(), h_loader.Get());
}
- ScopedObjectAccess soa(Thread::Current());
- class_loader_ = soa.Vm()->AddGlobalRef(soa.Self(), class_loader.Ptr());
+ // We also create our own global ref to use this class loader later.
+ class_loader_ = soa.Vm()->AddGlobalRef(soa.Self(), h_loader.Get());
}
void Run(Thread* self) override {
@@ -720,7 +724,7 @@
}
void Jit::RegisterDexFiles(const std::vector<std::unique_ptr<const DexFile>>& dex_files,
- ObjPtr<mirror::ClassLoader> class_loader) {
+ jobject class_loader) {
if (dex_files.empty()) {
return;
}
diff --git a/runtime/jit/jit.h b/runtime/jit/jit.h
index fcfddfe..5643277 100644
--- a/runtime/jit/jit.h
+++ b/runtime/jit/jit.h
@@ -320,7 +320,7 @@
// Register the dex files to the JIT. This is to perform any compilation/optimization
// at the point of loading the dex files.
void RegisterDexFiles(const std::vector<std::unique_ptr<const DexFile>>& dex_files,
- ObjPtr<mirror::ClassLoader> class_loader);
+ jobject class_loader);
private:
Jit(JitCodeCache* code_cache, JitOptions* options);
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 15553d4..56a2b6a 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -835,9 +835,8 @@
} else if (class_linker->IsQuickResolutionStub(
method->GetEntryPointFromQuickCompiledCode())) {
// This situation currently only occurs in the jit-zygote mode.
- DCHECK(Runtime::Current()->IsZygote());
DCHECK(Runtime::Current()->IsUsingApexBootImageLocation());
- DCHECK(method->GetDeclaringClass()->GetClassLoader() == nullptr);
+ DCHECK(!garbage_collect_code_);
// TODO(ngeoffray): In most cases, the zygote will not have a profiling
// info for a compiled method. Use a map instead.
if (method->GetProfilingInfo(kRuntimePointerSize) != nullptr) {
diff --git a/runtime/oat_file_manager.cc b/runtime/oat_file_manager.cc
index 111053a..e4c7dc3 100644
--- a/runtime/oat_file_manager.cc
+++ b/runtime/oat_file_manager.cc
@@ -648,9 +648,7 @@
}
if (Runtime::Current()->GetJit() != nullptr) {
- ScopedObjectAccess soa(self);
- Runtime::Current()->GetJit()->RegisterDexFiles(
- dex_files, soa.Decode<mirror::ClassLoader>(class_loader));
+ Runtime::Current()->GetJit()->RegisterDexFiles(dex_files, class_loader);
}
return dex_files;