diff options
author | Moonchild <moonchild@palemoon.org> | 2022-06-11 16:07:26 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2022-06-11 16:07:26 +0000 |
commit | 5652238ba898931d9705c9df37259284bb76619e (patch) | |
tree | b5458865163432e6643caf32cae2ed02426048d4 | |
parent | a164537057a031328a3f688cbfa17738aed067b1 (diff) | |
parent | 0c99c0ca2ef926f7cd3af2aafc5c8fe3df82f952 (diff) | |
download | uxp-5652238ba898931d9705c9df37259284bb76619e.tar.gz |
Merge pull request 'Add Apple Silicon (ARM64) Mac Support' (#1915) from dbsoft/UXP:AppleARM into master
Reviewed-on: https://repo.palemoon.org/MoonchildProductions/UXP/pulls/1915
22 files changed, 168 insertions, 224 deletions
diff --git a/aclocal.m4 b/aclocal.m4 index 43ae3a368b..f14ddbf29c 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -25,7 +25,6 @@ builtin(include, build/autoconf/zlib.m4)dnl builtin(include, build/autoconf/icu.m4)dnl builtin(include, build/autoconf/clang-plugin.m4)dnl builtin(include, build/autoconf/alloc.m4)dnl -builtin(include, build/autoconf/ios.m4)dnl builtin(include, build/autoconf/sanitize.m4)dnl MOZ_PROG_CHECKMSYS() diff --git a/build/autoconf/ios.m4 b/build/autoconf/ios.m4 deleted file mode 100644 index b341cda895..0000000000 --- a/build/autoconf/ios.m4 +++ /dev/null @@ -1,108 +0,0 @@ -dnl This Source Code Form is subject to the terms of the Mozilla Public -dnl License, v. 2.0. If a copy of the MPL was not distributed with this -dnl file, You can obtain one at http://mozilla.org/MPL/2.0/. - -AC_DEFUN([MOZ_IOS_PATH_PROG], -[ -changequote({,}) -_prog_name=ifelse($2, {}, `echo $1 | tr "[:upper:]" "[:lower:]"`, $2) -changequote([,]) -AC_CACHE_CHECK([for $_prog_name in iOS SDK], -ac_cv_ios_path_$1, -[ -_path=`xcrun --sdk $ios_sdk --find $_prog_name 2>/dev/null` -_res=$? -if test $_res -ne 0; then - AC_MSG_ERROR([Could not find '$_prog_name' in the iOS SDK]) -fi -ac_cv_ios_path_$1=$_path -]) -$1="${ac_cv_ios_path_$1}$3" -]) - -AC_DEFUN([MOZ_IOS_SDK], -[ - -MOZ_ARG_WITH_STRING(ios-sdk, -[ --with-ios-sdk=TYPE - Type of iOS SDK to use (iphonesimulator, iphoneos) - and optionally version (like iphoneos8.2)], - ios_sdk=$withval) - -MOZ_ARG_ENABLE_STRING(ios-target, - [ --enable-ios-target=VER (default=8.0) - Set the minimum iOS version needed at runtime], - [_IOS_TARGET=$enableval]) -_IOS_TARGET_DEFAULT=8.0 - -case "$target" in -arm*-apple-darwin*) - if test -z "$ios_sdk" -o "$ios_sdk" = "yes"; then - ios_sdk=iphoneos - fi - case "$ios_sdk" in - iphoneos*) - ios_target_arg="-miphoneos-version-min" - ;; - *) - AC_MSG_ERROR([Only 'iphoneos' SDKs are valid when targeting iOS device, don't know what to do with '$ios_sdk'.]) - ;; - esac - ;; -*-apple-darwin*) - ios_target_arg="-mios-simulator-version-min" - case "$ios_sdk" in - # Empty SDK is okay, this might be an OS X desktop build. - ""|iphonesimulator*) - ;; - # Default to iphonesimulator - yes) - ios_sdk=iphonesimulator - ;; - *) - AC_MSG_ERROR([Only 'iphonesimulator' SDKs are valid when targeting iOS simulator.]) - ;; - esac - ;; -esac - - -if test -n "$ios_sdk"; then - if test -z "$_IOS_TARGET"; then - _IOS_TARGET=$_IOS_TARGET_DEFAULT - ios_target_arg="${ios_target_arg}=${_IOS_TARGET}" - fi - # Ensure that xcrun knows where this SDK is. - ios_sdk_path=`xcrun --sdk $ios_sdk --show-sdk-path 2>/dev/null` - _ret=$? - if test $_ret -ne 0; then - AC_MSG_ERROR([iOS SDK '$ios_sdk' could not be found.]) - fi - MOZ_IOS=1 - export HOST_CC=clang - export HOST_CXX=clang++ - # Add isysroot, arch, and ios target arguments - case "$target_cpu" in - arm*) - ARGS="-arch armv7" - ;; - *) - # Unfortunately simulator builds need this. - export CROSS_COMPILE=1 - ;; - esac - ARGS=" $ARGS -isysroot $ios_sdk_path $ios_target_arg" - # Now find our tools - MOZ_IOS_PATH_PROG(CC, clang, $ARGS) - MOZ_IOS_PATH_PROG(CXX, clang++, $ARGS) - export CPP="$CC -E" - export LD="$CXX" - MOZ_IOS_PATH_PROG(AR) - MOZ_IOS_PATH_PROG(AS, as, $ARGS) - MOZ_IOS_PATH_PROG(OTOOL) - MOZ_IOS_PATH_PROG(STRIP) - export PKG_CONFIG_PATH=${ios_sdk_path}/usr/lib/pkgconfig/ -fi - -AC_SUBST(MOZ_IOS) -]) diff --git a/build/autoconf/toolchain.m4 b/build/autoconf/toolchain.m4 index 3109f5dfcf..9fc76a3f6e 100644 --- a/build/autoconf/toolchain.m4 +++ b/build/autoconf/toolchain.m4 @@ -27,6 +27,9 @@ fi if test "`echo | $AS -o conftest.out -v 2>&1 | grep -c GNU`" != "0"; then GNU_AS=1 fi +if test "`echo | $AS -o conftest.out -v 2>&1 | grep -c LLVM`" != "0"; then + GNU_AS=1 +fi rm -f conftest.out if test "`echo | $LD -v 2>&1 | grep -c GNU`" != "0"; then GNU_LD=1 diff --git a/build/gyp_base.mozbuild b/build/gyp_base.mozbuild index a1f8acb099..a97b209a53 100644 --- a/build/gyp_base.mozbuild +++ b/build/gyp_base.mozbuild @@ -16,7 +16,7 @@ if os == 'WINNT': flavors = { 'WINNT': 'win', 'Linux': 'linux', - 'Darwin': 'mac' if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa' else 'ios', + 'Darwin': 'mac', 'SunOS': 'solaris', 'GNU/kFreeBSD': 'freebsd', 'DragonFly': 'dragonfly', diff --git a/build/moz.configure/init.configure b/build/moz.configure/init.configure index f0d6b791b6..b138b79c82 100644 --- a/build/moz.configure/init.configure +++ b/build/moz.configure/init.configure @@ -321,9 +321,6 @@ def split_triplet(triplet): elif os.startswith('darwin'): canonical_kernel = 'Darwin' canonical_os = 'OSX' - elif os.startswith('ios'): - canonical_kernel = 'Darwin' - canonical_os = 'iOS' elif os.startswith('dragonfly'): canonical_os = canonical_kernel = 'DragonFly' elif os.startswith('freebsd'): @@ -455,10 +452,6 @@ add_old_configure_arg(host_for_old_configure) @depends(host, target) def target_for_old_configure(host, target): target_alias = target.alias - # old-configure does plenty of tests against $target and $target_os - # and expects darwin for iOS, so make it happy. - if target.os == 'iOS': - target_alias = target_alias.replace('-ios', '-darwin') return '--target=%s' % target_alias add_old_configure_arg(target_for_old_configure) diff --git a/config/external/ffi/moz.build b/config/external/ffi/moz.build index 32c4506ed5..168f28c0bf 100644 --- a/config/external/ffi/moz.build +++ b/config/external/ffi/moz.build @@ -121,6 +121,8 @@ else: DEFINES['SYMBOL_UNDERSCORE'] = True else: ffi_srcs = ('ffi.c', 'darwin.S', 'ffi64.c', 'darwin64.S') + elif CONFIG['FFI_TARGET'] == 'AARCH64_DARWIN': + ffi_srcs = ('sysv.S', 'ffi.c') SOURCES += [ '/js/src/ctypes/libffi/src/%s/%s' % (CONFIG['FFI_TARGET_DIR'], s) diff --git a/ipc/chromium/src/base/atomicops.h b/ipc/chromium/src/base/atomicops.h index 0883eb35af..66001578f9 100644 --- a/ipc/chromium/src/base/atomicops.h +++ b/ipc/chromium/src/base/atomicops.h @@ -135,7 +135,7 @@ Atomic64 Release_Load(volatile const Atomic64* ptr); // Include our platform specific implementation. #if defined(OS_WIN) && defined(ARCH_CPU_X86_FAMILY) #include "base/atomicops_internals_x86_msvc.h" -#elif defined(OS_MACOSX) && defined(ARCH_CPU_X86_FAMILY) +#elif defined(OS_MACOSX) && (defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM64)) #include "base/atomicops_internals_x86_macosx.h" #elif defined(COMPILER_GCC) && defined(ARCH_CPU_X86_FAMILY) #include "base/atomicops_internals_x86_gcc.h" diff --git a/js/ffi.configure b/js/ffi.configure index 9c60ac3a3c..96b6ad6d69 100644 --- a/js/ffi.configure +++ b/js/ffi.configure @@ -38,8 +38,12 @@ def ffi_target(target): else: target_name = 'X86_WIN32' elif target.os == 'OSX': - target_dir = 'x86' - target_name = 'X86_DARWIN' + if target.cpu == 'aarch64': + target_name = 'AARCH64_DARWIN' + target_dir = 'aarch64' + else: + target_name = 'X86_DARWIN' + target_dir = 'x86' elif target.cpu == 'arm': target_dir = 'arm' target_name = 'ARM' diff --git a/js/src/aclocal.m4 b/js/src/aclocal.m4 index 8b29b284d5..22c0911873 100644 --- a/js/src/aclocal.m4 +++ b/js/src/aclocal.m4 @@ -25,7 +25,6 @@ builtin(include, ../../build/autoconf/icu.m4)dnl builtin(include, ../../build/autoconf/clang-plugin.m4)dnl builtin(include, ../../build/autoconf/alloc.m4)dnl builtin(include, ../../build/autoconf/sanitize.m4)dnl -builtin(include, ../../build/autoconf/ios.m4)dnl define([__MOZ_AC_INIT_PREPARE], defn([AC_INIT_PREPARE])) define([AC_INIT_PREPARE], diff --git a/js/src/wasm/WasmSignalHandlers.cpp b/js/src/wasm/WasmSignalHandlers.cpp index 7699b336cc..36011abe90 100644 --- a/js/src/wasm/WasmSignalHandlers.cpp +++ b/js/src/wasm/WasmSignalHandlers.cpp @@ -283,6 +283,12 @@ struct macos_arm_context { arm_neon_state_t float_; }; # define EMULATOR_CONTEXT macos_arm_context +# elif defined(__aarch64__) +struct macos_aarch64_context { + arm_thread_state64_t thread; + arm_neon_state64_t float_; +}; +# define EMULATOR_CONTEXT macos_aarch64_context # else # error Unsupported architecture # endif @@ -800,7 +806,7 @@ ContextToPC(EMULATOR_CONTEXT* context) static_assert(sizeof(context->thread.uts.ts32.__eip) == sizeof(void*), "stored IP should be compile-time pointer-sized"); return reinterpret_cast<uint8_t**>(&context->thread.uts.ts32.__eip); -# elif defined(JS_CPU_ARM) +# elif defined(JS_CPU_ARM) || defined(__aarch64__) static_assert(sizeof(context->thread.__pc) == sizeof(void*), "stored IP should be compile-time pointer-sized"); return reinterpret_cast<uint8_t**>(&context->thread.__pc); @@ -861,6 +867,11 @@ HandleMachException(JSRuntime* rt, const ExceptionRequest& request) unsigned int float_state_count = ARM_NEON_STATE_COUNT; int thread_state = ARM_THREAD_STATE; int float_state = ARM_NEON_STATE; +# elif defined(__aarch64__) + unsigned int thread_state_count = ARM_THREAD_STATE64_COUNT; + unsigned int float_state_count = ARM_NEON_STATE64_COUNT; + int thread_state = ARM_THREAD_STATE64; + int float_state = ARM_NEON_STATE64; # else # error Unsupported architecture # endif diff --git a/nsprpub/pr/include/md/_darwin.h b/nsprpub/pr/include/md/_darwin.h index 1d79d3d82d..c6340ce2d5 100644 --- a/nsprpub/pr/include/md/_darwin.h +++ b/nsprpub/pr/include/md/_darwin.h @@ -40,7 +40,7 @@ #undef HAVE_STACK_GROWING_UP #define HAVE_DLL -#if defined(__x86_64__) || TARGET_OS_IPHONE +#if defined(__x86_64__) || defined(__aarch64__) #define USE_DLFCN #else #define USE_MACH_DYLD diff --git a/old-configure.in b/old-configure.in index f848e720e4..e575f65fa5 100644 --- a/old-configure.in +++ b/old-configure.in @@ -95,12 +95,6 @@ case "$target" in ;; esac -case "$target" in -*-apple-darwin*) - MOZ_IOS_SDK - ;; -esac - AC_SUBST(OBJCOPY) dnl ======================================================== @@ -775,27 +769,11 @@ case "$target" in DLL_SUFFIX=".dylib" DSO_LDOPTS='' STRIP_FLAGS="$STRIP_FLAGS -x -S" - # Ensure that if we're targeting iOS an SDK was provided. - AC_CACHE_CHECK(for iOS target, - ac_cv_ios_target, - [AC_TRY_COMPILE([#include <TargetConditionals.h> -#if !(TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR) -#error not iOS -#endif], - [], - ac_cv_ios_target="yes", - ac_cv_ios_target="no")]) - if test "$ac_cv_ios_target" = "yes" -a -z $MOZ_IOS; then - AC_MSG_ERROR([targeting iOS but not using an iOS SDK?]) - fi - if test -n "$MOZ_IOS"; then - direct_nspr_config=1 - else - # The ExceptionHandling framework is needed for Objective-C exception - # logging code in nsObjCExceptions.h. Currently we only use that in debug - # builds. - MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling"; - fi + + # The ExceptionHandling framework is needed for Objective-C exception + # logging code in nsObjCExceptions.h. Currently we only use that in debug + # builds. + MOZ_DEBUG_LDFLAGS="$MOZ_DEBUG_LDFLAGS -framework ExceptionHandling"; if test "x$lto_is_enabled" = "xyes"; then echo "Skipping -dead_strip because lto is enabled." @@ -2027,9 +2005,6 @@ MOZ_OFFICIAL_BRANDING= MC_OFFICIAL= MOZ_FEEDS=1 MOZ_AUTH_EXTENSION=1 -if test "$MOZ_IOS"; then - MOZ_AUTH_EXTENSION= -fi MOZ_RAW= MOZ_AV1= MOZ_VORBIS= @@ -3015,10 +2990,6 @@ MOZ_ARG_DISABLE_BOOL(negotiateauth, MOZ_AUTH_EXTENSION=, MOZ_AUTH_EXTENSION=1 ) -if test -n "$MOZ_IOS" -a -n "$MOZ_AUTH_EXTENSION"; then - AC_MSG_ERROR([negotiateauth is not supported on iOS.]) -fi - dnl ======================================================== dnl Pref extensions (autoconfig) dnl ======================================================== @@ -3171,9 +3142,7 @@ MOZ_ARG_ENABLE_BOOL(gamepad, if test "$MOZ_GAMEPAD"; then case "$OS_TARGET" in Darwin) - if test -z "$MOZ_IOS"; then - MOZ_GAMEPAD_BACKEND=cocoa - fi + MOZ_GAMEPAD_BACKEND=cocoa ;; WINNT) MOZ_GAMEPAD_BACKEND=windows @@ -3487,10 +3456,6 @@ dnl ======================================================== dnl Updater dnl ======================================================== -if test "$MOZ_IOS"; then - MOZ_UPDATER= -fi - MOZ_ARG_ENABLE_BOOL(updater, [ --enable-updater Enable building of internal updater], MOZ_UPDATER=1, @@ -4638,9 +4603,7 @@ MOZ_ARG_DISABLE_BOOL(necko-wifi, if test "$MOZ_NECKO_WIFI"; then case "$OS_TARGET" in Darwin) - if test -z "$MOZ_IOS"; then - NECKO_WIFI=1 - fi + NECKO_WIFI=1 ;; DragonFly|FreeBSD|WINNT) NECKO_WIFI=1 diff --git a/python/virtualenv/virtualenv.py b/python/virtualenv/virtualenv.py index 655e25cf01..d22207e257 100755 --- a/python/virtualenv/virtualenv.py +++ b/python/virtualenv/virtualenv.py @@ -1345,6 +1345,9 @@ def install_python(home_dir, lib_dir, inc_dir, bin_dir, site_packages, clear, sy "have Apple's development tools installed") raise + # Resign the executable, since install_name_tool invalidates the signature + call_subprocess(["codesign", "-s", "-", py_executable]) + if not is_win: # Ensure that 'python', 'pythonX' and 'pythonX.Y' all exist py_exe_version_major = 'python%s' % sys.version_info[0] diff --git a/widget/cocoa/nsChildView.h b/widget/cocoa/nsChildView.h index 2817c8d415..7b998a6c5c 100644 --- a/widget/cocoa/nsChildView.h +++ b/widget/cocoa/nsChildView.h @@ -224,7 +224,6 @@ class WidgetRenderingContext; enter:(BOOL)aEnter exitFrom:(mozilla::WidgetMouseEvent::ExitFrom)aExitFrom; -- (void)updateGLContext; - (void)_surfaceNeedsUpdate:(NSNotification*)notification; - (bool)preRender:(NSOpenGLContext *)aGLContext; diff --git a/widget/cocoa/nsChildView.mm b/widget/cocoa/nsChildView.mm index e2aa6729e9..a3a3bacbf9 100644 --- a/widget/cocoa/nsChildView.mm +++ b/widget/cocoa/nsChildView.mm @@ -3309,16 +3309,11 @@ NSEvent* gLastDragMouseDownEvent = nil; if (!mGLContext) { mGLContext = aGLContext; [mGLContext retain]; - mNeedsGLUpdate = true; + mNeedsGLUpdate = YES; } CGLLockContext((CGLContextObj)[aGLContext CGLContextObj]); - if (mNeedsGLUpdate) { - [self updateGLContext]; - mNeedsGLUpdate = NO; - } - return true; NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(false); @@ -3472,12 +3467,6 @@ NSEvent* gLastDragMouseDownEvent = nil; return YES; } --(void)updateGLContext -{ - [mGLContext setView:mPixelHostingView]; - [mGLContext update]; -} - - (void)_surfaceNeedsUpdate:(NSNotification*)notification { if (mGLContext) { @@ -3592,6 +3581,13 @@ NSEvent* gLastDragMouseDownEvent = nil; LayoutDeviceIntRegion region(geckoBounds); mGeckoChild->PaintWindow(region); + + if (mNeedsGLUpdate) { + [mGLContext setView:mPixelHostingView]; + [mGLContext update]; + mNeedsGLUpdate = NO; + } + return; } diff --git a/xpcom/build/moz.build b/xpcom/build/moz.build index c58b4db3f5..93e89e537b 100644 --- a/xpcom/build/moz.build +++ b/xpcom/build/moz.build @@ -37,8 +37,9 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa': 'PoisonIOInterposerBase.cpp', 'PoisonIOInterposerMac.cpp', ] - SOURCES += ['mach_override.c'] - SOURCES['mach_override.c'].flags += ['-Wno-unused-function'] + if CONFIG["CPU_ARCH"] != "aarch64": + SOURCES += ['mach_override.c'] + SOURCES['mach_override.c'].flags += ['-Wno-unused-function'] else: SOURCES += ['PoisonIOInterposerStub.cpp'] diff --git a/xpcom/glue/FileUtils.cpp b/xpcom/glue/FileUtils.cpp index 8057cf8cb1..d735964624 100644 --- a/xpcom/glue/FileUtils.cpp +++ b/xpcom/glue/FileUtils.cpp @@ -281,6 +281,8 @@ static const uint32_t CPU_TYPE = CPU_TYPE_X86_64; static const uint32_t CPU_TYPE = CPU_TYPE_POWERPC; #elif defined(__ppc64__) static const uint32_t CPU_TYPE = CPU_TYPE_POWERPC64; +#elif defined(__aarch64__) +static const uint32_t CPU_TYPE = CPU_TYPE_ARM64; #else #error Unsupported CPU type #endif diff --git a/xpcom/reflect/xptcall/md/unix/moz.build b/xpcom/reflect/xptcall/md/unix/moz.build index afab3acd2b..7ab7e73654 100644 --- a/xpcom/reflect/xptcall/md/unix/moz.build +++ b/xpcom/reflect/xptcall/md/unix/moz.build @@ -17,6 +17,11 @@ if CONFIG['OS_ARCH'] == 'Darwin': SOURCES += [ 'xptcinvoke_asm_x86_64_unix.S', ] + if CONFIG["CPU_ARCH"] == "aarch64": + SOURCES += [ + "xptcinvoke_asm_aarch64.S", + "xptcstubs_asm_aarch64.S", + ] if '86' in CONFIG['OS_TEST'] and CONFIG['OS_TEST'] != 'x86_64': DEFINES['MOZ_NEED_LEADING_UNDERSCORE'] = True @@ -105,9 +110,9 @@ if CONFIG['OS_ARCH'] in ('Linux', 'FreeBSD', 'NetBSD', 'OpenBSD'): if CONFIG['OS_TEST'] == 'aarch64': SOURCES += [ 'xptcinvoke_aarch64.cpp', - 'xptcinvoke_asm_aarch64.s', + 'xptcinvoke_asm_aarch64.S', 'xptcstubs_aarch64.cpp', - 'xptcstubs_asm_aarch64.s', + 'xptcstubs_asm_aarch64.S', ] if CONFIG['OS_TEST'] == 'm68k': SOURCES += [ diff --git a/xpcom/reflect/xptcall/md/unix/xptcinvoke_asm_aarch64.s b/xpcom/reflect/xptcall/md/unix/xptcinvoke_asm_aarch64.S index efe691a683..69a55b1c1c 100644 --- a/xpcom/reflect/xptcall/md/unix/xptcinvoke_asm_aarch64.s +++ b/xpcom/reflect/xptcall/md/unix/xptcinvoke_asm_aarch64.S @@ -3,20 +3,36 @@ * 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/. */ - .section ".text" - .globl _NS_InvokeByIndex +#ifdef __APPLE__ +#define SYM(x) _ ## x +#else +#define SYM(x) x +#endif + + .text + .align 2 + .globl SYM(_NS_InvokeByIndex) +#ifndef __APPLE__ .type _NS_InvokeByIndex,@function +#endif /* * _NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex, * uint32_t paramCount, nsXPTCVariant* params) */ -_NS_InvokeByIndex: +SYM(_NS_InvokeByIndex): + .cfi_startproc # set up frame stp x29, x30, [sp,#-32]! + .cfi_adjust_cfa_offset 32 + .cfi_rel_offset x29, 0 + .cfi_rel_offset x30, 8 mov x29, sp + .cfi_def_cfa_register x29 stp x19, x20, [sp,#16] + .cfi_rel_offset x19, 16 + .cfi_rel_offset x20, 24 # save methodIndex across function calls mov w20, w1 @@ -37,7 +53,7 @@ _NS_InvokeByIndex: # start of stack area passed to invoke_copy_to_stack mov x0, sp - bl invoke_copy_to_stack + bl SYM(invoke_copy_to_stack) # load arguments passed in r0-r7 ldp x6, x7, [sp, #48] @@ -58,10 +74,19 @@ _NS_InvokeByIndex: blr x16 add sp, sp, w19, uxth #3 + .cfi_def_cfa_register sp ldp x19, x20, [sp,#16] + .cfi_restore x19 + .cfi_restore x20 ldp x29, x30, [sp],#32 + .cfi_adjust_cfa_offset -32 + .cfi_restore x29 + .cfi_restore x30 ret + .cfi_endproc +#ifndef __APPLE__ .size _NS_InvokeByIndex, . - _NS_InvokeByIndex - + .section .note.GNU-stack, "", @progbits +#endif diff --git a/xpcom/reflect/xptcall/md/unix/xptcstubs_aarch64.cpp b/xpcom/reflect/xptcall/md/unix/xptcstubs_aarch64.cpp index 571fb42a2f..271ea4b019 100644 --- a/xpcom/reflect/xptcall/md/unix/xptcstubs_aarch64.cpp +++ b/xpcom/reflect/xptcall/md/unix/xptcstubs_aarch64.cpp @@ -10,6 +10,19 @@ #error "Only little endian compatibility was tested" #endif +template<typename T> void +get_value_and_advance(T* aOutValue, void*& aStack) { +#ifdef __APPLE__ + const size_t aligned_size = sizeof(T); +#else + const size_t aligned_size = 8; +#endif + // Ensure the pointer is aligned for the type + uintptr_t addr = (reinterpret_cast<uintptr_t>(aStack) + aligned_size - 1) & ~(aligned_size - 1); + memcpy(aOutValue, reinterpret_cast<void*>(addr), sizeof(T)); + aStack = reinterpret_cast<void*>(addr + aligned_size); +} + /* * This is for AArch64 ABI * @@ -17,8 +30,8 @@ * the "fp" registers are stored in fprData. Each array has 8 regs * but first reg in gprData is a placeholder for 'self'. */ -extern "C" nsresult -PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args, +extern "C" nsresult ATTRIBUTE_USED +PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, void* args, uint64_t *gprData, double *fprData) { #define PARAM_BUFFER_COUNT 16 @@ -28,7 +41,6 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args, nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT]; nsXPTCMiniVariant* dispatchParams = NULL; const nsXPTMethodInfo* info; - nsresult result = NS_ERROR_FAILURE; NS_ASSERTION(self,"no self"); @@ -45,7 +57,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args, } NS_ASSERTION(dispatchParams,"no place for params"); - uint64_t* ap = args; + void* ap = args; uint32_t next_gpr = 1; // skip first arg which is 'self' uint32_t next_fpr = 0; for (uint32_t i = 0; i < paramCount; i++) { @@ -57,7 +69,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args, if (next_gpr < PARAM_GPR_COUNT) { dp->val.p = (void*)gprData[next_gpr++]; } else { - dp->val.p = (void*)*ap++; + get_value_and_advance(&dp->val.p, ap); } continue; } @@ -67,7 +79,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args, if (next_gpr < PARAM_GPR_COUNT) { dp->val.i8 = (int8_t)gprData[next_gpr++]; } else { - dp->val.i8 = (int8_t)*ap++; + get_value_and_advance(&dp->val.i8, ap); } break; @@ -75,7 +87,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args, if (next_gpr < PARAM_GPR_COUNT) { dp->val.i16 = (int16_t)gprData[next_gpr++]; } else { - dp->val.i16 = (int16_t)*ap++; + get_value_and_advance(&dp->val.i16, ap); } break; @@ -83,7 +95,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args, if (next_gpr < PARAM_GPR_COUNT) { dp->val.i32 = (int32_t)gprData[next_gpr++]; } else { - dp->val.i32 = (int32_t)*ap++; + get_value_and_advance(&dp->val.i32, ap); } break; @@ -91,7 +103,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args, if (next_gpr < PARAM_GPR_COUNT) { dp->val.i64 = (int64_t)gprData[next_gpr++]; } else { - dp->val.i64 = (int64_t)*ap++; + get_value_and_advance(&dp->val.i64, ap); } break; @@ -99,7 +111,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args, if (next_gpr < PARAM_GPR_COUNT) { dp->val.u8 = (uint8_t)gprData[next_gpr++]; } else { - dp->val.u8 = (uint8_t)*ap++; + get_value_and_advance(&dp->val.u8, ap); } break; @@ -107,7 +119,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args, if (next_gpr < PARAM_GPR_COUNT) { dp->val.u16 = (uint16_t)gprData[next_gpr++]; } else { - dp->val.u16 = (uint16_t)*ap++; + get_value_and_advance(&dp->val.u16, ap); } break; @@ -115,7 +127,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args, if (next_gpr < PARAM_GPR_COUNT) { dp->val.u32 = (uint32_t)gprData[next_gpr++]; } else { - dp->val.u32 = (uint32_t)*ap++; + get_value_and_advance(&dp->val.u32, ap); } break; @@ -123,7 +135,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args, if (next_gpr < PARAM_GPR_COUNT) { dp->val.u64 = (uint64_t)gprData[next_gpr++]; } else { - dp->val.u64 = (uint64_t)*ap++; + get_value_and_advance(&dp->val.u64, ap); } break; @@ -131,7 +143,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args, if (next_fpr < PARAM_FPR_COUNT) { memcpy(&dp->val.f, &fprData[next_fpr++], sizeof(dp->val.f)); } else { - memcpy(&dp->val.f, ap++, sizeof(dp->val.f)); + get_value_and_advance(&dp->val.f, ap); } break; @@ -139,15 +151,17 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args, if (next_fpr < PARAM_FPR_COUNT) { memcpy(&dp->val.d, &fprData[next_fpr++], sizeof(dp->val.d)); } else { - memcpy(&dp->val.d, ap++, sizeof(dp->val.d)); + get_value_and_advance(&dp->val.d, ap); } break; case nsXPTType::T_BOOL: if (next_gpr < PARAM_GPR_COUNT) { - dp->val.b = (bool)gprData[next_gpr++]; + dp->val.b = (bool)(uint8_t)gprData[next_gpr++]; } else { - dp->val.b = (bool)*ap++; + uint8_t value; + get_value_and_advance(&value, ap); + dp->val.b = (bool)value; } break; @@ -155,7 +169,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args, if (next_gpr < PARAM_GPR_COUNT) { dp->val.c = (char)gprData[next_gpr++]; } else { - dp->val.c = (char)*ap++; + get_value_and_advance(&dp->val.c, ap); } break; @@ -163,7 +177,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args, if (next_gpr < PARAM_GPR_COUNT) { dp->val.wc = (wchar_t)gprData[next_gpr++]; } else { - dp->val.wc = (wchar_t)*ap++; + get_value_and_advance(&dp->val.wc, ap); } break; @@ -173,7 +187,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args, } } - result = self->mOuter->CallMethod((uint16_t)methodIndex, info, dispatchParams); + nsresult result = self->mOuter->CallMethod((uint16_t)methodIndex, info, dispatchParams); if (dispatchParams != paramBuffer) { delete [] dispatchParams; @@ -182,26 +196,34 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args, return result; } +#ifdef __APPLE__ +#define GNU(str) +#define UNDERSCORE "__" +#else +#define GNU(str) str +#define UNDERSCORE "_" +#endif + // Load w17 with the constant 'n' and branch to SharedStub(). # define STUB_ENTRY(n) \ __asm__ ( \ - ".section \".text\" \n\t" \ + ".text\n\t" \ ".align 2\n\t" \ ".if "#n" < 10 \n\t" \ - ".globl _ZN14nsXPTCStubBase5Stub"#n"Ev \n\t" \ - ".hidden _ZN14nsXPTCStubBase5Stub"#n"Ev \n\t" \ - ".type _ZN14nsXPTCStubBase5Stub"#n"Ev,@function \n\n" \ - "_ZN14nsXPTCStubBase5Stub"#n"Ev: \n\t" \ + ".globl " UNDERSCORE "ZN14nsXPTCStubBase5Stub"#n"Ev \n\t" \ + GNU(".hidden _ZN14nsXPTCStubBase5Stub"#n"Ev \n\t") \ + GNU(".type _ZN14nsXPTCStubBase5Stub"#n"Ev,@function \n\n")\ + "" UNDERSCORE "ZN14nsXPTCStubBase5Stub"#n"Ev: \n\t" \ ".elseif "#n" < 100 \n\t" \ - ".globl _ZN14nsXPTCStubBase6Stub"#n"Ev \n\t" \ - ".hidden _ZN14nsXPTCStubBase6Stub"#n"Ev \n\t" \ - ".type _ZN14nsXPTCStubBase6Stub"#n"Ev,@function \n\n" \ - "_ZN14nsXPTCStubBase6Stub"#n"Ev: \n\t" \ + ".globl " UNDERSCORE "ZN14nsXPTCStubBase6Stub"#n"Ev \n\t" \ + GNU(".hidden _ZN14nsXPTCStubBase6Stub"#n"Ev \n\t") \ + GNU(".type _ZN14nsXPTCStubBase6Stub"#n"Ev,@function \n\n")\ + "" UNDERSCORE "ZN14nsXPTCStubBase6Stub"#n"Ev: \n\t" \ ".elseif "#n" < 1000 \n\t" \ - ".globl _ZN14nsXPTCStubBase7Stub"#n"Ev \n\t" \ - ".hidden _ZN14nsXPTCStubBase7Stub"#n"Ev \n\t" \ - ".type _ZN14nsXPTCStubBase7Stub"#n"Ev,@function \n\n" \ - "_ZN14nsXPTCStubBase7Stub"#n"Ev: \n\t" \ + ".globl " UNDERSCORE "ZN14nsXPTCStubBase7Stub"#n"Ev \n\t" \ + GNU(".hidden _ZN14nsXPTCStubBase7Stub"#n"Ev \n\t") \ + GNU(".type _ZN14nsXPTCStubBase7Stub"#n"Ev,@function \n\n")\ + UNDERSCORE "ZN14nsXPTCStubBase7Stub"#n"Ev: \n\t" \ ".else \n\t" \ ".err \"stub number "#n" >= 1000 not yet supported\"\n" \ ".endif \n\t" \ diff --git a/xpcom/reflect/xptcall/md/unix/xptcstubs_asm_aarch64.s b/xpcom/reflect/xptcall/md/unix/xptcstubs_asm_aarch64.S index 6603a4f25b..f2394aa316 100644 --- a/xpcom/reflect/xptcall/md/unix/xptcstubs_asm_aarch64.s +++ b/xpcom/reflect/xptcall/md/unix/xptcstubs_asm_aarch64.S @@ -2,16 +2,30 @@ # 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/. +#ifdef __APPLE__ +#define SYM(x) _ ## x +#else +#define SYM(x) x +#endif + .set NGPREGS,8 .set NFPREGS,8 - .section ".text" + .text + .align 2 .globl SharedStub +#ifndef __APPLE__ .hidden SharedStub .type SharedStub,@function +#endif SharedStub: + .cfi_startproc stp x29, x30, [sp,#-16]! + .cfi_adjust_cfa_offset 16 + .cfi_rel_offset x29, 0 + .cfi_rel_offset x30, 8 mov x29, sp + .cfi_def_cfa_register x29 sub sp, sp, #8*(NGPREGS+NFPREGS) stp x0, x1, [sp, #64+(0*8)] @@ -30,10 +44,19 @@ SharedStub: add x3, sp, #8*NFPREGS add x4, sp, #0 - bl PrepareAndDispatch + bl SYM(PrepareAndDispatch) add sp, sp, #8*(NGPREGS+NFPREGS) + .cfi_def_cfa_register sp ldp x29, x30, [sp],#16 + .cfi_adjust_cfa_offset -16 + .cfi_restore x29 + .cfi_restore x30 ret + .cfi_endproc +#ifndef __APPLE__ .size SharedStub, . - SharedStub + + .section .note.GNU-stack, "", @progbits +#endif diff --git a/xpcom/reflect/xptcall/md/unix/xptcstubs_darwin.cpp b/xpcom/reflect/xptcall/md/unix/xptcstubs_darwin.cpp index 49edfca440..3d1addedaf 100644 --- a/xpcom/reflect/xptcall/md/unix/xptcstubs_darwin.cpp +++ b/xpcom/reflect/xptcall/md/unix/xptcstubs_darwin.cpp @@ -11,6 +11,8 @@ #include "xptcstubs_ppc_rhapsody.cpp" #elif defined(__arm__) #include "xptcstubs_arm.cpp" +#elif defined(__aarch64__) +#include "xptcstubs_aarch64.cpp" #else #error unknown cpu architecture #endif |