diff options
author | jan Iversen <jani@libreoffice.org> | 2018-02-15 15:55:30 +0100 |
---|---|---|
committer | jan Iversen <jani@libreoffice.org> | 2018-02-15 15:58:58 +0100 |
commit | 9a62dcf333b2e9b470d5aa1b5c2ddaae6732ad32 (patch) | |
tree | 8d73d32a26f8e85bd4f1b4f64f0173d5fd51d80a /bridges/source | |
parent | 0310430ed0455418cfe85e150f14496aff724897 (diff) |
iOS, reduce arm64 files to actually needed
Still comparing the "old" gcc3_ios_arm with the new one, in order to make
the asm code work.
Change-Id: I3a2fdfc1891a6a4d7065917f5ef8bd19c49b3987
Diffstat (limited to 'bridges/source')
-rw-r--r-- | bridges/source/cpp_uno/gcc3_ios/abi.cxx | 328 | ||||
-rw-r--r-- | bridges/source/cpp_uno/gcc3_ios/abi.hxx | 61 | ||||
-rw-r--r-- | bridges/source/cpp_uno/gcc3_ios/call.cxx | 78 | ||||
-rw-r--r-- | bridges/source/cpp_uno/gcc3_ios/call.hxx | 37 | ||||
-rw-r--r-- | bridges/source/cpp_uno/gcc3_ios/callvirtualmethod.cxx | 180 | ||||
-rw-r--r-- | bridges/source/cpp_uno/gcc3_ios/callvirtualmethod.hxx | 40 |
6 files changed, 0 insertions, 724 deletions
diff --git a/bridges/source/cpp_uno/gcc3_ios/abi.cxx b/bridges/source/cpp_uno/gcc3_ios/abi.cxx deleted file mode 100644 index 042a857bae32..000000000000 --- a/bridges/source/cpp_uno/gcc3_ios/abi.cxx +++ /dev/null @@ -1,328 +0,0 @@ -/* -*- 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 . - */ -#ifdef __x86_64 - -// This is an implementation of the x86-64 ABI as described in 'System V -// Application Binary Interface, AMD64 Architecture Processor Supplement' -// (http://www.x86-64.org/documentation/abi-0.95.pdf) -// -// The code in this file is a modification of src/x86/ffi64.c from libffi -// (http://sources.redhat.com/libffi/) which is under the following license: - -/* ----------------------------------------------------------------------- - ffi.c - Copyright (c) 2002 Bo Thorsen <bo@suse.de> - - x86-64 Foreign Function Interface - - Permission is hereby granted, free of charge, to any person obtaining - a copy of this software and associated documentation files (the - ``Software''), to deal in the Software without restriction, including - without limitation the rights to use, copy, modify, merge, publish, - distribute, sublicense, and/or sell copies of the Software, and to - permit persons to whom the Software is furnished to do so, subject to - the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL CYGNUS SOLUTIONS BE LIABLE FOR ANY CLAIM, DAMAGES OR - OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - OTHER DEALINGS IN THE SOFTWARE. - ----------------------------------------------------------------------- */ - -#include "sal/config.h" - -#include "abi.hxx" - -#include <sal/log.hxx> - -using namespace x86_64; - -/* Register class used for passing given 64bit part of the argument. - These represent classes as documented by the PS ABI, with the exception - of SSESF, SSEDF classes, that are basically SSE class, just gcc will - use SF or DFmode move instead of DImode to avoid reformatting penalties. - - Similarly we play games with INTEGERSI_CLASS to use cheaper SImode moves - whenever possible (upper half does contain padding). - */ -enum x86_64_reg_class -{ - X86_64_NO_CLASS, - X86_64_INTEGER_CLASS, - X86_64_INTEGERSI_CLASS, - X86_64_SSE_CLASS, - X86_64_SSESF_CLASS, - X86_64_SSEDF_CLASS, - X86_64_SSEUP_CLASS, - X86_64_X87_CLASS, - X86_64_X87UP_CLASS, - X86_64_MEMORY_CLASS -}; - -#define MAX_CLASSES 4 - -/* x86-64 register passing implementation. See x86-64 ABI for details. Goal - of this code is to classify each 8bytes of incoming argument by the register - class and assign registers accordingly. */ - -/* Return the union class of CLASS1 and CLASS2. - See the x86-64 PS ABI for details. */ - -static enum x86_64_reg_class -merge_classes (enum x86_64_reg_class class1, enum x86_64_reg_class class2) - throw () -{ - /* Rule #1: If both classes are equal, this is the resulting class. */ - if (class1 == class2) - return class1; - - /* Rule #2: If one of the classes is NO_CLASS, the resulting class is - the other class. */ - if (class1 == X86_64_NO_CLASS) - return class2; - if (class2 == X86_64_NO_CLASS) - return class1; - - /* Rule #3: If one of the classes is MEMORY, the result is MEMORY. */ - if (class1 == X86_64_MEMORY_CLASS || class2 == X86_64_MEMORY_CLASS) - return X86_64_MEMORY_CLASS; - - /* Rule #4: If one of the classes is INTEGER, the result is INTEGER. */ - if ((class1 == X86_64_INTEGERSI_CLASS && class2 == X86_64_SSESF_CLASS) - || (class2 == X86_64_INTEGERSI_CLASS && class1 == X86_64_SSESF_CLASS)) - return X86_64_INTEGERSI_CLASS; - if (class1 == X86_64_INTEGER_CLASS || class1 == X86_64_INTEGERSI_CLASS - || class2 == X86_64_INTEGER_CLASS || class2 == X86_64_INTEGERSI_CLASS) - return X86_64_INTEGER_CLASS; - - /* Rule #5: If one of the classes is X87 or X87UP class, MEMORY is used. */ - if (class1 == X86_64_X87_CLASS || class1 == X86_64_X87UP_CLASS - || class2 == X86_64_X87_CLASS || class2 == X86_64_X87UP_CLASS) - return X86_64_MEMORY_CLASS; - - /* Rule #6: Otherwise class SSE is used. */ - return X86_64_SSE_CLASS; -} - -/* Classify the argument of type TYPE and mode MODE. - CLASSES will be filled by the register class used to pass each word - of the operand. The number of words is returned. In case the parameter - should be passed in memory, 0 is returned. As a special case for zero - sized containers, classes[0] will be NO_CLASS and 1 is returned. - - See the x86-64 PS ABI for details. -*/ -static int -classify_argument( typelib_TypeDescriptionReference *pTypeRef, enum x86_64_reg_class classes[], int byteOffset ) throw () -{ - switch ( pTypeRef->eTypeClass ) - { - case typelib_TypeClass_VOID: - classes[0] = X86_64_NO_CLASS; - return 1; - case typelib_TypeClass_CHAR: - case typelib_TypeClass_BOOLEAN: - case typelib_TypeClass_BYTE: - case typelib_TypeClass_SHORT: - case typelib_TypeClass_UNSIGNED_SHORT: - case typelib_TypeClass_LONG: - case typelib_TypeClass_UNSIGNED_LONG: - case typelib_TypeClass_HYPER: - case typelib_TypeClass_UNSIGNED_HYPER: - case typelib_TypeClass_ENUM: - if ( ( byteOffset % 8 + pTypeRef->pType->nSize ) <= 4 ) - classes[0] = X86_64_INTEGERSI_CLASS; - else - classes[0] = X86_64_INTEGER_CLASS; - return 1; - case typelib_TypeClass_FLOAT: - if ( ( byteOffset % 8 ) == 0 ) - classes[0] = X86_64_SSESF_CLASS; - else - classes[0] = X86_64_SSE_CLASS; - return 1; - case typelib_TypeClass_DOUBLE: - classes[0] = X86_64_SSEDF_CLASS; - return 1; - /*case LONGDOUBLE: - classes[0] = X86_64_X87_CLASS; - classes[1] = X86_64_X87UP_CLASS; - return 2;*/ - case typelib_TypeClass_STRING: - case typelib_TypeClass_TYPE: - case typelib_TypeClass_ANY: - case typelib_TypeClass_TYPEDEF: - case typelib_TypeClass_SEQUENCE: - case typelib_TypeClass_INTERFACE: - return 0; - case typelib_TypeClass_STRUCT: - case typelib_TypeClass_EXCEPTION: - { - typelib_TypeDescription * pTypeDescr = nullptr; - TYPELIB_DANGER_GET( &pTypeDescr, pTypeRef ); - - const int UNITS_PER_WORD = 8; - int words = ( pTypeDescr->nSize + UNITS_PER_WORD - 1 ) / UNITS_PER_WORD; - enum x86_64_reg_class subclasses[MAX_CLASSES]; - - /* If the struct is larger than 16 bytes, pass it on the stack. */ - if ( pTypeDescr->nSize > 16 ) - { - TYPELIB_DANGER_RELEASE( pTypeDescr ); - return 0; - } - - for ( int i = 0; i < words; i++ ) - classes[i] = X86_64_NO_CLASS; - - const typelib_CompoundTypeDescription *pStruct = reinterpret_cast<const typelib_CompoundTypeDescription*>( pTypeDescr ); - - /* Merge the fields of structure. */ - for ( sal_Int32 nMember = 0; nMember < pStruct->nMembers; ++nMember ) - { - typelib_TypeDescriptionReference *pTypeInStruct = pStruct->ppTypeRefs[ nMember ]; - int offset = byteOffset + pStruct->pMemberOffsets[ nMember ]; - - int num = classify_argument( pTypeInStruct, subclasses, offset ); - - if ( num == 0 ) - { - TYPELIB_DANGER_RELEASE( pTypeDescr ); - return 0; - } - - for ( int i = 0; i < num; i++ ) - { - int pos = offset / 8; - classes[i + pos] = merge_classes( subclasses[i], classes[i + pos] ); - } - } - - TYPELIB_DANGER_RELEASE( pTypeDescr ); - - /* Final merger cleanup. */ - for ( int i = 0; i < words; i++ ) - { - /* If one class is MEMORY, everything should be passed in - memory. */ - if ( classes[i] == X86_64_MEMORY_CLASS ) - return 0; - - /* The X86_64_SSEUP_CLASS should be always preceded by - X86_64_SSE_CLASS. */ - if ( classes[i] == X86_64_SSEUP_CLASS - && ( i == 0 || classes[i - 1] != X86_64_SSE_CLASS ) ) - classes[i] = X86_64_SSE_CLASS; - - /* X86_64_X87UP_CLASS should be preceded by X86_64_X87_CLASS. */ - if ( classes[i] == X86_64_X87UP_CLASS - && ( i == 0 || classes[i - 1] != X86_64_X87_CLASS ) ) - classes[i] = X86_64_SSE_CLASS; - } - return words; - } - - default: - SAL_WARN("bridges", "Unhandled case: pType->eTypeClass == " - << pTypeRef->eTypeClass); - assert(false); - } - return 0; /* Never reached. */ -} - -/* Examine the argument and return set number of register required in each - class. Return 0 iff parameter should be passed in memory. */ -bool x86_64::examine_argument( typelib_TypeDescriptionReference *pTypeRef, bool bInReturn, int &nUsedGPR, int &nUsedSSE ) throw () -{ - enum x86_64_reg_class classes[MAX_CLASSES]; - int n; - - n = classify_argument( pTypeRef, classes, 0 ); - - if ( n == 0 ) - return false; - - nUsedGPR = 0; - nUsedSSE = 0; - for ( n--; n >= 0; n-- ) - switch ( classes[n] ) - { - case X86_64_INTEGER_CLASS: - case X86_64_INTEGERSI_CLASS: - nUsedGPR++; - break; - case X86_64_SSE_CLASS: - case X86_64_SSESF_CLASS: - case X86_64_SSEDF_CLASS: - nUsedSSE++; - break; - case X86_64_NO_CLASS: - case X86_64_SSEUP_CLASS: - break; - case X86_64_X87_CLASS: - case X86_64_X87UP_CLASS: - if ( !bInReturn ) - return false; - break; - default: - SAL_WARN("bridges", "Unhandled case: classes[n] == " << classes[n]); - assert(false); - } - return true; -} - -bool x86_64::return_in_hidden_param( typelib_TypeDescriptionReference *pTypeRef ) throw () -{ - int g, s; - - return !examine_argument( pTypeRef, true, g, s ); -} - -void x86_64::fill_struct( typelib_TypeDescriptionReference *pTypeRef, const sal_uInt64 *pGPR, const double *pSSE, void *pStruct ) throw () -{ - enum x86_64_reg_class classes[MAX_CLASSES]; - int n; - - n = classify_argument( pTypeRef, classes, 0 ); - - sal_uInt64 *pStructAlign = static_cast<sal_uInt64 *>( pStruct ); - for ( n--; n >= 0; n-- ) - switch ( classes[n] ) - { - case X86_64_INTEGER_CLASS: - case X86_64_INTEGERSI_CLASS: - *pStructAlign++ = *pGPR++; - break; - case X86_64_SSE_CLASS: - case X86_64_SSESF_CLASS: - case X86_64_SSEDF_CLASS: - *pStructAlign++ = *reinterpret_cast<const sal_uInt64 *>( pSSE++ ); - break; - default: - break; - } -} -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/gcc3_ios/abi.hxx b/bridges/source/cpp_uno/gcc3_ios/abi.hxx deleted file mode 100644 index 90aad264c89d..000000000000 --- a/bridges/source/cpp_uno/gcc3_ios/abi.hxx +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- 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 . - */ - -#ifndef INCLUDED_BRIDGES_SOURCE_CPP_UNO_GCC3_MACOSX_X86_64_ABI_HXX -#define INCLUDED_BRIDGES_SOURCE_CPP_UNO_GCC3_MACOSX_X86_64_ABI_HXX - -// This is an implementation of the x86-64 ABI as described in 'System V -// Application Binary Interface, AMD64 Architecture Processor Supplement' -// (http://www.x86-64.org/documentation/abi-0.95.pdf) - -#include <typelib/typedescription.hxx> - -namespace x86_64 -{ - -/* 6 general purpose registers are used for parameter passing */ -const sal_uInt32 MAX_GPR_REGS = 6; - -/* 8 SSE registers are used for parameter passing */ -const sal_uInt32 MAX_SSE_REGS = 8; - -/* Count number of required registers. - - Examine the argument and return set number of register required in each - class. - - Return false iff parameter should be passed in memory. -*/ -bool examine_argument( typelib_TypeDescriptionReference *pTypeRef, bool bInReturn, int &nUsedGPR, int &nUsedSSE ) throw (); - -/** Does function that returns this type use a hidden parameter, or registers? - - The value can be returned either in a hidden 1st parameter (which is a - pointer to a structure allocated by the caller), or in registers (rax, rdx - for the integers, xmm0, xmm1 for the floating point numbers). -*/ -bool return_in_hidden_param( typelib_TypeDescriptionReference *pTypeRef ) throw (); - -void fill_struct( typelib_TypeDescriptionReference *pTypeRef, const sal_uInt64* pGPR, const double* pSSE, void *pStruct ) throw (); - -} // namespace x86_64 - -#endif // INCLUDED_BRIDGES_SOURCE_CPP_UNO_GCC3_MACOSX_X86_64_ABI_HXX - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/gcc3_ios/call.cxx b/bridges/source/cpp_uno/gcc3_ios/call.cxx deleted file mode 100644 index 405ff2f953e8..000000000000 --- a/bridges/source/cpp_uno/gcc3_ios/call.cxx +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- 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 . - */ -#ifdef __x86_64 - -#include <sal/config.h> - -#include "call.hxx" - -void privateSnippetExecutor() -{ - asm volatile - ( - " subq $160, %rsp\n" - - " movq %r10, -152(%rbp) # Save (nVtableOffset << 32) + nFunctionIndex\n" - - " movq %rdi, -112(%rbp) # Save GP registers\n" - " movq %rsi, -104(%rbp)\n" - " movq %rdx, -96(%rbp)\n" - " movq %rcx, -88(%rbp)\n" - " movq %r8 , -80(%rbp)\n" - " movq %r9 , -72(%rbp)\n" - - " movsd %xmm0, -64(%rbp) # Save FP registers\n" - " movsd %xmm1, -56(%rbp)\n" - " movsd %xmm2, -48(%rbp)\n" - " movsd %xmm3, -40(%rbp)\n" - " movsd %xmm4, -32(%rbp)\n" - " movsd %xmm5, -24(%rbp)\n" - " movsd %xmm6, -16(%rbp)\n" - " movsd %xmm7, -8(%rbp)\n" - - " leaq -144(%rbp), %r9 # 6th param: sal_uInt64 * pRegisterReturn\n" - " leaq 16(%rbp), %r8 # 5rd param: void ** ovrflw\n" - " leaq -64(%rbp), %rcx # 4th param: void ** fpreg\n" - " leaq -112(%rbp), %rdx # 3rd param: void ** gpreg\n" - " movl -148(%rbp), %esi # 2nd param: sal_int32 nVtableOffset\n" - " movl -152(%rbp), %edi # 1st param: sal_int32 nFunctionIndex\n" - - " call _cpp_vtable_call\n" - - " cmp $10, %rax # typelib_TypeClass_FLOAT\n" - " je .Lfloat\n" - " cmp $11, %rax # typelib_TypeClass_DOUBLE\n" - " je .Lfloat\n" - - " movq -144(%rbp), %rax # Return value (int case)\n" - " movq -136(%rbp), %rdx # Return value (int case)\n" - " movq -144(%rbp), %xmm0 # Return value (int case)\n" - " movq -136(%rbp), %xmm1 # Return value (int case)\n" - " jmp .Lfinish\n" - - ".Lfloat:\n" - " movlpd -144(%rbp), %xmm0 # Return value (float/double case)\n" - - ".Lfinish:\n" - " addq $160, %rsp\n" - ); -} -#endif -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/gcc3_ios/call.hxx b/bridges/source/cpp_uno/gcc3_ios/call.hxx deleted file mode 100644 index 6738970d2fb7..000000000000 --- a/bridges/source/cpp_uno/gcc3_ios/call.hxx +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- 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 . - */ - -#ifndef INCLUDED_BRIDGES_SOURCE_CPP_UNO_GCC3_MACOSX_X86_64_CALL_HXX -#define INCLUDED_BRIDGES_SOURCE_CPP_UNO_GCC3_MACOSX_X86_64_CALL_HXX - -#include <sal/config.h> - -#include <sal/types.h> -#include <typelib/typeclass.h> - -extern "C" typelib_TypeClass cpp_vtable_call( - sal_Int32 nFunctionIndex, sal_Int32 nVtableOffset, - void ** gpreg, void ** fpreg, void ** ovrflw, - sal_uInt64 * pRegisterReturn /* space for register return */ ); - -extern "C" void privateSnippetExecutor(); - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/gcc3_ios/callvirtualmethod.cxx b/bridges/source/cpp_uno/gcc3_ios/callvirtualmethod.cxx deleted file mode 100644 index 21efdbab1a82..000000000000 --- a/bridges/source/cpp_uno/gcc3_ios/callvirtualmethod.cxx +++ /dev/null @@ -1,180 +0,0 @@ -/* -*- 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 . - */ - -#ifdef __x86_64 -#include "sal/config.h" - -#include <cstring> - -#include "cppu/macros.hxx" -#include "sal/types.h" -#include "typelib/typeclass.h" -#include "typelib/typedescription.h" - -#include "abi.hxx" -#include "callvirtualmethod.hxx" - -// The call instruction within the asm block of callVirtualMethod may throw -// exceptions. At least GCC 4.7.0 with -O0 would create (unnecessary) -// .gcc_exception_table call-site table entries around all other calls in this -// function that can throw, leading to std::terminate if the asm call throws an -// exception and the unwinding C++ personality routine finds the unexpected hole -// in the .gcc_exception_table. Therefore, make sure this function explicitly -// only calls nothrow-functions (so GCC 4.7.0 with -O0 happens to not create a -// .gcc_exception_table section at all for this function). For some reason, -// this also needs to be in a source file of its own. -// -// Also, this file should be compiled with -fnon-call-exceptions, and ideally -// there would be a way to tell the compiler that the asm block contains calls -// to functions that can potentially throw; see the mail thread starting at -// <http://gcc.gnu.org/ml/gcc/2012-03/msg00454.html> "C++: Letting compiler know -// asm block can call function that can throw?" - -void CPPU_CURRENT_NAMESPACE::callVirtualMethod( - void * pThis, sal_uInt32 nVtableIndex, void * pRegisterReturn, - typelib_TypeDescriptionReference * pReturnTypeRef, bool bSimpleReturn, - sal_uInt64 *pStack, sal_uInt32 nStack, sal_uInt64 *pGPR, double * pFPR) -{ - // Work around -fsanitize=address "inline assembly requires more registers - // than available" error: - struct Data { - sal_uInt64 pMethod; - sal_uInt64 * pStack; - sal_uInt32 nStack; - sal_uInt64 * pGPR; - double * pFPR; - // Return values: - sal_uInt64 rax; - sal_uInt64 rdx; - double xmm0; - double xmm1; - } data; - data.pStack = pStack; - data.nStack = nStack; - data.pGPR = pGPR; - data.pFPR = pFPR; - - // Get pointer to method - sal_uInt64 pMethod = *static_cast<sal_uInt64 *>(pThis); - pMethod += 8 * nVtableIndex; - data.pMethod = *reinterpret_cast<sal_uInt64 *>(pMethod); - - asm volatile ( - // Push arguments to stack - "movq %%rsp, %%r12\n\t" - "movl 16%0, %%ecx\n\t" - "jrcxz Lpushed\n\t" - "xor %%rax, %%rax\n\t" - "leaq (%%rax, %%rcx, 8), %%rax\n\t" - "subq %%rax, %%rsp\n\t" - "andq $-9, %%rsp\n\t" // 16-bytes aligned - "movq 8%0, %%rsi\n\t" - "\nLpush:\n\t" - "decq %%rcx\n\t" - "movq (%%rsi, %%rcx, 8), %%rax\n\t" - "movq %%rax, (%%rsp, %%rcx, 8)\n\t" - "jnz Lpush\n\t" - "\nLpushed:\n\t" - - // Fill the xmm registers - "movq 32%0, %%rax\n\t" - - "movsd (%%rax), %%xmm0\n\t" - "movsd 8(%%rax), %%xmm1\n\t" - "movsd 16(%%rax), %%xmm2\n\t" - "movsd 24(%%rax), %%xmm3\n\t" - "movsd 32(%%rax), %%xmm4\n\t" - "movsd 40(%%rax), %%xmm5\n\t" - "movsd 48(%%rax), %%xmm6\n\t" - "movsd 56(%%rax), %%xmm7\n\t" - - // Fill the general purpose registers - "movq 24%0, %%rax\n\t" - - "movq (%%rax), %%rdi\n\t" - "movq 8(%%rax), %%rsi\n\t" - "movq 16(%%rax), %%rdx\n\t" - "movq 24(%%rax), %%rcx\n\t" - "movq 32(%%rax), %%r8\n\t" - "movq 40(%%rax), %%r9\n\t" - - // Perform the call - "movq 0%0, %%r11\n\t" - "call *%%r11\n\t" - - // Fill the return values - "movq %%rax, 40%0\n\t" - "movq %%rdx, 48%0\n\t" - "movsd %%xmm0, 56%0\n\t" - "movsd %%xmm1, 64%0\n\t" - - // Reset %rsp - "movq %%r12, %%rsp\n\t" - :: "o" (data) - : "rax", "rdi", "rsi", "rdx", "rcx", "r8", "r9", "r10", "r11", "r12", - "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7", - "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15", - "memory" - ); - - switch (pReturnTypeRef->eTypeClass) - { - case typelib_TypeClass_HYPER: - case typelib_TypeClass_UNSIGNED_HYPER: - *static_cast<sal_uInt64 *>( pRegisterReturn ) = data.rax; - break; - case typelib_TypeClass_LONG: - case typelib_TypeClass_UNSIGNED_LONG: - case typelib_TypeClass_ENUM: - *static_cast<sal_uInt32 *>( pRegisterReturn ) = *reinterpret_cast<sal_uInt32 *>( &data.rax ); - break; - case typelib_TypeClass_CHAR: - case typelib_TypeClass_SHORT: - case typelib_TypeClass_UNSIGNED_SHORT: - *static_cast<sal_uInt16 *>( pRegisterReturn ) = *reinterpret_cast<sal_uInt16 *>( &data.rax ); - break; - case typelib_TypeClass_BOOLEAN: - case typelib_TypeClass_BYTE: - *static_cast<sal_uInt8 *>( pRegisterReturn ) = *reinterpret_cast<sal_uInt8 *>( &data.rax ); - break; - case typelib_TypeClass_FLOAT: - case typelib_TypeClass_DOUBLE: - *static_cast<double *>( pRegisterReturn ) = data.xmm0; - break; - default: - { - sal_Int32 const nRetSize = pReturnTypeRef->pType->nSize; - if (bSimpleReturn && nRetSize <= 16 && nRetSize > 0) - { - sal_uInt64 longs[2]; - longs[0] = data.rax; - longs[1] = data.rdx; - - double doubles[2]; - doubles[0] = data.xmm0; - doubles[1] = data.xmm1; - x86_64::fill_struct( pReturnTypeRef, &longs[0], &doubles[0], pRegisterReturn); - } - break; - } - } -} -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/cpp_uno/gcc3_ios/callvirtualmethod.hxx b/bridges/source/cpp_uno/gcc3_ios/callvirtualmethod.hxx deleted file mode 100644 index 53c5ac0986c6..000000000000 --- a/bridges/source/cpp_uno/gcc3_ios/callvirtualmethod.hxx +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- 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 . - */ - -#ifndef INCLUDED_BRIDGES_SOURCE_CPP_UNO_GCC3_MACOSX_X86_64_CALLVIRTUALMETHOD_HXX -#define INCLUDED_BRIDGES_SOURCE_CPP_UNO_GCC3_MACOSX_X86_64_CALLVIRTUALMETHOD_HXX - -#include "sal/config.h" - -#include "cppu/macros.hxx" -#include "sal/types.h" -#include "typelib/typedescription.h" - -namespace CPPU_CURRENT_NAMESPACE { - -void callVirtualMethod( - void * pThis, sal_uInt32 nVtableIndex, void * pRegisterReturn, - typelib_TypeDescriptionReference * pReturnTypeRef, bool bSimpleReturn, - sal_uInt64 *pStack, sal_uInt32 nStack, sal_uInt64 *pGPR, double * pFPR); - -} - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |