bug 681602 - Implement xptcall for arm iOS. r=glandium

xptcstubs_arm mostly works on iOS but Apple's assembler is ridiculous so
the inline assembly for the SharedStub and the stub methods needs judicious
preprocessor use.
This commit is contained in:
Ted Mielczarek 2015-09-23 09:57:10 -04:00
parent c4b7c13186
commit 01199f04c1
4 changed files with 53 additions and 33 deletions

View File

@ -9,8 +9,8 @@
#include "mozilla/Compiler.h"
#if !defined(__arm__) && !(defined(LINUX) || defined(ANDROID))
#error "This code is for Linux ARM only. Check that it works on your system, too.\nBeware that this code is highly compiler dependent."
#if !defined(__arm__) && !(defined(LINUX) || defined(ANDROID) || defined(XP_IOS))
#error "This code is for Linux/iOS ARM only. Check that it works on your system, too.\nBeware that this code is highly compiler dependent."
#endif
#if MOZ_IS_GCC

View File

@ -9,6 +9,8 @@
#include "xptcinvoke_x86_64_unix.cpp"
#elif defined(__ppc__)
#include "xptcinvoke_ppc_rhapsody.cpp"
#elif defined(__arm__)
#include "xptcinvoke_arm.cpp"
#else
#error unknown cpu architecture
#endif

View File

@ -8,8 +8,8 @@
#include "xptcprivate.h"
#include "xptiprivate.h"
#if !defined(__arm__) && !(defined(LINUX) || defined(ANDROID))
#error "This code is for Linux ARM only. Please check if it works for you, too.\nDepends strongly on gcc behaviour."
#if !defined(__arm__) && !(defined(LINUX) || defined(ANDROID) || defined(XP_DARWIN))
#error "This code is for Linux/iOS ARM only. Please check if it works for you, too.\nDepends strongly on gcc behaviour."
#endif
/* Specify explicitly a symbol for this function, don't try to guess the c++ mangled symbol. */
@ -22,11 +22,21 @@ ATTRIBUTE_USED;
#define DOUBLEWORD_ALIGN(p) (p)
#endif
// Apple's iOS toolchain is lame and does not support .cfi directives.
// Apple's iOS toolchain is lame.
#ifdef __APPLE__
#define CFI(str)
#define GNU(str)
#define APPLE(str) str
#define UNDERSCORE "__"
#else
#define CFI(str) str
#define GNU(str) str
#define APPLE(str)
#define UNDERSCORE "_"
#endif
#ifdef __thumb__
#define THUMB_FUNC ".thumb_func\n"
#else
#define THUMB_FUNC
#endif
static nsresult
@ -127,27 +137,29 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint32_t* args)
*
*/
__asm__ ("\n"
".text\n"
GNU(".text\n")
APPLE(".section __TEXT,__text\n")
THUMB_FUNC
".align 2\n"
"SharedStub:\n"
".fnstart\n"
CFI(".cfi_startproc\n")
GNU(".fnstart\n")
GNU(".cfi_startproc\n")
"stmfd sp!, {r1, r2, r3}\n"
".save {r1, r2, r3}\n"
CFI(".cfi_def_cfa_offset 12\n")
CFI(".cfi_offset r3, -4\n")
CFI(".cfi_offset r2, -8\n")
CFI(".cfi_offset r1, -12\n")
GNU(".save {r1, r2, r3}\n")
GNU(".cfi_def_cfa_offset 12\n")
GNU(".cfi_offset r3, -4\n")
GNU(".cfi_offset r2, -8\n")
GNU(".cfi_offset r1, -12\n")
"mov r2, sp\n"
"str lr, [sp, #-4]!\n"
".save {lr}\n"
CFI(".cfi_def_cfa_offset 16\n")
CFI(".cfi_offset lr, -16\n")
GNU(".save {lr}\n")
GNU(".cfi_def_cfa_offset 16\n")
GNU(".cfi_offset lr, -16\n")
"mov r1, ip\n"
"bl _PrepareAndDispatch\n"
"ldr pc, [sp], #16\n"
CFI(".cfi_endproc\n")
".fnend");
GNU(".cfi_endproc\n")
GNU(".fnend"));
/*
* Create sets of stubs to call the SharedStub.
@ -171,22 +183,26 @@ __asm__ ("\n"
#define STUB_ENTRY(n) \
__asm__( \
".section \".text\"\n" \
GNU(".section \".text\"\n") \
APPLE(".section __TEXT,__text\n") \
" .align 2\n" \
" .iflt ("#n" - 10)\n" \
" .globl _ZN14nsXPTCStubBase5Stub"#n"Ev\n" \
" .type _ZN14nsXPTCStubBase5Stub"#n"Ev,#function\n" \
"_ZN14nsXPTCStubBase5Stub"#n"Ev:\n" \
" .if ("#n" - 10) < 0\n" \
" .globl " UNDERSCORE "ZN14nsXPTCStubBase5Stub"#n"Ev\n" \
THUMB_FUNC \
GNU(".type _ZN14nsXPTCStubBase5Stub"#n"Ev,#function\n") \
UNDERSCORE "ZN14nsXPTCStubBase5Stub"#n"Ev:\n" \
" .else\n" \
" .iflt ("#n" - 100)\n" \
" .globl _ZN14nsXPTCStubBase6Stub"#n"Ev\n" \
" .type _ZN14nsXPTCStubBase6Stub"#n"Ev,#function\n" \
"_ZN14nsXPTCStubBase6Stub"#n"Ev:\n" \
" .if ("#n" - 100) < 0\n" \
" .globl " UNDERSCORE "ZN14nsXPTCStubBase6Stub"#n"Ev\n" \
THUMB_FUNC \
GNU(".type _ZN14nsXPTCStubBase6Stub"#n"Ev,#function\n") \
UNDERSCORE "ZN14nsXPTCStubBase6Stub"#n"Ev:\n" \
" .else\n" \
" .iflt ("#n" - 1000)\n" \
" .globl _ZN14nsXPTCStubBase7Stub"#n"Ev\n" \
" .type _ZN14nsXPTCStubBase7Stub"#n"Ev,#function\n" \
"_ZN14nsXPTCStubBase7Stub"#n"Ev:\n" \
" .if ("#n" - 1000) < 0\n" \
" .globl " UNDERSCORE "ZN14nsXPTCStubBase7Stub"#n"Ev\n" \
THUMB_FUNC \
GNU(".type _ZN14nsXPTCStubBase7Stub"#n"Ev,#function\n") \
UNDERSCORE "ZN14nsXPTCStubBase7Stub"#n"Ev:\n" \
" .else\n" \
" .err \"stub number "#n"> 1000 not yet supported\"\n" \
" .endif\n" \

View File

@ -9,6 +9,8 @@
#include "xptcstubs_x86_64_darwin.cpp"
#elif defined(__ppc__)
#include "xptcstubs_ppc_rhapsody.cpp"
#elif defined(__arm__)
#include "xptcstubs_arm.cpp"
#else
#error unknown cpu architecture
#endif