LCOV - code coverage report
Current view: directory - xpcom/reflect/xptcall/src/md/unix - xptcstubs_gcc_x86_unix.cpp (source / functions) Found Hit Coverage
Test: app.info Lines: 29 25 86.2 %
Date: 2012-06-02 Functions: 2 1 50.0 %

       1                 : /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 : /* ***** BEGIN LICENSE BLOCK *****
       3                 :  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
       4                 :  *
       5                 :  * The contents of this file are subject to the Mozilla Public License Version
       6                 :  * 1.1 (the "License"); you may not use this file except in compliance with
       7                 :  * the License. You may obtain a copy of the License at
       8                 :  * http://www.mozilla.org/MPL/
       9                 :  *
      10                 :  * Software distributed under the License is distributed on an "AS IS" basis,
      11                 :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12                 :  * for the specific language governing rights and limitations under the
      13                 :  * License.
      14                 :  *
      15                 :  * The Original Code is mozilla.org code.
      16                 :  *
      17                 :  * The Initial Developer of the Original Code is
      18                 :  * Netscape Communications Corporation.
      19                 :  * Portions created by the Initial Developer are Copyright (C) 1999
      20                 :  * the Initial Developer. All Rights Reserved.
      21                 :  *
      22                 :  * Contributor(s):
      23                 :  *
      24                 :  * Alternatively, the contents of this file may be used under the terms of
      25                 :  * either of the GNU General Public License Version 2 or later (the "GPL"),
      26                 :  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
      27                 :  * in which case the provisions of the GPL or the LGPL are applicable instead
      28                 :  * of those above. If you wish to allow use of your version of this file only
      29                 :  * under the terms of either the GPL or the LGPL, and not to allow others to
      30                 :  * use your version of this file under the terms of the MPL, indicate your
      31                 :  * decision by deleting the provisions above and replace them with the notice
      32                 :  * and other provisions required by the GPL or the LGPL. If you do not delete
      33                 :  * the provisions above, a recipient may use your version of this file under
      34                 :  * the terms of any one of the MPL, the GPL or the LGPL.
      35                 :  *
      36                 :  * ***** END LICENSE BLOCK ***** */
      37                 : 
      38                 : /* Implement shared vtbl methods. */
      39                 : 
      40                 : #include "xptcprivate.h"
      41                 : #include "xptiprivate.h"
      42                 : #include "xptc_gcc_x86_unix.h"
      43                 : 
      44                 : extern "C" {
      45                 : static nsresult ATTRIBUTE_USED
      46                 : __attribute__ ((regparm (3)))
      47         1225639 : PrepareAndDispatch(uint32 methodIndex, nsXPTCStubBase* self, PRUint32* args)
      48                 : {
      49                 : #define PARAM_BUFFER_COUNT     16
      50                 : 
      51                 :     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
      52         1225639 :     nsXPTCMiniVariant* dispatchParams = NULL;
      53                 :     const nsXPTMethodInfo* info;
      54                 :     PRUint8 paramCount;
      55                 :     PRUint8 i;
      56         1225639 :     nsresult result = NS_ERROR_FAILURE;
      57                 : 
      58         1225639 :     NS_ASSERTION(self,"no self");
      59                 : 
      60         1225639 :     self->mEntry->GetMethodInfo(PRUint16(methodIndex), &info);
      61         1225639 :     paramCount = info->GetParamCount();
      62                 : 
      63                 :     // setup variant array pointer
      64         1225639 :     if(paramCount > PARAM_BUFFER_COUNT)
      65               0 :         dispatchParams = new nsXPTCMiniVariant[paramCount];
      66                 :     else
      67         1225639 :         dispatchParams = paramBuffer;
      68         1225639 :     NS_ASSERTION(dispatchParams,"no place for params");
      69                 : 
      70         1225639 :     PRUint32* ap = args;
      71         2964023 :     for(i = 0; i < paramCount; i++, ap++)
      72                 :     {
      73         1738384 :         const nsXPTParamInfo& param = info->GetParam(i);
      74         1738384 :         const nsXPTType& type = param.GetType();
      75         1738384 :         nsXPTCMiniVariant* dp = &dispatchParams[i];
      76                 : 
      77         1738384 :         if(param.IsOut() || !type.IsArithmetic())
      78                 :         {
      79         1638346 :             dp->val.p = (void*) *ap;
      80         1638346 :             continue;
      81                 :         }
      82                 :         // else
      83          100038 :             dp->val.p = (void*) *ap;
      84          100038 :         switch(type)
      85                 :         {
      86           27284 :         case nsXPTType::T_I64    : dp->val.i64 = *((PRInt64*) ap); ap++; break;
      87           15808 :         case nsXPTType::T_U64    : dp->val.u64 = *((PRUint64*)ap); ap++; break;
      88               1 :         case nsXPTType::T_DOUBLE : dp->val.d   = *((double*)  ap); ap++; break;
      89                 :         }
      90                 :     }
      91                 : 
      92         1225639 :     result = self->mOuter->CallMethod((PRUint16)methodIndex, info, dispatchParams);
      93                 : 
      94         1225639 :     if(dispatchParams != paramBuffer)
      95               0 :         delete [] dispatchParams;
      96                 : 
      97         1225639 :     return result;
      98                 : }
      99                 : } // extern "C"
     100                 : 
     101                 : #if !defined(XP_MACOSX)
     102                 : 
     103                 : #define STUB_HEADER(a, b) ".hidden " SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase" #a "Stub" #b "Ev\n\t" \
     104                 :                           ".type   " SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase" #a "Stub" #b "Ev,@function\n"
     105                 : 
     106                 : #define STUB_SIZE(a, b)  ".size        " SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase" #a "Stub" #b "Ev,.-" SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase" #a "Stub" #b "Ev\n\t"
     107                 : 
     108                 : #else
     109                 : 
     110                 : #define STUB_HEADER(a, b)
     111                 : #define STUB_SIZE(a, b)
     112                 : 
     113                 : #endif
     114                 : 
     115                 : // gcc3 mangling tends to insert the length of the method name
     116                 : #define STUB_ENTRY(n) \
     117                 : asm(".text\n\t" \
     118                 :     ".align        2\n\t" \
     119                 :     ".if   " #n " < 10\n\t" \
     120                 :     ".globl        " SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase5Stub" #n "Ev\n\t" \
     121                 :     STUB_HEADER(5, n)                                                   \
     122                 :     SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase5Stub" #n "Ev:\n\t" \
     123                 :     ".elseif       " #n " < 100\n\t" \
     124                 :     ".globl        " SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase6Stub" #n "Ev\n\t" \
     125                 :     STUB_HEADER(6, n)                                                   \
     126                 :     SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase6Stub" #n "Ev:\n\t" \
     127                 :     ".elseif    " #n " < 1000\n\t" \
     128                 :     ".globl     " SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase7Stub" #n "Ev\n\t" \
     129                 :     STUB_HEADER(7, n)                                                   \
     130                 :     SYMBOL_UNDERSCORE "_ZN14nsXPTCStubBase7Stub" #n "Ev:\n\t" \
     131                 :     ".else\n\t" \
     132                 :     ".err  \"stub number " #n " >= 1000 not yet supported\"\n\t" \
     133                 :     ".endif\n\t" \
     134                 :     "movl  $" #n ", %eax\n\t" \
     135                 :     "jmp   " SYMBOL_UNDERSCORE "SharedStub\n\t" \
     136                 :     ".if   " #n " < 10\n\t" \
     137                 :     STUB_SIZE(5, n) \
     138                 :     ".elseif       " #n " < 100\n\t" \
     139                 :     STUB_SIZE(6, n) \
     140                 :     ".else\n\t" \
     141                 :     STUB_SIZE(7, n) \
     142                 :     ".endif");
     143                 : 
     144                 : // static nsresult SharedStub(PRUint32 methodIndex) __attribute__((regparm(1)))
     145                 : asm(".text\n\t"
     146                 :     ".align        2\n\t"
     147                 : #if !defined(XP_MACOSX)
     148                 :     ".type " SYMBOL_UNDERSCORE "SharedStub,@function\n\t"
     149                 : #endif
     150                 :     SYMBOL_UNDERSCORE "SharedStub:\n\t"
     151                 :     "leal  0x08(%esp), %ecx\n\t"
     152                 :     "movl  0x04(%esp), %edx\n\t"
     153                 :     "jmp   " SYMBOL_UNDERSCORE "PrepareAndDispatch\n\t"
     154                 : #if !defined(XP_MACOSX)
     155                 :     ".size " SYMBOL_UNDERSCORE "SharedStub,.-" SYMBOL_UNDERSCORE "SharedStub"
     156                 : #endif
     157                 : );
     158                 : 
     159                 : #define SENTINEL_ENTRY(n) \
     160                 : nsresult nsXPTCStubBase::Sentinel##n() \
     161                 : { \
     162                 :     NS_ERROR("nsXPTCStubBase::Sentinel called"); \
     163                 :     return NS_ERROR_NOT_IMPLEMENTED; \
     164                 : }
     165                 : 
     166                 : #include "xptcstubsdef.inc"
     167                 : 
     168                 : void
     169               0 : xptc_dummy()
     170                 : {
     171               0 : }

Generated by: LCOV version 1.7