Skip to content

Commit

Permalink
Force stack alignment on x86 devices
Browse files Browse the repository at this point in the history
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
  • Loading branch information
astreet authored and facebook-github-bot-7 committed Feb 4, 2016
1 parent 33d8db5 commit a0eddff
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion ReactAndroid/src/main/jni/react/JSCHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

} }

0 comments on commit a0eddff

Please sign in to comment.