forked from amazingfate/loongoffice
Use the same code as for Linux on aarch64, with minor additional hacks. But that will not actually work in all cases, as there are slight differences in the ABI. See https://developer.apple.com/library/archive/documentation/Xcode/Conceptual/iPhoneOSABIReference/Articles/ARM64FunctionCallingConventions.html Thus we can drop the use of the lo_mobile_throwException() hack that was very temporarily used. The run-time code generation requires use of a new API on macOS to work: See the use of pthread_jit_write_protect_np() in bridges/source/cpp_uno/shared/vtablefactory.cxx. For some reason, with the Xcode 12 betas, when compiling for arm64-apple-macos, the symbols for the type_infos for the UNO exception types (_ZTIN3com3sun4star3uno16RuntimeExceptionE etc) end up as "weak private external" in the object file, as displayed by "nm -f darwin". We try to look them up with dlsym(), but that then fails. So use a gross hack: Introduce separate real variables that point to these typeinfos, and look up and dereference them instead. If this hack ends up needing to be permanent, instead of having a manually edited set of such pointer variables, we should teach codemaker to generate corresponding functions, and look up and invoke them to get the std::type_info pointer. When compiling for x86_64-apple-macos, the type_info symbols end up as "weak external" which is fine. With this, LibreOffice starts and seems to work to some extent, and many unit tests succeed. Change-Id: I05f46a122a51ade1ac7dccd57cb90e594547740e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100408 Tested-by: Jenkins Reviewed-by: Tor Lillqvist <tml@collabora.com>
70 lines
2.6 KiB
C++
70 lines
2.6 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
/*
|
|
* This file is part of the LibreOffice project.
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* 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/.
|
|
*
|
|
* This file incorporates work covered by the following license notice:
|
|
*
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
* with this work for additional information regarding copyright
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
* except in compliance with the License. You may obtain a copy of
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
*/
|
|
|
|
#include <sal/config.h>
|
|
|
|
#include <cstring>
|
|
|
|
#include <sal/types.h>
|
|
#include <sal/alloca.h>
|
|
|
|
#include "callvirtualfunction.hxx"
|
|
|
|
void callVirtualFunction(
|
|
unsigned long function, unsigned long * gpr, unsigned long * fpr,
|
|
unsigned long * stack, sal_Int32 sp, void * ret)
|
|
{
|
|
void * stackargs;
|
|
if (sp != 0) {
|
|
stackargs = alloca(((sp + 1) >> 1) * 16);
|
|
std::memcpy(stackargs, stack, sp * 8);
|
|
}
|
|
asm volatile(
|
|
"ldp x0, x1, [%[gpr_]]\n\t"
|
|
"ldp x2, x3, [%[gpr_], #16]\n\t"
|
|
"ldp x4, x5, [%[gpr_], #32]\n\t"
|
|
"ldp x6, x7, [%[gpr_], #48]\n\t"
|
|
"ldr x8, %[ret_]\n\t"
|
|
"ldr x9, %[function_]\n\t"
|
|
"ldp d0, d1, [%[fpr_]]\n\t"
|
|
"ldp d2, d3, [%[fpr_], #16]\n\t"
|
|
"ldp d4, d5, [%[fpr_], #32]\n\t"
|
|
"ldp d6, d7, [%[fpr_], #48]\n\t"
|
|
"blr x9\n\t"
|
|
"stp x0, x1, [%[gpr_]]\n\t"
|
|
"stp d0, d1, [%[fpr_]]\n\t"
|
|
"stp d2, d3, [%[fpr_], #16]\n\t"
|
|
:: [gpr_]"r" (gpr), [fpr_]"r" (fpr), [function_]"m" (function),
|
|
[ret_]"m" (ret),
|
|
"m" (stackargs) // dummy input to prevent optimizing the alloca away
|
|
: "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
|
|
"r11", "r12", "r13", "r14", "r15", "r16", "r17",
|
|
#if !defined ANDROID && !defined MACOSX
|
|
"r18"/*TODO?*/,
|
|
#endif
|
|
"v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11",
|
|
"v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19", "v20", "v21",
|
|
"v22", "v23", "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
|
|
"memory"
|
|
// only the bottom 64 bits of v8--15 need to be preserved by callees
|
|
);
|
|
}
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|