Kaydet (Commit) e69ed74e authored tarafından jan Iversen's avatar jan Iversen

iOS, make simulator config copy of macosx.

When compiling for the simulator it is like compiling
for macosx (64bit) but with other libraries, therefore
the bridge should be like the macosx.

Change-Id: I59f1442a5c77d09ad0bc4bf31c2432fc32ef725e
üst 45dcb415
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# 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/.
#
$(eval $(call gb_CustomTarget_CustomTarget,bridges/source/cpp_uno/gcc3_ios))
$(call gb_CustomTarget_get_target,bridges/source/cpp_uno/gcc3_ios) : \
$(call gb_CustomTarget_get_workdir,bridges/source/cpp_uno/gcc3_ios)/codesnippets.S
$(call gb_CustomTarget_get_workdir,bridges/source/cpp_uno/gcc3_ios)/codesnippets.S : \
$(SRCDIR)/bridges/source/cpp_uno/gcc3_ios/generate-snippets.pl \
| $(call gb_CustomTarget_get_workdir,bridges/source/cpp_uno/gcc3_ios)/.dir
$(PERL) $< > $@
# vim: set noet sw=4 ts=4:
......@@ -11,7 +11,8 @@ $(eval $(call gb_Library_Library,$(gb_CPPU_ENV)_uno))
ifeq ($(OS),IOS)
bridges_SELECTED_BRIDGE := gcc3_ios
bridge_noopt_objects := cpp2uno except uno2cpp uno2cpp-i386
bridge_noopt_objects := cpp2uno cpp2uno-simulator except uno2cpp uno2cpp-simulator callvirtualmethod abi call
bridge_asm_objects := ios64_helper
else ifeq ($(CPUNAME),ARM)
......
......@@ -17,8 +17,6 @@ $(eval $(call gb_Module_add_targets,bridges,\
$(if $(filter MACOSX,$(OS)),Package_jnilib_java_uno) \
) \
$(if $(filter ARM,$(CPUNAME)),\
$(if $(filter IOS,$(OS)),\
CustomTarget_gcc3_ios) \
$(if $(filter ANDROID LINUX,$(OS)),\
CustomTarget_gcc3_linux_arm) \
) \
......
This diff is collapsed.
/* -*- 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: */
/* -*- 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: */
/* -*- 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: */
/* -*- 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: */
/* -*- 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: */
......@@ -29,6 +29,7 @@
#include "share.hxx"
#ifdef __arm64
extern "C" {
extern int nFunIndexes, nVtableOffsets;
extern int codeSnippets[];
......@@ -447,7 +448,6 @@ extern "C" sal_Int64 cpp_vtable_call( sal_Int32 *pFunctionAndOffset,
return nRegReturn;
}
#ifdef __arm64
namespace
{
unsigned char *codeSnippet(const typelib_InterfaceTypeDescription *type,
......
#!/usr/bin/perl -w # -*- tab-width: 4; indent-tabs-mode: nil; cperl-indent-level: 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/.
#
my $nFunIndexes = 8;
my $nVtableOffsets = 4;
sub gen_arm ($$)
{
my ($funIndex, $vtableOffset) = @_;
if ($funIndex & 0x80000000) {
printf ("#ifndef __arm64\n");
}
printf ("codeSnippet_%08x_%d:\n", $funIndex, $vtableOffset);
printf ("#ifdef __arm\n");
# Note: pc is the address of instruction being executed plus 8
printf (" mov ip, pc\n");
printf ("#else\n");
printf (" adr x15, .+8\n");
printf ("#endif\n");
printf (" b _privateSnippetExecutor\n");
printf (" .long %#08x\n", $funIndex);
printf (" .long %d\n", $vtableOffset);
if ($funIndex & 0x80000000) {
printf ("#endif\n");
}
}
sub gen_x86 ($$$)
{
my ($funIndex, $vtableOffset, $executor) = @_;
printf ("codeSnippet_%08x_%d_%s:\n", $funIndex, $vtableOffset, $executor);
printf (" movl \$%#08x, %%eax\n", $funIndex);
printf (" movl \$%d, %%edx\n", $vtableOffset);
printf (" jmp _privateSnippetExecutor%s\n", $executor);
}
printf (".text\n");
printf ("#if defined(__arm) || defined(__arm64)\n");
printf ("\n");
printf ("// Each codeSnippetX function stores into ip (arm64: x15) an address and branches to _privateSnippetExecutor\n");
printf ("// The address is that following the branch instruction, containing two 32-bit ints:\n");
printf ("// - the function index, which for 32-bit can have the 0x80000000 bit set\n");
printf ("// to indicate that a hidden parameter is used for returning large values\n");
printf ("// - the vtable offset\n");
printf ("\n");
printf (" .align 4\n");
printf ("\n");
foreach my $funIndex (0 .. $nFunIndexes-1)
{
foreach my $vtableOffset (0 .. $nVtableOffsets-1)
{
gen_arm ($funIndex, $vtableOffset);
gen_arm ($funIndex|0x80000000, $vtableOffset);
}
}
printf ("#else\n");
printf (" .align 1, 0x90\n");
foreach my $funIndex (0 .. $nFunIndexes-1)
{
foreach my $vtableOffset (0 .. $nVtableOffsets-1)
{
foreach my $executor ('General', 'Void', 'Hyper', 'Float', 'Double', 'Class')
{
gen_x86 ($funIndex, $vtableOffset, $executor);
gen_x86 ($funIndex|0x80000000, $vtableOffset, $executor);
}
}
}
printf ("#endif\n");
printf (" .globl _nFunIndexes\n");
printf ("_nFunIndexes:\n");
printf (" .long %d\n", $nFunIndexes);
printf (" .globl _nVtableOffsets\n");
printf ("_nVtableOffsets:\n");
printf (" .long %d\n", $nVtableOffsets);
printf (" .globl _codeSnippets\n");
printf ("_codeSnippets:\n");
foreach my $funIndex (0 .. $nFunIndexes-1)
{
foreach my $vtableOffset (0 .. $nVtableOffsets-1)
{
printf ("#if defined(__arm) || defined(__arm64)\n");
printf (" .long codeSnippet_%08x_%d - _codeSnippets\n", $funIndex, $vtableOffset);
printf ("#ifndef __arm64\n");
printf (" .long codeSnippet_%08x_%d - _codeSnippets\n", $funIndex|0x80000000, $vtableOffset);
printf ("#endif\n");
printf ("#else\n");
foreach my $executor ('General', 'Void', 'Hyper', 'Float', 'Double', 'Class')
{
printf (" .long codeSnippet_%08x_%d_%s - _codeSnippets\n", $funIndex, $vtableOffset, $executor);
printf (" .long codeSnippet_%08x_%d_%s - _codeSnippets\n", $funIndex|0x80000000, $vtableOffset, $executor);
}
printf ("#endif\n");
}
}
# vim:set shiftwidth=4 softtabstop=4 expandtab:
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment