Use combined native/manual JNI registration.

Add a new mode to the JNI generator which emits both native JNI exports
and manual registration code, and use this as the default mode (except
when compiling with clang as a clang bug prevents this from working at
present).

Native JNI exports are stripped from binaries by default to enforce that
the correct manual registration code is called (and to save increasing
the dynamic symbol table size), except for binaries that explicitly opt
in to using native exports (i.e. libwebviewchromium). Native exports are
not compatible with the crazy linker, so cannot be used universally.

The WebView-specific call to InitReplacementClassLoader, required by
native export mode, has been moved to base to make it easy for other
binaries to experiment with that mode.

Manual JNI registration can be disabled with a call to
base::android::DisableManualJniRegistration at the beginning of
JNI_OnLoad and this has been added to WebView. We plan to refactor the
Android library entry points to make it possible to avoid needing this
flag by just not calling JNI registration but the work is still ongoing;
the flag gets us the desired WebView startup time improvement in the
meantime.

BUG=442327

Review URL: https://codereview.chromium.org/920883002

Cr-Original-Commit-Position: refs/heads/master@{#317434}
Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src
Cr-Mirrored-Commit: 103bf19477cc121eee7a3c2bdc221f2874c971c3
This commit is contained in:
torne 2015-02-20 15:06:33 -08:00 коммит произвёл Commit bot
Родитель 99b3ec1638
Коммит 22ad692dfd
3 изменённых файлов: 28 добавлений и 0 удалений

Просмотреть файл

@ -74,6 +74,12 @@ template("generate_jni") {
rebase_path(jni_generator_jarjar_file, root_build_dir),
]
}
if (!is_clang) {
# Clang builds currently fail with --native_exports_optional due to
# http://llvm.org/bugs/show_bug.cgi?id=22602 - only enable for gcc.
# http://crbug.com/442327
args += [ "--native_exports_optional" ]
}
}
config("jni_includes_${target_name}") {
@ -184,6 +190,12 @@ template("generate_jar_jni") {
"--includes",
rebase_path(jni_generator_include, root_build_dir),
]
if (!is_clang) {
# Clang builds currently fail with --native_exports_optional due to
# http://llvm.org/bugs/show_bug.cgi?id=22602 - only enable for gcc.
# http://crbug.com/442327
args += [ "--native_exports_optional" ]
}
}
}

Просмотреть файл

@ -73,5 +73,13 @@
'<(DEPTH)/build/android/android_exports.gyp:android_exports',
],
}],
['clang==0', {
# Clang builds currently fail with --native_exports_optional due to
# http://llvm.org/bugs/show_bug.cgi?id=22602 - only enable for gcc.
# http://crbug.com/442327
'variables': {
'native_exports%': '--native_exports_optional',
},
}],
],
}

Просмотреть файл

@ -92,6 +92,14 @@
'<(DEPTH)/build/android/android_exports.gyp:android_exports',
],
}],
['clang==0', {
# Clang builds currently fail with --native_exports_optional due to
# http://llvm.org/bugs/show_bug.cgi?id=22602 - only enable for gcc.
# http://crbug.com/442327
'variables': {
'native_exports%': '--native_exports_optional',
},
}],
],
}