Revert "Revert "Revert "Always put the framework profile in the boot image location."""
This reverts commit ec769b883cf49c742689a195a417345328fa1bf0.
Bug: 143126914
Bug: 119800099
Bug: 149859910
Bug: 150193586
Reason for revert: First commit was mixed with other regressions. This CL does have a ~20ms impact on app startup of calculator in speed-profile mode. But no regression with "quicken".
Change-Id: I16df444fc4edf509a9db815891a1ada6005ebc91
diff --git a/libartbase/base/file_utils.cc b/libartbase/base/file_utils.cc
index a899b86..3fd1980 100644
--- a/libartbase/base/file_utils.cc
+++ b/libartbase/base/file_utils.cc
@@ -278,9 +278,8 @@
// Boot image consists of two parts:
// - the primary boot image in the ART apex (contains the Core Libraries)
// - the boot image extension on the system partition (contains framework libraries)
- return StringPrintf("%s/javalib/boot.art:%s/framework/boot-framework.art!%s/etc/boot-image.prof",
+ return StringPrintf("%s/javalib/boot.art:%s/framework/boot-framework.art",
kAndroidArtApexDefaultPath,
- android_root.c_str(),
android_root.c_str());
}
diff --git a/runtime/jit/jit.cc b/runtime/jit/jit.cc
index 8ae57ff..1990457 100644
--- a/runtime/jit/jit.cc
+++ b/runtime/jit/jit.cc
@@ -767,10 +767,7 @@
ScopedObjectAccess soa(Thread::Current());
// For a non-bootclasspath class, add a global ref to the class to prevent class unloading
// until compilation is done.
- // When we precompile, this is either with boot classpath methods, or main
- // class loader methods, so we don't need to keep a global reference.
- if (method->GetDeclaringClass()->GetClassLoader() != nullptr &&
- kind_ != TaskKind::kPreCompile) {
+ if (method->GetDeclaringClass()->GetClassLoader() != nullptr) {
klass_ = soa.Vm()->AddGlobalRef(soa.Self(), method_->GetDeclaringClass());
CHECK(klass_ != nullptr);
}
@@ -1119,17 +1116,6 @@
LOG(INFO) << "Successfully mapped boot image methods";
}
-// Return whether a boot image has a profile. This means we'll need to pre-JIT
-// methods in that profile for performance.
-static bool HasImageWithProfile() {
- for (gc::space::ImageSpace* space : Runtime::Current()->GetHeap()->GetBootImageSpaces()) {
- if (!space->GetProfileFile().empty()) {
- return true;
- }
- }
- return false;
-}
-
void Jit::CreateThreadPool() {
// There is a DCHECK in the 'AddSamples' method to ensure the tread pool
// is not null when we instrument.
@@ -1142,9 +1128,9 @@
Start();
Runtime* runtime = Runtime::Current();
- if (runtime->IsZygote() && HasImageWithProfile() && UseJitCompilation()) {
- // If we have an image with a profile, request a JIT task to
- // compile all methods in that profile.
+ if (runtime->IsZygote() && runtime->IsRunningJitZygote() && UseJitCompilation()) {
+ // If we're not using the default boot image location, request a JIT task to
+ // compile all methods in the boot image profile.
thread_pool_->AddTask(Thread::Current(), new ZygoteTask());
// And create mappings to share boot image methods memory from the zygote to
@@ -1223,7 +1209,7 @@
return;
}
Runtime* runtime = Runtime::Current();
- if (runtime->IsSystemServer() && UseJitCompilation() && HasImageWithProfile()) {
+ if (runtime->IsSystemServer() && runtime->IsRunningJitZygote() && UseJitCompilation()) {
thread_pool_->AddTask(Thread::Current(), new JitProfileTask(dex_files, class_loader));
}
}
@@ -1251,9 +1237,7 @@
const void* entry_point = method->GetEntryPointFromQuickCompiledCode();
if (class_linker->IsQuickToInterpreterBridge(entry_point) ||
class_linker->IsQuickGenericJniStub(entry_point) ||
- // We explicitly check for the stub. The trampoline is for methods backed by
- // a .oat file that has a compiled version of the method.
- (entry_point == GetQuickResolutionStub())) {
+ class_linker->IsQuickResolutionStub(entry_point)) {
method->SetPreCompiled();
if (!add_to_queue) {
CompileMethod(method, self, /* baseline= */ false, /* osr= */ false, /* prejit= */ true);
@@ -1479,6 +1463,13 @@
}
}
if (UseJitCompilation()) {
+ if (old_count == 0 &&
+ method->IsNative() &&
+ Runtime::Current()->IsRunningJitZygote()) {
+ // jitzygote: Compile JNI stub on first use to avoid the expensive generic stub.
+ CompileMethod(method, self, /* baseline= */ false, /* osr= */ false, /* prejit= */ false);
+ return true;
+ }
if (old_count < HotMethodThreshold() && new_count >= HotMethodThreshold()) {
if (!code_cache_->ContainsPc(method->GetEntryPointFromQuickCompiledCode())) {
DCHECK(thread_pool_ != nullptr);
@@ -1648,11 +1639,10 @@
}
Runtime* const runtime = Runtime::Current();
- // Check if we'll need to remap the boot image methods.
- if (!is_zygote && fd_methods_ != -1) {
+ // For child zygote, we instead query IsCompilationNotified() post zygote fork.
+ if (!is_zygote && runtime->IsRunningJitZygote() && fd_methods_ != -1) {
// Create a thread that will poll the status of zygote compilation, and map
// the private mapping of boot image methods.
- // For child zygote, we instead query IsCompilationNotified() post zygote fork.
zygote_mapping_methods_.ResetInForkedProcess();
pthread_t polling_thread;
pthread_attr_t attr;
@@ -1678,7 +1668,7 @@
code_cache_->SetGarbageCollectCode(!jit_compiler_->GenerateDebugInfo() &&
!Runtime::Current()->GetInstrumentation()->AreExitStubsInstalled());
- if (is_system_server && HasImageWithProfile()) {
+ if (is_system_server && Runtime::Current()->IsRunningJitZygote()) {
// Disable garbage collection: we don't want it to delete methods we're compiling
// through boot and system server profiles.
// TODO(ngeoffray): Fix this so we still collect deoptimized and unused code.
diff --git a/runtime/runtime.h b/runtime/runtime.h
index 655f05f..3e618fa 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -979,6 +979,11 @@
// Return true if we should load oat files as executable or not.
bool GetOatFilesExecutable() const;
+ bool IsRunningJitZygote() const {
+ // TODO: This should be better specified.
+ return EndsWith(image_location_, "boot-image.prof");
+ }
+
private:
static void InitPlatformSignalHandlers();