Bug 1207642 - Work around Dalvik bug by realigning stack on JNI entry; r=snorp, a=sylvestre
authorJim Chen <nchen@mozilla.com>
Tue, 20 Oct 2015 14:48:17 -0400
changeset 289604 fbd30c48f6ec
parent 289603 451d4a04dae4
child 289605 4cebb6ab9288
push id5213
push usercbook@mozilla.com
push date2015-10-22 07:36 +0000
treeherdermozilla-beta@fbd30c48f6ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp, sylvestre
bugs1207642
milestone42.0
Bug 1207642 - Work around Dalvik bug by realigning stack on JNI entry; r=snorp, a=sylvestre Use the force_align_arg_pointer attribute to force realigning stack at JNI entry points.
mobile/android/base/jni-generator.py
mozglue/android/APKOpen.cpp
mozglue/android/APKOpen.h
mozglue/android/NSSBridge.cpp
mozglue/android/NativeCrypto.cpp
mozglue/android/SQLiteBridge.cpp
mozglue/android/jni-stubs.inc
mozglue/android/nsGeckoUtils.cpp
widget/android/jni/Natives.h
--- a/mobile/android/base/jni-generator.py
+++ b/mobile/android/base/jni-generator.py
@@ -3,17 +3,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import argparse
 import re
 
 STUB_TEMPLATE = '''
 typedef %(returnType)s (*%(functionName)s_t)(%(paramTypes)s);
 static %(functionName)s_t f_%(functionName)s;
-extern "C" NS_EXPORT %(returnType)s JNICALL
+extern "C" NS_EXPORT %(returnType)s MOZ_JNICALL
 %(functionName)s(%(parameterList)s) {
     if (!f_%(functionName)s) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return %(returnValue)s;
     }
     %(returnKeyword)s f_%(functionName)s(%(arguments)s);
 }
--- a/mozglue/android/APKOpen.cpp
+++ b/mozglue/android/APKOpen.cpp
@@ -310,17 +310,17 @@ loadNSSLibs(const char *apkName)
     __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Couldn't get a handle to libplc4!");
     return FAILURE;
   }
 #endif
 
   return setup_nss_functions(nss_handle, nspr_handle, plc_handle);
 }
 
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_mozglue_GeckoLoader_loadGeckoLibsNative(JNIEnv *jenv, jclass jGeckoAppShellClass, jstring jApkName)
 {
   jenv->GetJavaVM(&sJavaVM);
 
   const char* str;
   // XXX: java doesn't give us true UTF8, we should figure out something
   // better to do here
   str = jenv->GetStringUTFChars(jApkName, nullptr);
@@ -329,17 +329,17 @@ Java_org_mozilla_gecko_mozglue_GeckoLoad
 
   int res = loadGeckoLibs(str);
   if (res != SUCCESS) {
     JNI_Throw(jenv, "java/lang/Exception", "Error loading gecko libraries");
   }
   jenv->ReleaseStringUTFChars(jApkName, str);
 }
 
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_mozglue_GeckoLoader_loadSQLiteLibsNative(JNIEnv *jenv, jclass jGeckoAppShellClass, jstring jApkName) {
   const char* str;
   // XXX: java doesn't give us true UTF8, we should figure out something
   // better to do here
   str = jenv->GetStringUTFChars(jApkName, nullptr);
   if (str == nullptr)
     return;
 
@@ -347,17 +347,17 @@ Java_org_mozilla_gecko_mozglue_GeckoLoad
   mozglueresult rv = loadSQLiteLibs(str);
   if (rv != SUCCESS) {
       JNI_Throw(jenv, "java/lang/Exception", "Error loading sqlite libraries");
   }
   __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Load sqlite done\n");
   jenv->ReleaseStringUTFChars(jApkName, str);
 }
 
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_mozglue_GeckoLoader_loadNSSLibsNative(JNIEnv *jenv, jclass jGeckoAppShellClass, jstring jApkName) {
   const char* str;
   // XXX: java doesn't give us true UTF8, we should figure out something
   // better to do here
   str = jenv->GetStringUTFChars(jApkName, nullptr);
   if (str == nullptr)
     return;
 
@@ -367,17 +367,17 @@ Java_org_mozilla_gecko_mozglue_GeckoLoad
     JNI_Throw(jenv, "java/lang/Exception", "Error loading nss libraries");
   }
   __android_log_print(ANDROID_LOG_ERROR, "GeckoLibLoad", "Load nss done\n");
   jenv->ReleaseStringUTFChars(jApkName, str);
 }
 
 typedef void (*GeckoStart_t)(void *, const nsXREAppData *);
 
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_mozglue_GeckoLoader_nativeRun(JNIEnv *jenv, jclass jc, jstring jargs)
 {
   GeckoStart_t GeckoStart;
   xul_dlsym("GeckoStart", &GeckoStart);
   if (GeckoStart == nullptr)
     return;
   // XXX: java doesn't give us true UTF8, we should figure out something
   // better to do here
--- a/mozglue/android/APKOpen.h
+++ b/mozglue/android/APKOpen.h
@@ -20,9 +20,18 @@ struct mapping_info {
 
 NS_EXPORT const struct mapping_info * getLibraryMapping();
 NS_EXPORT void abortThroughJava(const char* msg);
 
 static const int SUCCESS = 0;
 static const int FAILURE = 1;
 void JNI_Throw(JNIEnv* jenv, const char* classname, const char* msg);
 
+// Bug 1207642 - Work around Dalvik bug by realigning stack on JNI entry
+#ifndef MOZ_JNICALL
+# ifdef __i386__
+#  define MOZ_JNICALL JNICALL __attribute__((force_align_arg_pointer))
+# else
+#  define MOZ_JNICALL JNICALL
+# endif
+#endif
+
 #endif /* APKOpen_h */
--- a/mozglue/android/NSSBridge.cpp
+++ b/mozglue/android/NSSBridge.cpp
@@ -83,17 +83,17 @@ throwError(JNIEnv* jenv, const char * fu
     asprintf(&msg, "%s returned error %d: %s\n", funcString, perr, errString);
     LOG("Throwing error: %s\n", msg);
 
     JNI_Throw(jenv, "java/lang/Exception", msg);
     free(msg);
     LOG("Error thrown\n");
 }
 
-extern "C" NS_EXPORT jstring JNICALL
+extern "C" NS_EXPORT jstring MOZ_JNICALL
 Java_org_mozilla_gecko_NSSBridge_nativeEncrypt(JNIEnv* jenv, jclass,
                                                jstring jPath,
                                                jstring jValue)
 {
     jstring ret = jenv->NewStringUTF("");
 
     const char* path;
     path = jenv->GetStringUTFChars(jPath, nullptr);
@@ -109,17 +109,17 @@ Java_org_mozilla_gecko_NSSBridge_nativeE
     }
 
     jenv->ReleaseStringUTFChars(jValue, value);
     jenv->ReleaseStringUTFChars(jPath, path);
 
     return ret;
 }
 
-extern "C" NS_EXPORT jstring JNICALL
+extern "C" NS_EXPORT jstring MOZ_JNICALL
 Java_org_mozilla_gecko_NSSBridge_nativeDecrypt(JNIEnv* jenv, jclass,
                                                jstring jPath,
                                                jstring jValue)
 {
     jstring ret = jenv->NewStringUTF("");
 
     const char* path;
     path = jenv->GetStringUTFChars(jPath, nullptr);
--- a/mozglue/android/NativeCrypto.cpp
+++ b/mozglue/android/NativeCrypto.cpp
@@ -1,28 +1,29 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "NativeCrypto.h"
+#include "APKOpen.h"
 
 #include <jni.h>
 
 #include <errno.h>
 #include <stdlib.h>
 #include <inttypes.h>
 
 #include "mozilla/SHA1.h"
 #include "pbkdf2_sha256.h"
 
 /**
  * Helper function to invoke native PBKDF2 function with JNI
  * arguments.
  */
-extern "C" JNIEXPORT jbyteArray JNICALL Java_org_mozilla_gecko_background_nativecode_NativeCrypto_pbkdf2SHA256
+extern "C" JNIEXPORT jbyteArray MOZ_JNICALL Java_org_mozilla_gecko_background_nativecode_NativeCrypto_pbkdf2SHA256
     (JNIEnv *env, jclass jc, jbyteArray jpassword, jbyteArray jsalt, jint c, jint dkLen) {
   if (dkLen < 0) {
     env->ThrowNew(env->FindClass("java/lang/IllegalArgumentException"),
                   "dkLen should not be less than 0");
     return nullptr;
   }
 
   jbyte *password = env->GetByteArrayElements(jpassword, nullptr);
@@ -47,17 +48,17 @@ extern "C" JNIEXPORT jbyteArray JNICALL 
   return out;
 }
 
 using namespace mozilla;
 
 /**
  * Helper function to invoke native SHA-1 function with JNI arguments.
  */
-extern "C" JNIEXPORT jbyteArray JNICALL Java_org_mozilla_gecko_background_nativecode_NativeCrypto_sha1
+extern "C" JNIEXPORT jbyteArray MOZ_JNICALL Java_org_mozilla_gecko_background_nativecode_NativeCrypto_sha1
     (JNIEnv *env, jclass jc, jbyteArray jstr) {
   jbyte *str = env->GetByteArrayElements(jstr, nullptr);
   size_t strLen = env->GetArrayLength(jstr);
 
   SHA1Sum sha1;
   SHA1Sum::Hash hashResult;
   sha1.update((void *) str, (uint32_t) strLen);
   sha1.finish(hashResult);
--- a/mozglue/android/SQLiteBridge.cpp
+++ b/mozglue/android/SQLiteBridge.cpp
@@ -131,17 +131,17 @@ JNI_Setup(JNIEnv* jenv)
         || jCursorAddRow == nullptr) {
         throwSqliteException(jenv, "GetMethodId error");
         return;
     }
 
     initialized = true;
 }
 
-extern "C" NS_EXPORT jobject JNICALL
+extern "C" NS_EXPORT jobject MOZ_JNICALL
 Java_org_mozilla_gecko_sqlite_SQLiteBridge_sqliteCall(JNIEnv* jenv, jclass,
                                                       jstring jDb,
                                                       jstring jQuery,
                                                       jobjectArray jParams,
                                                       jlongArray jQueryRes)
 {
     JNI_Setup(jenv);
 
@@ -159,32 +159,32 @@ Java_org_mozilla_gecko_sqlite_SQLiteBrid
         f_sqlite3_close(db); // close db even if open failed
         return nullptr;
     }
     jCursor = sqliteInternalCall(jenv, db, jQuery, jParams, jQueryRes);
     f_sqlite3_close(db);
     return jCursor;
 }
 
-extern "C" NS_EXPORT jobject JNICALL
+extern "C" NS_EXPORT jobject MOZ_JNICALL
 Java_org_mozilla_gecko_sqlite_SQLiteBridge_sqliteCallWithDb(JNIEnv* jenv, jclass,
                                                             jlong jDb,
                                                             jstring jQuery,
                                                             jobjectArray jParams,
                                                             jlongArray jQueryRes)
 {
     JNI_Setup(jenv);
 
     jobject jCursor = nullptr;
     sqlite3 *db = (sqlite3*)jDb;
     jCursor = sqliteInternalCall(jenv, db, jQuery, jParams, jQueryRes);
     return jCursor;
 }
 
-extern "C" NS_EXPORT jlong JNICALL
+extern "C" NS_EXPORT jlong MOZ_JNICALL
 Java_org_mozilla_gecko_sqlite_SQLiteBridge_openDatabase(JNIEnv* jenv, jclass,
                                                         jstring jDb)
 {
     JNI_Setup(jenv);
 
     int rc;
     const char* dbPath;
     sqlite3 *db;
@@ -196,17 +196,17 @@ Java_org_mozilla_gecko_sqlite_SQLiteBrid
         throwSqliteException(jenv,
             "Can't open database: %s", f_sqlite3_errmsg(db));
         f_sqlite3_close(db); // close db even if open failed
         return 0;
     }
     return (jlong)db;
 }
 
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_sqlite_SQLiteBridge_closeDatabase(JNIEnv* jenv, jclass,
                                                         jlong jDb)
 {
     JNI_Setup(jenv);
 
     sqlite3 *db = (sqlite3*)jDb;
     f_sqlite3_close(db);
 }
--- a/mozglue/android/jni-stubs.inc
+++ b/mozglue/android/jni-stubs.inc
@@ -1,14 +1,14 @@
 /* WARNING - This file is autogenerated by mobile/android/base/jni-generator.py. Do not edit manually! */
 #ifdef JNI_STUBS
 
 typedef void (*Java_org_mozilla_gecko_GeckoAppShell_registerJavaUiThread_t)(JNIEnv *, jclass);
 static Java_org_mozilla_gecko_GeckoAppShell_registerJavaUiThread_t f_Java_org_mozilla_gecko_GeckoAppShell_registerJavaUiThread;
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_registerJavaUiThread(JNIEnv * arg0, jclass arg1) {
     if (!f_Java_org_mozilla_gecko_GeckoAppShell_registerJavaUiThread) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
      f_Java_org_mozilla_gecko_GeckoAppShell_registerJavaUiThread(arg0, arg1);
 }
@@ -17,17 +17,17 @@ Java_org_mozilla_gecko_GeckoAppShell_reg
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_registerJavaUiThread", &f_Java_org_mozilla_gecko_GeckoAppShell_registerJavaUiThread);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef void (*Java_org_mozilla_gecko_GeckoAppShell_nativeInit_t)(JNIEnv *, jclass, jobject, jobject);
 static Java_org_mozilla_gecko_GeckoAppShell_nativeInit_t f_Java_org_mozilla_gecko_GeckoAppShell_nativeInit;
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_nativeInit(JNIEnv * arg0, jclass arg1, jobject arg2, jobject arg3) {
     if (!f_Java_org_mozilla_gecko_GeckoAppShell_nativeInit) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
      f_Java_org_mozilla_gecko_GeckoAppShell_nativeInit(arg0, arg1, arg2, arg3);
 }
@@ -36,17 +36,17 @@ Java_org_mozilla_gecko_GeckoAppShell_nat
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_nativeInit", &f_Java_org_mozilla_gecko_GeckoAppShell_nativeInit);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef void (*Java_org_mozilla_gecko_GeckoAppShell_onResume_t)(JNIEnv *, jclass);
 static Java_org_mozilla_gecko_GeckoAppShell_onResume_t f_Java_org_mozilla_gecko_GeckoAppShell_onResume;
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_onResume(JNIEnv * arg0, jclass arg1) {
     if (!f_Java_org_mozilla_gecko_GeckoAppShell_onResume) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
      f_Java_org_mozilla_gecko_GeckoAppShell_onResume(arg0, arg1);
 }
@@ -55,17 +55,17 @@ Java_org_mozilla_gecko_GeckoAppShell_onR
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_onResume", &f_Java_org_mozilla_gecko_GeckoAppShell_onResume);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef void (*Java_org_mozilla_gecko_GeckoAppShell_onSurfaceTextureFrameAvailable_t)(JNIEnv *, jclass, jobject, jint);
 static Java_org_mozilla_gecko_GeckoAppShell_onSurfaceTextureFrameAvailable_t f_Java_org_mozilla_gecko_GeckoAppShell_onSurfaceTextureFrameAvailable;
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_onSurfaceTextureFrameAvailable(JNIEnv * arg0, jclass arg1, jobject arg2, jint arg3) {
     if (!f_Java_org_mozilla_gecko_GeckoAppShell_onSurfaceTextureFrameAvailable) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
      f_Java_org_mozilla_gecko_GeckoAppShell_onSurfaceTextureFrameAvailable(arg0, arg1, arg2, arg3);
 }
@@ -74,17 +74,17 @@ Java_org_mozilla_gecko_GeckoAppShell_onS
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_onSurfaceTextureFrameAvailable", &f_Java_org_mozilla_gecko_GeckoAppShell_onSurfaceTextureFrameAvailable);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef void (*Java_org_mozilla_gecko_GeckoAppShell_dispatchMemoryPressure_t)(JNIEnv *, jclass);
 static Java_org_mozilla_gecko_GeckoAppShell_dispatchMemoryPressure_t f_Java_org_mozilla_gecko_GeckoAppShell_dispatchMemoryPressure;
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_dispatchMemoryPressure(JNIEnv * arg0, jclass arg1) {
     if (!f_Java_org_mozilla_gecko_GeckoAppShell_dispatchMemoryPressure) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
      f_Java_org_mozilla_gecko_GeckoAppShell_dispatchMemoryPressure(arg0, arg1);
 }
@@ -93,17 +93,17 @@ Java_org_mozilla_gecko_GeckoAppShell_dis
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_dispatchMemoryPressure", &f_Java_org_mozilla_gecko_GeckoAppShell_dispatchMemoryPressure);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef void (*Java_org_mozilla_gecko_GeckoAppShell_reportJavaCrash_t)(JNIEnv *, jclass, jstring);
 static Java_org_mozilla_gecko_GeckoAppShell_reportJavaCrash_t f_Java_org_mozilla_gecko_GeckoAppShell_reportJavaCrash;
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_reportJavaCrash(JNIEnv * arg0, jclass arg1, jstring arg2) {
     if (!f_Java_org_mozilla_gecko_GeckoAppShell_reportJavaCrash) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
      f_Java_org_mozilla_gecko_GeckoAppShell_reportJavaCrash(arg0, arg1, arg2);
 }
@@ -112,17 +112,17 @@ Java_org_mozilla_gecko_GeckoAppShell_rep
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_reportJavaCrash", &f_Java_org_mozilla_gecko_GeckoAppShell_reportJavaCrash);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef void (*Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent_t)(JNIEnv *, jclass, jboolean);
 static Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent_t f_Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent;
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent(JNIEnv * arg0, jclass arg1, jboolean arg2) {
     if (!f_Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
      f_Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent(arg0, arg1, arg2);
 }
@@ -131,17 +131,17 @@ Java_org_mozilla_gecko_GeckoAppShell_pro
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent", &f_Java_org_mozilla_gecko_GeckoAppShell_processNextNativeEvent);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef void (*Java_org_mozilla_gecko_GeckoAppShell_notifyBatteryChange_t)(JNIEnv *, jclass, jdouble, jboolean, jdouble);
 static Java_org_mozilla_gecko_GeckoAppShell_notifyBatteryChange_t f_Java_org_mozilla_gecko_GeckoAppShell_notifyBatteryChange;
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_notifyBatteryChange(JNIEnv * arg0, jclass arg1, jdouble arg2, jboolean arg3, jdouble arg4) {
     if (!f_Java_org_mozilla_gecko_GeckoAppShell_notifyBatteryChange) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
      f_Java_org_mozilla_gecko_GeckoAppShell_notifyBatteryChange(arg0, arg1, arg2, arg3, arg4);
 }
@@ -150,17 +150,17 @@ Java_org_mozilla_gecko_GeckoAppShell_not
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_notifyBatteryChange", &f_Java_org_mozilla_gecko_GeckoAppShell_notifyBatteryChange);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef void (*Java_org_mozilla_gecko_GeckoAppShell_invalidateAndScheduleComposite_t)(JNIEnv *, jclass);
 static Java_org_mozilla_gecko_GeckoAppShell_invalidateAndScheduleComposite_t f_Java_org_mozilla_gecko_GeckoAppShell_invalidateAndScheduleComposite;
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_invalidateAndScheduleComposite(JNIEnv * arg0, jclass arg1) {
     if (!f_Java_org_mozilla_gecko_GeckoAppShell_invalidateAndScheduleComposite) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
      f_Java_org_mozilla_gecko_GeckoAppShell_invalidateAndScheduleComposite(arg0, arg1);
 }
@@ -169,17 +169,17 @@ Java_org_mozilla_gecko_GeckoAppShell_inv
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_invalidateAndScheduleComposite", &f_Java_org_mozilla_gecko_GeckoAppShell_invalidateAndScheduleComposite);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef void (*Java_org_mozilla_gecko_GeckoAppShell_scheduleResumeComposition_t)(JNIEnv *, jclass, jint, jint);
 static Java_org_mozilla_gecko_GeckoAppShell_scheduleResumeComposition_t f_Java_org_mozilla_gecko_GeckoAppShell_scheduleResumeComposition;
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_scheduleResumeComposition(JNIEnv * arg0, jclass arg1, jint arg2, jint arg3) {
     if (!f_Java_org_mozilla_gecko_GeckoAppShell_scheduleResumeComposition) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
      f_Java_org_mozilla_gecko_GeckoAppShell_scheduleResumeComposition(arg0, arg1, arg2, arg3);
 }
@@ -188,17 +188,17 @@ Java_org_mozilla_gecko_GeckoAppShell_sch
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_scheduleResumeComposition", &f_Java_org_mozilla_gecko_GeckoAppShell_scheduleResumeComposition);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef jfloat (*Java_org_mozilla_gecko_GeckoAppShell_computeRenderIntegrity_t)(JNIEnv *, jclass);
 static Java_org_mozilla_gecko_GeckoAppShell_computeRenderIntegrity_t f_Java_org_mozilla_gecko_GeckoAppShell_computeRenderIntegrity;
-extern "C" NS_EXPORT jfloat JNICALL
+extern "C" NS_EXPORT jfloat MOZ_JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_computeRenderIntegrity(JNIEnv * arg0, jclass arg1) {
     if (!f_Java_org_mozilla_gecko_GeckoAppShell_computeRenderIntegrity) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return 0;
     }
     return f_Java_org_mozilla_gecko_GeckoAppShell_computeRenderIntegrity(arg0, arg1);
 }
@@ -207,17 +207,17 @@ Java_org_mozilla_gecko_GeckoAppShell_com
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_computeRenderIntegrity", &f_Java_org_mozilla_gecko_GeckoAppShell_computeRenderIntegrity);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef jobject (*Java_org_mozilla_gecko_GeckoAppShell_getSurfaceBits_t)(JNIEnv *, jclass, jobject);
 static Java_org_mozilla_gecko_GeckoAppShell_getSurfaceBits_t f_Java_org_mozilla_gecko_GeckoAppShell_getSurfaceBits;
-extern "C" NS_EXPORT jobject JNICALL
+extern "C" NS_EXPORT jobject MOZ_JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_getSurfaceBits(JNIEnv * arg0, jclass arg1, jobject arg2) {
     if (!f_Java_org_mozilla_gecko_GeckoAppShell_getSurfaceBits) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return nullptr;
     }
     return f_Java_org_mozilla_gecko_GeckoAppShell_getSurfaceBits(arg0, arg1, arg2);
 }
@@ -226,17 +226,17 @@ Java_org_mozilla_gecko_GeckoAppShell_get
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_getSurfaceBits", &f_Java_org_mozilla_gecko_GeckoAppShell_getSurfaceBits);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef void (*Java_org_mozilla_gecko_GeckoAppShell_addPresentationSurface_t)(JNIEnv *, jclass, jobject);
 static Java_org_mozilla_gecko_GeckoAppShell_addPresentationSurface_t f_Java_org_mozilla_gecko_GeckoAppShell_addPresentationSurface;
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_addPresentationSurface(JNIEnv * arg0, jclass arg1, jobject arg2) {
     if (!f_Java_org_mozilla_gecko_GeckoAppShell_addPresentationSurface) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
      f_Java_org_mozilla_gecko_GeckoAppShell_addPresentationSurface(arg0, arg1, arg2);
 }
@@ -245,17 +245,17 @@ Java_org_mozilla_gecko_GeckoAppShell_add
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_addPresentationSurface", &f_Java_org_mozilla_gecko_GeckoAppShell_addPresentationSurface);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef void (*Java_org_mozilla_gecko_GeckoAppShell_removePresentationSurface_t)(JNIEnv *, jclass, jobject);
 static Java_org_mozilla_gecko_GeckoAppShell_removePresentationSurface_t f_Java_org_mozilla_gecko_GeckoAppShell_removePresentationSurface;
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_removePresentationSurface(JNIEnv * arg0, jclass arg1, jobject arg2) {
     if (!f_Java_org_mozilla_gecko_GeckoAppShell_removePresentationSurface) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
      f_Java_org_mozilla_gecko_GeckoAppShell_removePresentationSurface(arg0, arg1, arg2);
 }
@@ -264,17 +264,17 @@ Java_org_mozilla_gecko_GeckoAppShell_rem
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_removePresentationSurface", &f_Java_org_mozilla_gecko_GeckoAppShell_removePresentationSurface);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef void (*Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden_t)(JNIEnv *, jclass, jobject);
 static Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden_t f_Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden;
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden(JNIEnv * arg0, jclass arg1, jobject arg2) {
     if (!f_Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
      f_Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden(arg0, arg1, arg2);
 }
@@ -283,17 +283,17 @@ Java_org_mozilla_gecko_GeckoAppShell_onF
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden", &f_Java_org_mozilla_gecko_GeckoAppShell_onFullScreenPluginHidden);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef void (*Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoOfEvent_t)(JNIEnv *, jclass, jobject);
 static Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoOfEvent_t f_Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoOfEvent;
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoOfEvent(JNIEnv * arg0, jclass arg1, jobject arg2) {
     if (!f_Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoOfEvent) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
      f_Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoOfEvent(arg0, arg1, arg2);
 }
@@ -302,17 +302,17 @@ Java_org_mozilla_gecko_GeckoAppShell_not
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoOfEvent", &f_Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoOfEvent);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef void (*Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoObservers_t)(JNIEnv *, jclass, jstring, jstring);
 static Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoObservers_t f_Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoObservers;
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoObservers(JNIEnv * arg0, jclass arg1, jstring arg2, jstring arg3) {
     if (!f_Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoObservers) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
      f_Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoObservers(arg0, arg1, arg2, arg3);
 }
@@ -321,17 +321,17 @@ Java_org_mozilla_gecko_GeckoAppShell_not
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoObservers", &f_Java_org_mozilla_gecko_GeckoAppShell_notifyGeckoObservers);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef jlong (*Java_org_mozilla_gecko_GeckoAppShell_runUiThreadCallback_t)(JNIEnv *, jclass);
 static Java_org_mozilla_gecko_GeckoAppShell_runUiThreadCallback_t f_Java_org_mozilla_gecko_GeckoAppShell_runUiThreadCallback;
-extern "C" NS_EXPORT jlong JNICALL
+extern "C" NS_EXPORT jlong MOZ_JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_runUiThreadCallback(JNIEnv * arg0, jclass arg1) {
     if (!f_Java_org_mozilla_gecko_GeckoAppShell_runUiThreadCallback) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return 0;
     }
     return f_Java_org_mozilla_gecko_GeckoAppShell_runUiThreadCallback(arg0, arg1);
 }
@@ -340,17 +340,17 @@ Java_org_mozilla_gecko_GeckoAppShell_run
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_runUiThreadCallback", &f_Java_org_mozilla_gecko_GeckoAppShell_runUiThreadCallback);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef void (*Java_org_mozilla_gecko_GeckoAppShell_cameraCallbackBridge_t)(JNIEnv *, jclass, jbyteArray);
 static Java_org_mozilla_gecko_GeckoAppShell_cameraCallbackBridge_t f_Java_org_mozilla_gecko_GeckoAppShell_cameraCallbackBridge;
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_GeckoAppShell_cameraCallbackBridge(JNIEnv * arg0, jclass arg1, jbyteArray arg2) {
     if (!f_Java_org_mozilla_gecko_GeckoAppShell_cameraCallbackBridge) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
      f_Java_org_mozilla_gecko_GeckoAppShell_cameraCallbackBridge(arg0, arg1, arg2);
 }
@@ -359,17 +359,17 @@ Java_org_mozilla_gecko_GeckoAppShell_cam
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoAppShell_cameraCallbackBridge", &f_Java_org_mozilla_gecko_GeckoAppShell_cameraCallbackBridge);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef jdouble (*Java_org_mozilla_gecko_GeckoJavaSampler_getProfilerTime_t)(JNIEnv *, jclass);
 static Java_org_mozilla_gecko_GeckoJavaSampler_getProfilerTime_t f_Java_org_mozilla_gecko_GeckoJavaSampler_getProfilerTime;
-extern "C" NS_EXPORT jdouble JNICALL
+extern "C" NS_EXPORT jdouble MOZ_JNICALL
 Java_org_mozilla_gecko_GeckoJavaSampler_getProfilerTime(JNIEnv * arg0, jclass arg1) {
     if (!f_Java_org_mozilla_gecko_GeckoJavaSampler_getProfilerTime) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return 0;
     }
     return f_Java_org_mozilla_gecko_GeckoJavaSampler_getProfilerTime(arg0, arg1);
 }
@@ -378,17 +378,17 @@ Java_org_mozilla_gecko_GeckoJavaSampler_
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_GeckoJavaSampler_getProfilerTime", &f_Java_org_mozilla_gecko_GeckoJavaSampler_getProfilerTime);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef void (*Java_org_mozilla_gecko_gfx_NativePanZoomController_abortAnimation_t)(JNIEnv *, jobject);
 static Java_org_mozilla_gecko_gfx_NativePanZoomController_abortAnimation_t f_Java_org_mozilla_gecko_gfx_NativePanZoomController_abortAnimation;
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_gfx_NativePanZoomController_abortAnimation(JNIEnv * arg0, jobject arg1) {
     if (!f_Java_org_mozilla_gecko_gfx_NativePanZoomController_abortAnimation) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
      f_Java_org_mozilla_gecko_gfx_NativePanZoomController_abortAnimation(arg0, arg1);
 }
@@ -397,17 +397,17 @@ Java_org_mozilla_gecko_gfx_NativePanZoom
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_gfx_NativePanZoomController_abortAnimation", &f_Java_org_mozilla_gecko_gfx_NativePanZoomController_abortAnimation);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef void (*Java_org_mozilla_gecko_gfx_NativePanZoomController_init_t)(JNIEnv *, jobject);
 static Java_org_mozilla_gecko_gfx_NativePanZoomController_init_t f_Java_org_mozilla_gecko_gfx_NativePanZoomController_init;
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_gfx_NativePanZoomController_init(JNIEnv * arg0, jobject arg1) {
     if (!f_Java_org_mozilla_gecko_gfx_NativePanZoomController_init) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
      f_Java_org_mozilla_gecko_gfx_NativePanZoomController_init(arg0, arg1);
 }
@@ -416,17 +416,17 @@ Java_org_mozilla_gecko_gfx_NativePanZoom
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_gfx_NativePanZoomController_init", &f_Java_org_mozilla_gecko_gfx_NativePanZoomController_init);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef jboolean (*Java_org_mozilla_gecko_gfx_NativePanZoomController_handleTouchEvent_t)(JNIEnv *, jobject, jobject);
 static Java_org_mozilla_gecko_gfx_NativePanZoomController_handleTouchEvent_t f_Java_org_mozilla_gecko_gfx_NativePanZoomController_handleTouchEvent;
-extern "C" NS_EXPORT jboolean JNICALL
+extern "C" NS_EXPORT jboolean MOZ_JNICALL
 Java_org_mozilla_gecko_gfx_NativePanZoomController_handleTouchEvent(JNIEnv * arg0, jobject arg1, jobject arg2) {
     if (!f_Java_org_mozilla_gecko_gfx_NativePanZoomController_handleTouchEvent) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return false;
     }
     return f_Java_org_mozilla_gecko_gfx_NativePanZoomController_handleTouchEvent(arg0, arg1, arg2);
 }
@@ -435,17 +435,17 @@ Java_org_mozilla_gecko_gfx_NativePanZoom
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_gfx_NativePanZoomController_handleTouchEvent", &f_Java_org_mozilla_gecko_gfx_NativePanZoomController_handleTouchEvent);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef void (*Java_org_mozilla_gecko_gfx_NativePanZoomController_handleMotionEvent_t)(JNIEnv *, jobject, jobject);
 static Java_org_mozilla_gecko_gfx_NativePanZoomController_handleMotionEvent_t f_Java_org_mozilla_gecko_gfx_NativePanZoomController_handleMotionEvent;
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_gfx_NativePanZoomController_handleMotionEvent(JNIEnv * arg0, jobject arg1, jobject arg2) {
     if (!f_Java_org_mozilla_gecko_gfx_NativePanZoomController_handleMotionEvent) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
      f_Java_org_mozilla_gecko_gfx_NativePanZoomController_handleMotionEvent(arg0, arg1, arg2);
 }
@@ -454,17 +454,17 @@ Java_org_mozilla_gecko_gfx_NativePanZoom
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_gfx_NativePanZoomController_handleMotionEvent", &f_Java_org_mozilla_gecko_gfx_NativePanZoomController_handleMotionEvent);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef void (*Java_org_mozilla_gecko_gfx_NativePanZoomController_destroy_t)(JNIEnv *, jobject);
 static Java_org_mozilla_gecko_gfx_NativePanZoomController_destroy_t f_Java_org_mozilla_gecko_gfx_NativePanZoomController_destroy;
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_gfx_NativePanZoomController_destroy(JNIEnv * arg0, jobject arg1) {
     if (!f_Java_org_mozilla_gecko_gfx_NativePanZoomController_destroy) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
      f_Java_org_mozilla_gecko_gfx_NativePanZoomController_destroy(arg0, arg1);
 }
@@ -473,17 +473,17 @@ Java_org_mozilla_gecko_gfx_NativePanZoom
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_gfx_NativePanZoomController_destroy", &f_Java_org_mozilla_gecko_gfx_NativePanZoomController_destroy);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef jboolean (*Java_org_mozilla_gecko_gfx_NativePanZoomController_getRedrawHint_t)(JNIEnv *, jobject);
 static Java_org_mozilla_gecko_gfx_NativePanZoomController_getRedrawHint_t f_Java_org_mozilla_gecko_gfx_NativePanZoomController_getRedrawHint;
-extern "C" NS_EXPORT jboolean JNICALL
+extern "C" NS_EXPORT jboolean MOZ_JNICALL
 Java_org_mozilla_gecko_gfx_NativePanZoomController_getRedrawHint(JNIEnv * arg0, jobject arg1) {
     if (!f_Java_org_mozilla_gecko_gfx_NativePanZoomController_getRedrawHint) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return false;
     }
     return f_Java_org_mozilla_gecko_gfx_NativePanZoomController_getRedrawHint(arg0, arg1);
 }
@@ -492,17 +492,17 @@ Java_org_mozilla_gecko_gfx_NativePanZoom
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_gfx_NativePanZoomController_getRedrawHint", &f_Java_org_mozilla_gecko_gfx_NativePanZoomController_getRedrawHint);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef void (*Java_org_mozilla_gecko_gfx_NativePanZoomController_setOverScrollMode_t)(JNIEnv *, jobject, jint);
 static Java_org_mozilla_gecko_gfx_NativePanZoomController_setOverScrollMode_t f_Java_org_mozilla_gecko_gfx_NativePanZoomController_setOverScrollMode;
-extern "C" NS_EXPORT void JNICALL
+extern "C" NS_EXPORT void MOZ_JNICALL
 Java_org_mozilla_gecko_gfx_NativePanZoomController_setOverScrollMode(JNIEnv * arg0, jobject arg1, jint arg2) {
     if (!f_Java_org_mozilla_gecko_gfx_NativePanZoomController_setOverScrollMode) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return ;
     }
      f_Java_org_mozilla_gecko_gfx_NativePanZoomController_setOverScrollMode(arg0, arg1, arg2);
 }
@@ -511,17 +511,17 @@ Java_org_mozilla_gecko_gfx_NativePanZoom
 #ifdef JNI_BINDINGS
   xul_dlsym("Java_org_mozilla_gecko_gfx_NativePanZoomController_setOverScrollMode", &f_Java_org_mozilla_gecko_gfx_NativePanZoomController_setOverScrollMode);
 #endif
 
 #ifdef JNI_STUBS
 
 typedef jint (*Java_org_mozilla_gecko_gfx_NativePanZoomController_getOverScrollMode_t)(JNIEnv *, jobject);
 static Java_org_mozilla_gecko_gfx_NativePanZoomController_getOverScrollMode_t f_Java_org_mozilla_gecko_gfx_NativePanZoomController_getOverScrollMode;
-extern "C" NS_EXPORT jint JNICALL
+extern "C" NS_EXPORT jint MOZ_JNICALL
 Java_org_mozilla_gecko_gfx_NativePanZoomController_getOverScrollMode(JNIEnv * arg0, jobject arg1) {
     if (!f_Java_org_mozilla_gecko_gfx_NativePanZoomController_getOverScrollMode) {
         arg0->ThrowNew(arg0->FindClass("java/lang/UnsupportedOperationException"),
                        "JNI Function called before it was loaded");
         return 0;
     }
     return f_Java_org_mozilla_gecko_gfx_NativePanZoomController_getOverScrollMode(arg0, arg1);
 }
--- a/mozglue/android/nsGeckoUtils.cpp
+++ b/mozglue/android/nsGeckoUtils.cpp
@@ -8,55 +8,55 @@
 #include <stdlib.h>
 #include <fcntl.h>
 #include "APKOpen.h"
 #include "Zip.h"
 #include "mozilla/RefPtr.h"
 
 extern "C"
 __attribute__ ((visibility("default")))
-void JNICALL
+void MOZ_JNICALL
 Java_org_mozilla_gecko_mozglue_GeckoLoader_putenv(JNIEnv *jenv, jclass, jstring map)
 {
     const char* str;
     // XXX: java doesn't give us true UTF8, we should figure out something
     // better to do here
     str = jenv->GetStringUTFChars(map, nullptr);
     if (str == nullptr)
         return;
     putenv(strdup(str));
     jenv->ReleaseStringUTFChars(map, str);
 }
 
 extern "C"
 __attribute__ ((visibility("default")))
-jobject JNICALL
+jobject MOZ_JNICALL
 Java_org_mozilla_gecko_mozglue_DirectBufferAllocator_nativeAllocateDirectBuffer(JNIEnv *jenv, jclass, jlong size)
 {
     jobject buffer = nullptr;
     void* mem = malloc(size);
     if (mem) {
         buffer = jenv->NewDirectByteBuffer(mem, size);
         if (!buffer)
             free(mem);
     }
     return buffer;
 }
 
 extern "C"
 __attribute__ ((visibility("default")))
-void JNICALL
+void MOZ_JNICALL
 Java_org_mozilla_gecko_mozglue_DirectBufferAllocator_nativeFreeDirectBuffer(JNIEnv *jenv, jclass, jobject buf)
 {
     free(jenv->GetDirectBufferAddress(buf));
 }
 
 extern "C"
 __attribute__ ((visibility("default")))
-jlong JNICALL
+jlong MOZ_JNICALL
 Java_org_mozilla_gecko_mozglue_NativeZip_getZip(JNIEnv *jenv, jclass, jstring path)
 {
     const char* str;
     str = jenv->GetStringUTFChars(path, nullptr);
     if (!str || !*str) {
         if (str)
             jenv->ReleaseStringUTFChars(path, str);
         JNI_Throw(jenv, "java/lang/IllegalArgumentException", "Invalid path");
@@ -69,42 +69,42 @@ Java_org_mozilla_gecko_mozglue_NativeZip
         return 0;
     }
     zip->AddRef();
     return (jlong) zip.get();
 }
 
 extern "C"
 __attribute__ ((visibility("default")))
-jlong JNICALL
+jlong MOZ_JNICALL
 Java_org_mozilla_gecko_mozglue_NativeZip_getZipFromByteBuffer(JNIEnv *jenv, jclass, jobject buffer)
 {
     void *buf = jenv->GetDirectBufferAddress(buffer);
     size_t size = jenv->GetDirectBufferCapacity(buffer);
     mozilla::RefPtr<Zip> zip = Zip::Create(buf, size);
     if (!zip) {
         JNI_Throw(jenv, "java/lang/IllegalArgumentException", "Invalid zip");
         return 0;
     }
     zip->AddRef();
     return (jlong) zip.get();
 }
 
  extern "C"
 __attribute__ ((visibility("default")))
-void JNICALL
+void MOZ_JNICALL
 Java_org_mozilla_gecko_mozglue_NativeZip__1release(JNIEnv *jenv, jclass, jlong obj)
 {
     Zip *zip = (Zip *)obj;
     zip->Release();
 }
 
 extern "C"
 __attribute__ ((visibility("default")))
-jobject JNICALL
+jobject MOZ_JNICALL
 Java_org_mozilla_gecko_mozglue_NativeZip__1getInputStream(JNIEnv *jenv, jobject jzip, jlong obj, jstring path)
 {
     Zip *zip = (Zip *)obj;
     const char* str;
     str = jenv->GetStringUTFChars(path, nullptr);
 
     Zip::Stream stream;
     bool res = zip->GetStream(str, &stream);
--- a/widget/android/jni/Natives.h
+++ b/widget/android/jni/Natives.h
@@ -182,41 +182,48 @@ namespace detail {
 // signatures (jobject vs jclass and Impl::*Method vs *Method).
 // We need specialization for return type, because void return type requires
 // us to not deal with the return value.
 
 template<bool IsStatic, typename ReturnType,
          class Traits, class Impl, class Args>
 class NativeStubImpl;
 
+// Bug 1207642 - Work around Dalvik bug by realigning stack on JNI entry
+#ifdef __i386__
+#define MOZ_JNICALL JNICALL __attribute__((force_align_arg_pointer))
+#else
+#define MOZ_JNICALL JNICALL
+#endif
+
 // Specialization for instance methods with non-void return type
 template<typename ReturnType, class Traits, class Impl, typename... Args>
 class NativeStubImpl<false, ReturnType, Traits, Impl, jni::Args<Args...>>
 {
     typedef typename Traits::Owner Owner;
     typedef typename TypeAdapter<ReturnType>::JNIType ReturnJNIType;
 
 public:
     // Instance method
     template<ReturnType (Impl::*Method) (Args...)>
-    static ReturnJNIType Wrap(JNIEnv* env, jobject instance,
-                              typename TypeAdapter<Args>::JNIType... args)
+    static MOZ_JNICALL ReturnJNIType Wrap(JNIEnv* env,
+            jobject instance, typename TypeAdapter<Args>::JNIType... args)
     {
         Impl* const impl = NativePtr<Impl>::Get(env, instance);
         if (!impl) {
             return ReturnJNIType();
         }
         return TypeAdapter<ReturnType>::FromNative(env,
                 (impl->*Method)(TypeAdapter<Args>::ToNative(env, args)...));
     }
 
     // Instance method with instance reference
     template<ReturnType (Impl::*Method) (const typename Owner::LocalRef&, Args...)>
-    static ReturnJNIType Wrap(JNIEnv* env, jobject instance,
-                              typename TypeAdapter<Args>::JNIType... args)
+    static MOZ_JNICALL ReturnJNIType Wrap(JNIEnv* env,
+            jobject instance, typename TypeAdapter<Args>::JNIType... args)
     {
         Impl* const impl = NativePtr<Impl>::Get(env, instance);
         if (!impl) {
             return ReturnJNIType();
         }
         auto self = Owner::LocalRef::Adopt(env, instance);
         const auto res = TypeAdapter<ReturnType>::FromNative(env,
                 (impl->*Method)(self, TypeAdapter<Args>::ToNative(env, args)...));
@@ -229,30 +236,30 @@ public:
 template<class Traits, class Impl, typename... Args>
 class NativeStubImpl<false, void, Traits, Impl, jni::Args<Args...>>
 {
     typedef typename Traits::Owner Owner;
 
 public:
     // Instance method
     template<void (Impl::*Method) (Args...)>
-    static void Wrap(JNIEnv* env, jobject instance,
-                     typename TypeAdapter<Args>::JNIType... args)
+    static MOZ_JNICALL void Wrap(JNIEnv* env,
+            jobject instance, typename TypeAdapter<Args>::JNIType... args)
     {
         Impl* const impl = NativePtr<Impl>::Get(env, instance);
         if (!impl) {
             return;
         }
         (impl->*Method)(TypeAdapter<Args>::ToNative(env, args)...);
     }
 
     // Instance method with instance reference
     template<void (Impl::*Method) (const typename Owner::LocalRef&, Args...)>
-    static void Wrap(JNIEnv* env, jobject instance,
-                     typename TypeAdapter<Args>::JNIType... args)
+    static MOZ_JNICALL void Wrap(JNIEnv* env,
+            jobject instance, typename TypeAdapter<Args>::JNIType... args)
     {
         Impl* const impl = NativePtr<Impl>::Get(env, instance);
         if (!impl) {
             return;
         }
         auto self = Owner::LocalRef::Adopt(env, instance);
         (impl->*Method)(self, TypeAdapter<Args>::ToNative(env, args)...);
         self.Forget();
@@ -263,53 +270,53 @@ public:
 template<typename ReturnType, class Traits, class Impl, typename... Args>
 class NativeStubImpl<true, ReturnType, Traits, Impl, jni::Args<Args...>>
 {
     typedef typename TypeAdapter<ReturnType>::JNIType ReturnJNIType;
 
 public:
     // Static method
     template<ReturnType (*Method) (Args...)>
-    static ReturnJNIType Wrap(JNIEnv* env, jclass,
-                              typename TypeAdapter<Args>::JNIType... args)
+    static MOZ_JNICALL ReturnJNIType Wrap(JNIEnv* env,
+            jclass, typename TypeAdapter<Args>::JNIType... args)
     {
         return TypeAdapter<ReturnType>::FromNative(env,
                 (*Method)(TypeAdapter<Args>::ToNative(env, args)...));
     }
 
     // Static method with class reference
     template<ReturnType (*Method) (const ClassObject::LocalRef&, Args...)>
-    static ReturnJNIType Wrap(JNIEnv* env, jclass cls,
-                              typename TypeAdapter<Args>::JNIType... args)
+    static MOZ_JNICALL ReturnJNIType Wrap(JNIEnv* env,
+            jclass cls, typename TypeAdapter<Args>::JNIType... args)
     {
         auto clazz = ClassObject::LocalRef::Adopt(env, cls);
         const auto res = TypeAdapter<ReturnType>::FromNative(env,
                 (*Method)(clazz, TypeAdapter<Args>::ToNative(env, args)...));
         clazz.Forget();
         return res;
     }
 };
 
 // Specialization for static methods with void return type
 template<class Traits, class Impl, typename... Args>
 class NativeStubImpl<true, void, Traits, Impl, jni::Args<Args...>>
 {
 public:
     // Static method
     template<void (*Method) (Args...)>
-    static void Wrap(JNIEnv* env, jclass,
-                     typename TypeAdapter<Args>::JNIType... args)
+    static MOZ_JNICALL void Wrap(JNIEnv* env,
+            jclass, typename TypeAdapter<Args>::JNIType... args)
     {
         (*Method)(TypeAdapter<Args>::ToNative(env, args)...);
     }
 
     // Static method with class reference
     template<void (*Method) (const ClassObject::LocalRef&, Args...)>
-    static void Wrap(JNIEnv* env, jclass cls,
-                     typename TypeAdapter<Args>::JNIType... args)
+    static MOZ_JNICALL void Wrap(JNIEnv* env,
+            jclass cls, typename TypeAdapter<Args>::JNIType... args)
     {
         auto clazz = ClassObject::LocalRef::Adopt(env, cls);
         (*Method)(clazz, TypeAdapter<Args>::ToNative(env, args)...);
         clazz.Forget();
     }
 };
 
 } // namespace detail