LibreOffice Module bridges (master)  1
gcc3_solaris_intel/callvirtualmethod.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <com/sun/star/uno/genfunc.hxx>
21 #include "com/sun/star/uno/RuntimeException.hpp"
22 #include <uno/data.h>
23 
24 #include "bridge.hxx"
25 #include "types.hxx"
26 #include "unointerfaceproxy.hxx"
27 #include "vtables.hxx"
28 
29 #include "share.hxx"
30 
31 #include "callvirtualmethod.hxx"
32 
34  void * pAdjustedThisPtr,
35  sal_Int32 nVtableIndex,
36  void * pRegisterReturn,
37  typelib_TypeClass eReturnType,
38  sal_Int32 * pStackLongs,
39  sal_Int32 nStackLongs )
40 {
41  // parameter list is mixed list of * and values
42  // reference parameters are pointers
43 
44  assert(pStackLongs && pAdjustedThisPtr);
45  static_assert((sizeof(void *) == 4) && (sizeof(sal_Int32) == 4), "### unexpected size of int!");
46  assert(nStackLongs && pStackLongs && "### no stack in callVirtualMethod !");
47 
48  // never called
49  if (! pAdjustedThisPtr) CPPU_CURRENT_NAMESPACE::dummy_can_throw_anything("xxx"); // address something
50 
51  long edx, eax; // for register returns
52  void * stackptr;
53  asm volatile (
54  "mov %%esp, %2\n\t"
55  // preserve potential 128bit stack alignment
56  "and $0xfffffff0, %%esp\n\t"
57  "mov %3, %%eax\n\t"
58  "lea -4(,%%eax,4), %%eax\n\t"
59  "and $0xf, %%eax\n\t"
60  "sub $0xc, %%eax\n\t"
61  "add %%eax, %%esp\n\t"
62  // copy values
63  "mov %3, %%eax\n\t"
64  "mov %%eax, %%edx\n\t"
65  "dec %%edx\n\t"
66  "shl $2, %%edx\n\t"
67  "add %4, %%edx\n"
68  "Lcopy:\n\t"
69  "pushl 0(%%edx)\n\t"
70  "sub $4, %%edx\n\t"
71  "dec %%eax\n\t"
72  "jne Lcopy\n\t"
73  // do the actual call
74  "mov %5, %%edx\n\t"
75  "mov 0(%%edx), %%edx\n\t"
76  "mov %6, %%eax\n\t"
77  "shl $2, %%eax\n\t"
78  "add %%eax, %%edx\n\t"
79  "mov 0(%%edx), %%edx\n\t"
80  "call *%%edx\n\t"
81  // save return registers
82  "mov %%eax, %0\n\t"
83  "mov %%edx, %1\n\t"
84  // cleanup stack
85  "mov %2, %%esp\n\t"
86  : "=m"(eax), "=m"(edx), "=m"(stackptr)
87  : "m"(nStackLongs), "m"(pStackLongs), "m"(pAdjustedThisPtr), "m"(nVtableIndex)
88  : "eax", "ecx", "edx" );
89  switch( eReturnType )
90  {
91  case typelib_TypeClass_HYPER:
92  case typelib_TypeClass_UNSIGNED_HYPER:
93  ((long*)pRegisterReturn)[1] = edx;
94  case typelib_TypeClass_LONG:
95  case typelib_TypeClass_UNSIGNED_LONG:
96  case typelib_TypeClass_CHAR:
97  case typelib_TypeClass_ENUM:
98  ((long*)pRegisterReturn)[0] = eax;
99  break;
100  case typelib_TypeClass_SHORT:
101  case typelib_TypeClass_UNSIGNED_SHORT:
102  *(unsigned short*)pRegisterReturn = eax;
103  break;
104  case typelib_TypeClass_BOOLEAN:
105  case typelib_TypeClass_BYTE:
106  *(unsigned char*)pRegisterReturn = eax;
107  break;
108  case typelib_TypeClass_FLOAT:
109  asm ( "fstps %0" : : "m"(*(char *)pRegisterReturn) );
110  break;
111  case typelib_TypeClass_DOUBLE:
112  asm ( "fstpl %0\n\t" : : "m"(*(char *)pRegisterReturn) );
113  break;
114  }
115 }
116 
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void callVirtualMethod(void *pAdjustedThisPtr, sal_Int32 nVtableIndex, void *pRegisterReturn, typelib_TypeDescription *pReturnTypeDescr, bool bSimpleReturn, sal_Int32 *pStackLongs, sal_Int32 nStackLongs)
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
void dummy_can_throw_anything(char const *)