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

@ -82,6 +82,8 @@ Michel Promonet <michel.promonet.1@gmail.com>
Min Wang <mingewang@gmail.com> Min Wang <mingewang@gmail.com>
Ramprakash Jelari <ennajelari@gmail.com> Ramprakash Jelari <ennajelari@gmail.com>
CZ Theng <cz.theng@gmail.com> CZ Theng <cz.theng@gmail.com>
Miguel Paris <mparisdiaz@gmail.com>
Raman Budny <budnyjj@gmail.com>
&yet LLC <*@andyet.com> &yet LLC <*@andyet.com>
Agora IO <*@agora.io> Agora IO <*@agora.io>
@ -109,7 +111,6 @@ Videxio AS <*@videxio.com>
Vidyo, Inc. <*@vidyo.com> Vidyo, Inc. <*@vidyo.com>
Vonage Holdings Corp. <*@vonage.com> Vonage Holdings Corp. <*@vonage.com>
Wire Swiss GmbH <*@wire.com> Wire Swiss GmbH <*@wire.com>
Miguel Paris <mparisdiaz@gmail.com>
Vewd Software AS <*@vewd.com> Vewd Software AS <*@vewd.com>
Highfive, Inc. <*@highfive.com> Highfive, Inc. <*@highfive.com>
CoSMo Software Consulting, Pte Ltd <*@cosmosoftware.io> CoSMo Software Consulting, Pte Ltd <*@cosmosoftware.io>

View File

@ -27,7 +27,16 @@
#define BASE_EXPORT #define BASE_EXPORT
#define JNI_REGISTRATION_EXPORT __attribute__((visibility("default"))) #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 #define JNI_GENERATOR_EXPORT extern "C" JNIEXPORT JNICALL
#endif
#define CHECK_EXCEPTION(jni) \ #define CHECK_EXCEPTION(jni) \
RTC_CHECK(!jni->ExceptionCheck()) \ RTC_CHECK(!jni->ExceptionCheck()) \

View File

@ -23,8 +23,17 @@
// Convenience macro defining JNI-accessible methods in the org.webrtc package. // Convenience macro defining JNI-accessible methods in the org.webrtc package.
// Eliminates unnecessary boilerplate and line-wraps, reducing visual clutter. // 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, ...) \ #define JNI_FUNCTION_DECLARATION(rettype, name, ...) \
extern "C" JNIEXPORT rettype JNICALL Java_org_webrtc_##name(__VA_ARGS__) extern "C" JNIEXPORT rettype JNICALL Java_org_webrtc_##name(__VA_ARGS__)
#endif
namespace webrtc { namespace webrtc {
namespace jni { namespace jni {