mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 632954 - Add an explicit __llvm_profile_dump() call for Android; r=snorp
When Android shuts down the ndk process, it doesn't call the registered atexit() handlers, which is normally where the profile data gets written to file. Since the PGO test suite closes the browser when it is finished, the nativeRun routine can manually call out to __llvm_profile_dump() before returning. This method has a downside that only the profile data from the calling library gets written out, rather than for the whole process. Since we are most interested in optimizing libxul, a new hook is added in Bootstrap to make sure we get the profile data for the right library. Differential Revision: https://phabricator.services.mozilla.com/D22817 --HG-- extra : source : 0615c775a0cf6e8f98e1c051cd574c0d602a738a
This commit is contained in:
parent
5f5bbc2171
commit
e39a3d6b7c
@ -379,6 +379,11 @@ Java_org_mozilla_gecko_mozglue_GeckoLoader_nativeRun(JNIEnv* jenv, jclass jc,
|
||||
gBootstrap->XRE_InitChildProcess(argc - 1, argv, &childData);
|
||||
}
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
# ifdef MOZ_PROFILE_GENERATE
|
||||
gBootstrap->XRE_WriteLLVMProfData();
|
||||
# endif
|
||||
#endif
|
||||
gBootstrap.reset();
|
||||
FreeArgv(argv, argc);
|
||||
}
|
||||
|
@ -33,6 +33,9 @@ for var in ('ANDROID_PACKAGE_NAME',
|
||||
'ANDROID_CPU_ARCH'):
|
||||
DEFINES[var] = '"%s"' % CONFIG[var]
|
||||
|
||||
if CONFIG['MOZ_PROFILE_GENERATE']:
|
||||
DEFINES['MOZ_PROFILE_GENERATE'] = True
|
||||
|
||||
if CONFIG['MOZ_FOLD_LIBS']:
|
||||
DEFINES['MOZ_FOLD_LIBS'] = True
|
||||
|
||||
|
@ -8,6 +8,12 @@
|
||||
|
||||
#include "AutoSQLiteLifetime.h"
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
# ifdef MOZ_PROFILE_GENERATE
|
||||
extern "C" int __llvm_profile_dump(void);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class BootstrapImpl final : public Bootstrap {
|
||||
@ -75,6 +81,14 @@ class BootstrapImpl final : public Bootstrap {
|
||||
JNIEnv* aEnv, const XRE_AndroidChildFds& aFds) override {
|
||||
::XRE_SetAndroidChildFds(aEnv, aFds);
|
||||
}
|
||||
|
||||
# ifdef MOZ_PROFILE_GENERATE
|
||||
virtual void XRE_WriteLLVMProfData() override {
|
||||
__android_log_print(ANDROID_LOG_INFO, "GeckoLibLoad",
|
||||
"Calling __llvm_profile_dump()");
|
||||
__llvm_profile_dump();
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef LIBFUZZER
|
||||
|
@ -114,6 +114,9 @@ class Bootstrap {
|
||||
|
||||
virtual void XRE_SetAndroidChildFds(JNIEnv* aEnv,
|
||||
const XRE_AndroidChildFds& fds) = 0;
|
||||
# ifdef MOZ_PROFILE_GENERATE
|
||||
virtual void XRE_WriteLLVMProfData() = 0;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef LIBFUZZER
|
||||
|
@ -257,3 +257,6 @@ if CONFIG['CC_TYPE'] in ('clang', 'gcc'):
|
||||
|
||||
if CONFIG['MOZ_IPDL_TESTS']:
|
||||
DEFINES['MOZ_IPDL_TESTS'] = True
|
||||
|
||||
if CONFIG['MOZ_PROFILE_GENERATE']:
|
||||
DEFINES['MOZ_PROFILE_GENERATE'] = True
|
||||
|
Loading…
Reference in New Issue
Block a user