Force alignment of generated JVM called functions.

This CL effectively expands the zone of influence of
https://webrtc-review.googlesource.com/64160,
forcing 16-byte stack alignment of generated JNI methods
for the Android x86 platform.

Bug: webrtc:9085
Change-Id: Idc40c00ea3fb52dbbbeac7b58ceda2a9a44733d8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/159928
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29858}
This commit is contained in:
Raman Budny
2019-11-20 17:08:12 +03:00
committed by Commit Bot
parent ec22183f43
commit ac7fd87375
3 changed files with 20 additions and 1 deletions

View File

@ -27,7 +27,16 @@
#define BASE_EXPORT
#define JNI_REGISTRATION_EXPORT __attribute__((visibility("default")))
#if defined(WEBRTC_ARCH_X86)
// Dalvik JIT generated code doesn't guarantee 16-byte stack alignment on
// x86 - use force_align_arg_pointer to realign the stack at the JNI
// boundary. crbug.com/655248
#define JNI_GENERATOR_EXPORT \
__attribute__((force_align_arg_pointer)) extern "C" JNIEXPORT JNICALL
#else
#define JNI_GENERATOR_EXPORT extern "C" JNIEXPORT JNICALL
#endif
#define CHECK_EXCEPTION(jni) \
RTC_CHECK(!jni->ExceptionCheck()) \

View File

@ -23,8 +23,17 @@
// Convenience macro defining JNI-accessible methods in the org.webrtc package.
// Eliminates unnecessary boilerplate and line-wraps, reducing visual clutter.
#if defined(WEBRTC_ARCH_X86)
// Dalvik JIT generated code doesn't guarantee 16-byte stack alignment on
// x86 - use force_align_arg_pointer to realign the stack at the JNI
// boundary. crbug.com/655248
#define JNI_FUNCTION_DECLARATION(rettype, name, ...) \
__attribute__((force_align_arg_pointer)) extern "C" JNIEXPORT rettype \
JNICALL Java_org_webrtc_##name(__VA_ARGS__)
#else
#define JNI_FUNCTION_DECLARATION(rettype, name, ...) \
extern "C" JNIEXPORT rettype JNICALL Java_org_webrtc_##name(__VA_ARGS__)
#endif
namespace webrtc {
namespace jni {