summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Smith <brian@dbsoft.org>2022-06-09 22:05:20 -0500
committerBrian Smith <brian@dbsoft.org>2022-06-09 22:05:20 -0500
commita977ba55eb80984b38c8f9a31778c948afa55c20 (patch)
tree9c45e3d721b9b3808c190f225cbd73f0c8f51bb5
parent8199a0d551455314809de775164d592c5a4aad9d (diff)
downloaduxp-a977ba55eb80984b38c8f9a31778c948afa55c20.tar.gz
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.
-rw-r--r--config/external/ffi/moz.build2
-rw-r--r--js/ffi.configure7
-rw-r--r--js/src/wasm/WasmSignalHandlers.cpp13
-rw-r--r--xpcom/reflect/xptcall/md/unix/xptcstubs_aarch64.cpp29
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 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/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 = &paramBuffer[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;
}