OSDN Git Service

zygote to preload public native libraries
authorDimitry Ivanov <dimitry@google.com>
Mon, 22 Feb 2016 19:22:11 +0000 (11:22 -0800)
committerNicolas Geoffray <ngeoffray@google.com>
Fri, 26 Feb 2016 10:00:27 +0000 (10:00 +0000)
Preload public native libraries when starting a zygote
This lets other users of libnativeloader (like dex2oat)
avoid unnecessary cold loads of libandroid.so which could
take up to a second.

Bug: http://b/27245894
Change-Id: I1499a7485c186b185fce8a1f8d05afcd579d59cc

cmds/app_process/Android.mk
cmds/app_process/app_main.cpp

index 51bbb81..fae0400 100644 (file)
@@ -20,6 +20,7 @@ LOCAL_SHARED_LIBRARIES := \
     libutils \
     liblog \
     libbinder \
+    libnativeloader \
     libandroid_runtime \
     $(app_process_common_shared_libs) \
 
index 2e02382..bfcba9a 100644 (file)
@@ -20,6 +20,7 @@
 #include <cutils/process_name.h>
 #include <cutils/properties.h>
 #include <cutils/trace.h>
+#include <nativeloader/native_loader.h>
 #include <android_runtime/AndroidRuntime.h>
 #include <private/android_filesystem_config.h>  // for AID_SYSTEM
 
@@ -304,6 +305,7 @@ int main(int argc, char* const argv[])
     }
 
     if (zygote) {
+        PreloadPublicNativeLibraries();
         runtime.start("com.android.internal.os.ZygoteInit", args, zygote);
     } else if (className) {
         runtime.start("com.android.internal.os.RuntimeInit", args, zygote);