Force stack alignment on x86 devices

Summary:
public

JSC enforces a stack-alignment that wasn't always being provided on x86 builds. See D2886997.

Reviewed By: foghina

Differential Revision: D2900982

fb-gh-sync-id: 3f8dffcc1c528a4c21d7ed0b17e49d87761b1df7
This commit is contained in:
Andy Street 2016-02-04 08:38:17 -08:00 committed by facebook-github-bot-7
parent 33d8db599e
commit a0eddff5de
1 changed files with 20 additions and 1 deletions

View File

@ -20,6 +20,25 @@ JSValueRef makeJSCException(
JSContextRef ctx,
const char* exception_text);
JSValueRef evaluateScript(JSContextRef context, JSStringRef script, JSStringRef source, const char *cachePath = nullptr);
#ifdef __i386__
// The Android x86 ABI states that the NDK toolchain assumes 16 byte stack
// alignment: http://developer.android.com/ndk/guides/x86.html JSC checks for
// stack alignment, and fails with SIGTRAP if it is not. Empirically, the
// google android x86 emulator does not provide this alignment, and so JSC
// calls may crash. All checked calls go through here, so the attribute here
// is added to force alignment and prevent crashes.
JSValueRef evaluateScript(
JSContextRef ctx,
JSStringRef script,
JSStringRef sourceURL,
const char* cachePath = nullptr) __attribute__((force_align_arg_pointer));
#else
JSValueRef evaluateScript(
JSContextRef ctx,
JSStringRef script,
JSStringRef sourceURL,
const char* cachePath = nullptr);
#endif
} }