From 7224a179032e83a87d3e2102a3bcb45212022417 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Sat, 4 Jun 2022 17:13:45 -0500 Subject: [PATCH 01/14] Issue #1905 - Part 2c - Fix OpenGL crash caused by calling [NSOpenGLContext setView:] on the Compositor thread. Starting with SDK 10.14 I believe, many functions have main thread checks, including setView: and update. So we now move the code in the updateGLContext method into doDrawRect which runs on the main thread. --- widget/cocoa/nsChildView.h | 1 - widget/cocoa/nsChildView.mm | 20 ++++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) 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; } From 9f3376e56dc21e9aa181847fa959c4dc03823572 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Thu, 9 Jun 2022 14:12:00 -0500 Subject: [PATCH 02/14] Issue #1905 - Part 3a - Resign python binary ad-hoc since install_name_tool invalidates code signature. The code signature is invalidated on Intel as well, but on ARM the binary fails to run with an invalid code signature error. --- python/virtualenv/virtualenv.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/virtualenv/virtualenv.py b/python/virtualenv/virtualenv.py index 655e25cf01..d22207e257 100644 --- 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] From a2f6708c4d43ec2673db08862d152cf18ea2af2c Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Thu, 9 Jun 2022 14:19:05 -0500 Subject: [PATCH 03/14] Issue #1905 - Part 3b - Remove iOS support from old-configure. iOS is not really a viable target and Apple Silicon Macs report the same core system. --- old-configure.in | 51 +++++++----------------------------------------- 1 file changed, 7 insertions(+), 44 deletions(-) diff --git a/old-configure.in b/old-configure.in index a23c549663..5fea6d4c2c 100644 --- a/old-configure.in +++ b/old-configure.in @@ -96,12 +96,6 @@ case "$target" in ;; esac -case "$target" in -*-apple-darwin*) - MOZ_IOS_SDK - ;; -esac - AC_SUBST(ANDROID_SOURCE) AC_SUBST(ANDROID_PACKAGE_NAME) AC_SUBST(OBJCOPY) @@ -787,27 +781,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 -#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." @@ -2084,9 +2062,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= @@ -3092,10 +3067,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 ======================================================== @@ -3326,9 +3297,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 @@ -3645,10 +3614,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, @@ -4852,9 +4817,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 From 02ceb3e1a31c7dfb820c36c240b68072e26bf0ea Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Thu, 9 Jun 2022 14:35:28 -0500 Subject: [PATCH 04/14] Issue #1905 - Part 3c - Remove iOS from the rest of the configure system. --- aclocal.m4 | 1 - build/autoconf/ios.m4 | 108 ----------------------------- build/moz.configure/init.configure | 7 -- 3 files changed, 116 deletions(-) delete mode 100644 build/autoconf/ios.m4 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/moz.configure/init.configure b/build/moz.configure/init.configure index 0874e4b935..372d034cd4 100644 --- a/build/moz.configure/init.configure +++ b/build/moz.configure/init.configure @@ -324,9 +324,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'): @@ -458,10 +455,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) From ccdf07735ae3d91444ffe316486d1e3cc48e9128 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Thu, 9 Jun 2022 14:38:33 -0500 Subject: [PATCH 05/14] Issue #1905 - Part 3d - Report GNU AS when the system "as" is LLVM-as. LLVM as is generally compatible with GNU, this should allow ICU to build on ARM Macs. --- build/autoconf/toolchain.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/autoconf/toolchain.m4 b/build/autoconf/toolchain.m4 index 3109f5dfcf..5940e9698a 100644 --- a/build/autoconf/toolchain.m4 +++ b/build/autoconf/toolchain.m4 @@ -24,7 +24,7 @@ if test "$CC_TYPE" = "gcc"; then GNU_CXX=1 fi -if test "`echo | $AS -o conftest.out -v 2>&1 | grep -c GNU`" != "0"; then +if test "`echo | $AS -o conftest.out -v 2>&1 | grep -c GNU|LLVM`" != "0"; then GNU_AS=1 fi rm -f conftest.out From e73d4de0b4307d8a30ba2ac95e3f04f387114c41 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Thu, 9 Jun 2022 14:57:21 -0500 Subject: [PATCH 06/14] Issue #1905 - Part 3e - Fix NSPR build on ARM. The dynamic loader had been falling through to the ancient PowerPC code without __aarch64__ #ifdef --- nsprpub/pr/include/md/_darwin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From e55ae571da4421e0aa7cb1cf71cb49746a082092 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Thu, 9 Jun 2022 18:08:04 -0500 Subject: [PATCH 07/14] Issue #1905 - Part 3f - Collection of fixes connecting ARM support to the Mac build. Also update ARM XPT code to add Mac/Apple support. --- ipc/chromium/src/base/atomicops.h | 2 +- xpcom/build/moz.build | 5 +- xpcom/glue/FileUtils.cpp | 2 + xpcom/reflect/xptcall/md/unix/moz.build | 5 + .../xptcall/md/unix/xptcinvoke_asm_aarch64.s | 35 +++++- .../xptcall/md/unix/xptcstubs_aarch64.cpp | 115 ++++++++++-------- .../xptcall/md/unix/xptcstubs_asm_aarch64.s | 27 +++- .../xptcall/md/unix/xptcstubs_darwin.cpp | 2 + 8 files changed, 135 insertions(+), 58 deletions(-) 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/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..80c1c23045 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 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..d535557259 100644 --- a/xpcom/reflect/xptcall/md/unix/xptcstubs_aarch64.cpp +++ b/xpcom/reflect/xptcall/md/unix/xptcstubs_aarch64.cpp @@ -4,12 +4,24 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "xptcprivate.h" -#include "xptiprivate.h" #ifndef __AARCH64EL__ #error "Only little endian compatibility was tested" #endif +template 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(aStack) + aligned_size - 1) & ~(aligned_size - 1); + memcpy(aOutValue, reinterpret_cast(addr), sizeof(T)); + aStack = reinterpret_cast(addr + aligned_size); +} + /* * This is for AArch64 ABI * @@ -17,18 +29,15 @@ * 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 #define PARAM_GPR_COUNT 8 #define PARAM_FPR_COUNT 8 nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT]; - nsXPTCMiniVariant* dispatchParams = NULL; const nsXPTMethodInfo* info; - nsresult result = NS_ERROR_FAILURE; NS_ASSERTION(self,"no self"); @@ -37,27 +46,30 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args, uint32_t paramCount = info->GetParamCount(); - // setup variant array pointer - if (paramCount > PARAM_BUFFER_COUNT) { - dispatchParams = new nsXPTCMiniVariant[paramCount]; - } else { - dispatchParams = paramBuffer; - } - NS_ASSERTION(dispatchParams,"no place for params"); + const uint8_t indexOfJSContext = info->IndexOfJSContext(); - 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++) { const nsXPTParamInfo& param = info->GetParam(i); const nsXPTType& type = param.GetType(); - nsXPTCMiniVariant* dp = &dispatchParams[i]; + nsXPTCMiniVariant* dp = ¶mBuffer[i]; + + if (i == indexOfJSContext) { + if (next_gpr < PARAM_GPR_COUNT) + next_gpr++; + else { + void* value; + get_value_and_advance(&value, ap); + } + } if (param.IsOut() || !type.IsArithmetic()) { 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,35 +187,40 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args, } } - result = self->mOuter->CallMethod((uint16_t)methodIndex, info, dispatchParams); - - if (dispatchParams != paramBuffer) { - delete [] dispatchParams; - } + nsresult result = self->mOuter->CallMethod((uint16_t)methodIndex, info, + paramBuffer); 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 From be240b34037bb9df1aa7c4505fc5a3964a64b458 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Thu, 9 Jun 2022 22:05:20 -0500 Subject: [PATCH 08/14] Issue #1905 - Part 3g - Final set of changes connecting ARM64 support for Mac. Back out some of the xptcstubs changes that are not viable for our codebase. --- config/external/ffi/moz.build | 2 ++ js/ffi.configure | 7 +++-- js/src/wasm/WasmSignalHandlers.cpp | 13 ++++++++- .../xptcall/md/unix/xptcstubs_aarch64.cpp | 29 ++++++++++--------- 4 files changed, 35 insertions(+), 16 deletions(-) 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/js/ffi.configure b/js/ffi.configure index 9c60ac3a3c..749b5f7010 100644 --- a/js/ffi.configure +++ b/js/ffi.configure @@ -38,8 +38,11 @@ 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' + else: + target_name = 'X86_DARWIN' + target_dir = 'aarch64' elif target.cpu == 'arm': target_dir = 'arm' target_name = 'ARM' diff --git a/js/src/wasm/WasmSignalHandlers.cpp b/js/src/wasm/WasmSignalHandlers.cpp index b7bb024bca..119f31dc6a 100644 --- a/js/src/wasm/WasmSignalHandlers.cpp +++ b/js/src/wasm/WasmSignalHandlers.cpp @@ -370,6 +370,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 @@ -887,7 +893,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(&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(&context->thread.__pc); @@ -948,6 +954,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/xpcom/reflect/xptcall/md/unix/xptcstubs_aarch64.cpp b/xpcom/reflect/xptcall/md/unix/xptcstubs_aarch64.cpp index d535557259..271ea4b019 100644 --- a/xpcom/reflect/xptcall/md/unix/xptcstubs_aarch64.cpp +++ b/xpcom/reflect/xptcall/md/unix/xptcstubs_aarch64.cpp @@ -4,6 +4,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "xptcprivate.h" +#include "xptiprivate.h" #ifndef __AARCH64EL__ #error "Only little endian compatibility was tested" @@ -33,10 +34,12 @@ extern "C" nsresult ATTRIBUTE_USED PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, void* args, uint64_t *gprData, double *fprData) { +#define PARAM_BUFFER_COUNT 16 #define PARAM_GPR_COUNT 8 #define PARAM_FPR_COUNT 8 nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT]; + nsXPTCMiniVariant* dispatchParams = NULL; const nsXPTMethodInfo* info; NS_ASSERTION(self,"no self"); @@ -46,7 +49,13 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, void* args, uint32_t paramCount = info->GetParamCount(); - const uint8_t indexOfJSContext = info->IndexOfJSContext(); + // setup variant array pointer + if (paramCount > PARAM_BUFFER_COUNT) { + dispatchParams = new nsXPTCMiniVariant[paramCount]; + } else { + dispatchParams = paramBuffer; + } + NS_ASSERTION(dispatchParams,"no place for params"); void* ap = args; uint32_t next_gpr = 1; // skip first arg which is 'self' @@ -54,16 +63,7 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, void* args, for (uint32_t i = 0; i < paramCount; i++) { const nsXPTParamInfo& param = info->GetParam(i); const nsXPTType& type = param.GetType(); - nsXPTCMiniVariant* dp = ¶mBuffer[i]; - - if (i == indexOfJSContext) { - if (next_gpr < PARAM_GPR_COUNT) - next_gpr++; - else { - void* value; - get_value_and_advance(&value, ap); - } - } + nsXPTCMiniVariant* dp = &dispatchParams[i]; if (param.IsOut() || !type.IsArithmetic()) { if (next_gpr < PARAM_GPR_COUNT) { @@ -187,8 +187,11 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, void* args, } } - nsresult result = self->mOuter->CallMethod((uint16_t)methodIndex, info, - paramBuffer); + nsresult result = self->mOuter->CallMethod((uint16_t)methodIndex, info, dispatchParams); + + if (dispatchParams != paramBuffer) { + delete [] dispatchParams; + } return result; } From 5bf1ed59533b1285261411313fbcba67b8425bbc Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Fri, 10 Jun 2022 01:28:08 -0500 Subject: [PATCH 09/14] Issue #1905 - Part 3h - Fix breakages on other platforms. Mac Intel broke due to incorrect FFI target_dir for Intel. Linux and possibly other platforms use a secondary aclocal.m4 that still referenced ios.m4. --- js/ffi.configure | 3 ++- js/src/aclocal.m4 | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/ffi.configure b/js/ffi.configure index 749b5f7010..96b6ad6d69 100644 --- a/js/ffi.configure +++ b/js/ffi.configure @@ -40,9 +40,10 @@ def ffi_target(target): elif target.os == 'OSX': if target.cpu == 'aarch64': target_name = 'AARCH64_DARWIN' + target_dir = 'aarch64' else: target_name = 'X86_DARWIN' - target_dir = 'aarch64' + 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], From 06aa3c8c37fba81ac57efed681d67d191b10968d Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Fri, 10 Jun 2022 01:53:05 -0500 Subject: [PATCH 10/14] Issue #1905 - Part 3i - Rename the ARM64 assembly files to .S. Necessary because they now need to be preprocessed. --- .../unix/{xptcinvoke_asm_aarch64.s => xptcinvoke_asm_aarch64.S} | 0 .../md/unix/{xptcstubs_asm_aarch64.s => xptcstubs_asm_aarch64.S} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename xpcom/reflect/xptcall/md/unix/{xptcinvoke_asm_aarch64.s => xptcinvoke_asm_aarch64.S} (100%) rename xpcom/reflect/xptcall/md/unix/{xptcstubs_asm_aarch64.s => xptcstubs_asm_aarch64.S} (100%) diff --git a/xpcom/reflect/xptcall/md/unix/xptcinvoke_asm_aarch64.s b/xpcom/reflect/xptcall/md/unix/xptcinvoke_asm_aarch64.S similarity index 100% rename from xpcom/reflect/xptcall/md/unix/xptcinvoke_asm_aarch64.s rename to xpcom/reflect/xptcall/md/unix/xptcinvoke_asm_aarch64.S diff --git a/xpcom/reflect/xptcall/md/unix/xptcstubs_asm_aarch64.s b/xpcom/reflect/xptcall/md/unix/xptcstubs_asm_aarch64.S similarity index 100% rename from xpcom/reflect/xptcall/md/unix/xptcstubs_asm_aarch64.s rename to xpcom/reflect/xptcall/md/unix/xptcstubs_asm_aarch64.S From 076a0eb275859b12925368df7cfe7eb5796d8dc3 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Fri, 10 Jun 2022 02:00:29 -0500 Subject: [PATCH 11/14] Issue #1905 - Part 3j - Rename the ARM64 assembly files to .S. Missed the moz.build file in the last commit. --- xpcom/reflect/xptcall/md/unix/moz.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xpcom/reflect/xptcall/md/unix/moz.build b/xpcom/reflect/xptcall/md/unix/moz.build index 80c1c23045..7ab7e73654 100644 --- a/xpcom/reflect/xptcall/md/unix/moz.build +++ b/xpcom/reflect/xptcall/md/unix/moz.build @@ -110,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 += [ From 163bce2e81c3851965a4be80f64d7339eed8ed08 Mon Sep 17 00:00:00 2001 From: Brian Smith Date: Fri, 10 Jun 2022 16:33:04 -0500 Subject: [PATCH 12/14] Issue #1905 - Part 3k - Separate the GNU and LLVM-as tests. While we should be able to test these together, I don't want to risk breakages on different *nixes. --- build/autoconf/toolchain.m4 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build/autoconf/toolchain.m4 b/build/autoconf/toolchain.m4 index 5940e9698a..9fc76a3f6e 100644 --- a/build/autoconf/toolchain.m4 +++ b/build/autoconf/toolchain.m4 @@ -24,7 +24,10 @@ if test "$CC_TYPE" = "gcc"; then GNU_CXX=1 fi -if test "`echo | $AS -o conftest.out -v 2>&1 | grep -c GNU|LLVM`" != "0"; then +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 From afbfbcb1e19e0824984e2d8642ae4b299785887d Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 10 Jun 2022 07:35:22 +0000 Subject: [PATCH 13/14] Issue #1914 - Implement white-space: break-spaces This also simplifies GetCSSWhitespaceToCompressionMode (FFS with the function names, Mozilla!) to be less fragile. --- .../shared/css/generated/properties-db.js | 1 + gfx/thebes/gfxTextRun.cpp | 16 ++++-- gfx/thebes/gfxTextRun.h | 1 + layout/generic/nsTextFrame.cpp | 52 +++++++++---------- layout/style/nsCSSKeywordList.h | 1 + layout/style/nsCSSProps.cpp | 1 + layout/style/nsStyleConsts.h | 13 ++--- layout/style/nsStyleStruct.h | 7 ++- layout/style/test/property_database.js | 2 +- 9 files changed, 57 insertions(+), 37 deletions(-) diff --git a/devtools/shared/css/generated/properties-db.js b/devtools/shared/css/generated/properties-db.js index 5a7e6d815d..9ccebc8481 100644 --- a/devtools/shared/css/generated/properties-db.js +++ b/devtools/shared/css/generated/properties-db.js @@ -9519,6 +9519,7 @@ exports.CSS_PROPERTIES = { "supports": [], "values": [ "-moz-pre-space", + "break-spaces", "inherit", "initial", "normal", diff --git a/gfx/thebes/gfxTextRun.cpp b/gfx/thebes/gfxTextRun.cpp index fd97615366..438f6f61ae 100644 --- a/gfx/thebes/gfxTextRun.cpp +++ b/gfx/thebes/gfxTextRun.cpp @@ -851,6 +851,7 @@ gfxTextRun::BreakAndMeasureText(uint32_t aStart, uint32_t aMaxLength, bool *aUsedHyphenation, uint32_t *aLastBreak, bool aCanWordWrap, + bool aCanWhitespaceWrap, gfxBreakPriority *aBreakPriority) { aMaxLength = std::min(aMaxLength, GetLength() - aStart); @@ -918,7 +919,15 @@ gfxTextRun::BreakAndMeasureText(uint32_t aStart, uint32_t aMaxLength, aCanWordWrap && mCharacterGlyphs[i].IsClusterStart() && *aBreakPriority <= gfxBreakPriority::eWordWrapBreak; - if (atBreak || wordWrapping) { + bool whitespaceWrapping = false; + if (i > aStart) { + // The spec says the breaking opportunity is *after* whitespace. + auto const& g = mCharacterGlyphs[i - 1]; + whitespaceWrapping = aCanWhitespaceWrap && + (g.CharIsSpace() || g.CharIsTab() || g.CharIsNewline()); + } + + if (atBreak || wordWrapping || whitespaceWrapping) { gfxFloat hyphenatedAdvance = advance; if (atHyphenationBreak) { hyphenatedAdvance += aProvider->GetHyphenWidth(); @@ -930,8 +939,9 @@ gfxTextRun::BreakAndMeasureText(uint32_t aStart, uint32_t aMaxLength, lastBreakTrimmableChars = trimmableChars; lastBreakTrimmableAdvance = trimmableAdvance; lastBreakUsedHyphenation = atHyphenationBreak; - *aBreakPriority = atBreak ? gfxBreakPriority::eNormalBreak - : gfxBreakPriority::eWordWrapBreak; + *aBreakPriority = (atBreak || whitespaceWrapping) + ? gfxBreakPriority::eNormalBreak + : gfxBreakPriority::eWordWrapBreak; } width += advance; diff --git a/gfx/thebes/gfxTextRun.h b/gfx/thebes/gfxTextRun.h index d61992527b..2ef835f189 100644 --- a/gfx/thebes/gfxTextRun.h +++ b/gfx/thebes/gfxTextRun.h @@ -409,6 +409,7 @@ public: bool *aUsedHyphenation, uint32_t *aLastBreak, bool aCanWordWrap, + bool aCanWhitespaceWrap, gfxBreakPriority *aBreakPriority); // Utility getters diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 07e7a36557..1fccf48a18 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -1988,35 +1988,31 @@ GetHyphenTextRun(const gfxTextRun* aTextRun, DrawTarget* aDrawTarget, MakeHyphenTextRun(dt, aTextRun->GetAppUnitsPerDevUnit()); } -static_assert(NS_STYLE_WHITESPACE_NORMAL == 0, "Convention: NS_STYLE_WHITESPACE_NORMAL should be 0"); -static_assert(NS_STYLE_WHITESPACE_PRE == 1, "Convention: NS_STYLE_WHITESPACE_PRE should be 1"); -static_assert(NS_STYLE_WHITESPACE_NOWRAP == 2, "Convention: NS_STYLE_WHITESPACE_NOWRAP should be 2"); -static_assert(NS_STYLE_WHITESPACE_PRE_WRAP == 3, "Convention: NS_STYLE_WHITESPACE_PRE_WRAP should be 3"); -static_assert(NS_STYLE_WHITESPACE_PRE_LINE == 4, "Convention: NS_STYLE_WHITESPACE_PRE_LINE should be 4"); -static_assert(NS_STYLE_WHITESPACE_PRE_SPACE == 5, "Convention: NS_STYLE_WHITESPACE_PRE_SPACE should be 5"); - static nsTextFrameUtils::CompressionMode GetCSSWhitespaceToCompressionMode(nsTextFrame* aFrame, const nsStyleText* aStyleText) { - static const nsTextFrameUtils::CompressionMode sModes[] = - { - nsTextFrameUtils::COMPRESS_WHITESPACE_NEWLINE, // normal - nsTextFrameUtils::COMPRESS_NONE, // pre - nsTextFrameUtils::COMPRESS_WHITESPACE_NEWLINE, // nowrap - nsTextFrameUtils::COMPRESS_NONE, // pre-wrap - nsTextFrameUtils::COMPRESS_WHITESPACE, // pre-line - nsTextFrameUtils::COMPRESS_NONE_TRANSFORM_TO_SPACE // -moz-pre-space - }; - - auto compression = sModes[aStyleText->mWhiteSpace]; - if (compression == nsTextFrameUtils::COMPRESS_NONE && - !aStyleText->NewlineIsSignificant(aFrame)) { - // If newline is set to be preserved, but then suppressed, - // transform newline to space. - compression = nsTextFrameUtils::COMPRESS_NONE_TRANSFORM_TO_SPACE; + switch (aStyleText->mWhiteSpace) { + case NS_STYLE_WHITESPACE_NORMAL: + case NS_STYLE_WHITESPACE_NOWRAP: + return nsTextFrameUtils::COMPRESS_WHITESPACE_NEWLINE; + case NS_STYLE_WHITESPACE_PRE: + case NS_STYLE_WHITESPACE_PRE_WRAP: + case NS_STYLE_WHITESPACE_BREAK_SPACES: + if (!aStyleText->NewlineIsSignificant(aFrame)) { + // If newline is set to be preserved, but then suppressed, + // transform newline to space. + return nsTextFrameUtils::COMPRESS_NONE_TRANSFORM_TO_SPACE; + } + return nsTextFrameUtils::COMPRESS_NONE; + case NS_STYLE_WHITESPACE_PRE_SPACE: + return nsTextFrameUtils::COMPRESS_NONE_TRANSFORM_TO_SPACE; + case NS_STYLE_WHITESPACE_PRE_LINE: + return nsTextFrameUtils::COMPRESS_WHITESPACE; + default: + MOZ_ASSERT_UNREACHABLE("Unknown white-space value"); + return nsTextFrameUtils::COMPRESS_WHITESPACE_NEWLINE; } - return compression; } already_AddRefed @@ -9206,8 +9202,10 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth, } bool canTrimTrailingWhitespace = !textStyle->WhiteSpaceIsSignificant() || (GetStateBits() & TEXT_IS_IN_TOKEN_MATHML); + bool isBreakSpaces = textStyle->mWhiteSpace == NS_STYLE_WHITESPACE_BREAK_SPACES; // allow whitespace to overflow the container - bool whitespaceCanHang = textStyle->WhiteSpaceCanWrapStyle() && + bool whitespaceCanHang = !isBreakSpaces && + textStyle->WhiteSpaceCanWrapStyle() && textStyle->WhiteSpaceIsSignificant(); gfxBreakPriority breakPriority = aLineLayout.LastOptionalBreakPriority(); gfxTextRun::SuppressBreak suppressBreak = gfxTextRun::eNoSuppressBreak; @@ -9227,7 +9225,9 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth, &textMetrics, boundingBoxType, aDrawTarget, &usedHyphenation, &transformedLastBreak, - textStyle->WordCanWrap(this), &breakPriority); + textStyle->WordCanWrap(this), + isBreakSpaces, + &breakPriority); if (!length && !textMetrics.mAscent && !textMetrics.mDescent) { // If we're measuring a zero-length piece of text, update // the height manually. diff --git a/layout/style/nsCSSKeywordList.h b/layout/style/nsCSSKeywordList.h index 7e661bc483..d6486b18cf 100644 --- a/layout/style/nsCSSKeywordList.h +++ b/layout/style/nsCSSKeywordList.h @@ -171,6 +171,7 @@ CSS_KEY(both, both) CSS_KEY(bottom, bottom) CSS_KEY(bottom-outside, bottom_outside) CSS_KEY(break-all, break_all) +CSS_KEY(break-spaces, break_spaces) CSS_KEY(break-word, break_word) CSS_KEY(brightness, brightness) CSS_KEY(browser, browser) diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp index ec6cd978e9..ca506fe0c5 100644 --- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -2253,6 +2253,7 @@ const KTableEntry nsCSSProps::kWhitespaceKTable[] = { { eCSSKeyword_pre_wrap, NS_STYLE_WHITESPACE_PRE_WRAP }, { eCSSKeyword_pre_line, NS_STYLE_WHITESPACE_PRE_LINE }, { eCSSKeyword__moz_pre_space, NS_STYLE_WHITESPACE_PRE_SPACE }, + { eCSSKeyword_break_spaces, NS_STYLE_WHITESPACE_BREAK_SPACES }, { eCSSKeyword_UNKNOWN, -1 } }; diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index 7f2463733e..e9063b595e 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -995,12 +995,13 @@ enum class StyleDisplay : uint8_t { #define NS_STYLE_TABSIZE_INITIAL 8 // See nsStyleText -#define NS_STYLE_WHITESPACE_NORMAL 0 -#define NS_STYLE_WHITESPACE_PRE 1 -#define NS_STYLE_WHITESPACE_NOWRAP 2 -#define NS_STYLE_WHITESPACE_PRE_WRAP 3 -#define NS_STYLE_WHITESPACE_PRE_LINE 4 -#define NS_STYLE_WHITESPACE_PRE_SPACE 5 +#define NS_STYLE_WHITESPACE_NORMAL 0 +#define NS_STYLE_WHITESPACE_PRE 1 +#define NS_STYLE_WHITESPACE_NOWRAP 2 +#define NS_STYLE_WHITESPACE_PRE_WRAP 3 +#define NS_STYLE_WHITESPACE_PRE_LINE 4 +#define NS_STYLE_WHITESPACE_PRE_SPACE 5 +#define NS_STYLE_WHITESPACE_BREAK_SPACES 6 // See nsStyleText #define NS_STYLE_WORDBREAK_NORMAL 0 diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index a01685cc44..da9643594e 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -2105,30 +2105,35 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleText bool WhiteSpaceIsSignificant() const { return mWhiteSpace == NS_STYLE_WHITESPACE_PRE || mWhiteSpace == NS_STYLE_WHITESPACE_PRE_WRAP || + mWhiteSpace == NS_STYLE_WHITESPACE_BREAK_SPACES || mWhiteSpace == NS_STYLE_WHITESPACE_PRE_SPACE; } bool NewlineIsSignificantStyle() const { return mWhiteSpace == NS_STYLE_WHITESPACE_PRE || mWhiteSpace == NS_STYLE_WHITESPACE_PRE_WRAP || + mWhiteSpace == NS_STYLE_WHITESPACE_BREAK_SPACES || mWhiteSpace == NS_STYLE_WHITESPACE_PRE_LINE; } bool WhiteSpaceOrNewlineIsSignificant() const { return mWhiteSpace == NS_STYLE_WHITESPACE_PRE || mWhiteSpace == NS_STYLE_WHITESPACE_PRE_WRAP || + mWhiteSpace == NS_STYLE_WHITESPACE_BREAK_SPACES || mWhiteSpace == NS_STYLE_WHITESPACE_PRE_LINE || mWhiteSpace == NS_STYLE_WHITESPACE_PRE_SPACE; } bool TabIsSignificant() const { return mWhiteSpace == NS_STYLE_WHITESPACE_PRE || - mWhiteSpace == NS_STYLE_WHITESPACE_PRE_WRAP; + mWhiteSpace == NS_STYLE_WHITESPACE_PRE_WRAP || + mWhiteSpace == NS_STYLE_WHITESPACE_BREAK_SPACES; } bool WhiteSpaceCanWrapStyle() const { return mWhiteSpace == NS_STYLE_WHITESPACE_NORMAL || mWhiteSpace == NS_STYLE_WHITESPACE_PRE_WRAP || + mWhiteSpace == NS_STYLE_WHITESPACE_BREAK_SPACES || mWhiteSpace == NS_STYLE_WHITESPACE_PRE_LINE; } diff --git a/layout/style/test/property_database.js b/layout/style/test/property_database.js index 5c6e2f6d86..0abe930832 100644 --- a/layout/style/test/property_database.js +++ b/layout/style/test/property_database.js @@ -4052,7 +4052,7 @@ var gCSSProperties = { inherited: true, type: CSS_TYPE_LONGHAND, initial_values: [ "normal" ], - other_values: [ "pre", "nowrap", "pre-wrap", "pre-line", "-moz-pre-space" ], + other_values: [ "pre", "nowrap", "pre-wrap", "pre-line", "-moz-pre-space", "break-spaces" ], invalid_values: [] }, "width": { From 41b9919e7c2ec507b0c8ee2b241dbe1d07169ab0 Mon Sep 17 00:00:00 2001 From: Jeremy Andrews Date: Wed, 8 Jun 2022 15:15:42 -0500 Subject: [PATCH 14/14] Issue #1909 - Ensure UpdateChecker and UpdateParser can handle empty manifest URLs. --- .../mozapps/extensions/internal/AddonUpdateChecker.jsm | 8 ++++++++ toolkit/mozapps/extensions/internal/XPIProvider.jsm | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm b/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm index a475f7f1fa..6710c6a70f 100644 --- a/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm +++ b/toolkit/mozapps/extensions/internal/AddonUpdateChecker.jsm @@ -611,6 +611,14 @@ function UpdateParser(aId, aUpdateKey, aUrl, aObserver) { let requireBuiltIn = Services.prefs.getBoolPref(PREF_UPDATE_REQUIREBUILTINCERTS, true); logger.debug("Requesting " + aUrl); + + if (!aUrl) { + logger.warn("Request failed: empty update manifest URL"); + this._doneAt = new Error("UP_emptyManifestURL"); + this.notifyError(AddonUpdateChecker.ERROR_DOWNLOAD_ERROR); + return; + } + try { this.request = new ServiceRequest(); this.request.open("GET", this.url, true); diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm index 690351be1d..fb41087e18 100644 --- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm @@ -6134,6 +6134,15 @@ function UpdateChecker(aAddon, aListener, aReason, aAppVersion, aPlatformVersion aReason |= UPDATE_TYPE_COMPATIBILITY; if ("onUpdateAvailable" in this.listener) aReason |= UPDATE_TYPE_NEWVERSION; + + // Pass an empty string as the url and call checkForUpdates now if + // updateURL is empty. UpdateParser should detect this and fail early. + + if (!updateURL) { + this._parser = AddonUpdateChecker.checkForUpdates(aAddon.id, aAddon.updateKey, + "", this); + return; + } let url = escapeAddonURI(aAddon, updateURL, aReason, aAppVersion); this._parser = AddonUpdateChecker.checkForUpdates(aAddon.id, aAddon.updateKey,