xpcom/reflect/xptcall/src/md/unix/xptcstubs_ipf32.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     2 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     3  *
     4  * This Source Code Form is subject to the terms of the Mozilla Public
     5  * License, v. 2.0. If a copy of the MPL was not distributed with this
     6  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     9 #include "xptcprivate.h"
    10 #include "xptiprivate.h"
    12 #include <stddef.h>
    13 #include <stdlib.h>
    15 // "This code is for IA64 only"
    17 /* Implement shared vtbl methods. */
    19 extern "C" nsresult ATTRIBUTE_USED
    20 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex,
    21   uint64_t* intargs, uint64_t* floatargs, uint64_t* restargs)
    22 {
    24 #define PARAM_BUFFER_COUNT     16
    26   nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
    27   nsXPTCMiniVariant* dispatchParams = nullptr;
    28   const nsXPTMethodInfo* info;
    29   nsresult result = NS_ERROR_FAILURE;
    30   uint64_t* iargs = intargs;
    31   uint64_t* fargs = floatargs;
    32   uint8_t paramCount;
    33   uint8_t i;
    35   NS_ASSERTION(self,"no self");
    37   self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info);
    38   NS_ASSERTION(info,"no interface info");
    40   paramCount = info->GetParamCount();
    42   // setup variant array pointer
    43   if(paramCount > PARAM_BUFFER_COUNT)
    44     dispatchParams = new nsXPTCMiniVariant[paramCount];
    45   else
    46     dispatchParams = paramBuffer;
    47   NS_ASSERTION(dispatchParams,"no place for params");
    48   if (! dispatchParams)
    49       return NS_ERROR_OUT_OF_MEMORY;
    51   for(i = 0; i < paramCount; ++i)
    52   {
    53     int isfloat = 0;
    54     const nsXPTParamInfo& param = info->GetParam(i);
    55     const nsXPTType& type = param.GetType();
    56     nsXPTCMiniVariant* dp = &dispatchParams[i];
    58     if(param.IsOut() || !type.IsArithmetic())
    59     {
    60 #ifdef __LP64__
    61         /* 64 bit pointer mode */
    62         dp->val.p = (void*) *iargs;
    63 #else
    64         /* 32 bit pointer mode */
    65         uint32_t* adr = (uint32_t*) iargs;
    66         dp->val.p = (void*) (*(adr+1));
    67 #endif
    68     }
    69     else
    70     switch(type)
    71     {
    72     case nsXPTType::T_I8     : dp->val.i8  = *(iargs); break;
    73     case nsXPTType::T_I16    : dp->val.i16 = *(iargs); break;
    74     case nsXPTType::T_I32    : dp->val.i32 = *(iargs); break;
    75     case nsXPTType::T_I64    : dp->val.i64 = *(iargs); break;
    76     case nsXPTType::T_U8     : dp->val.u8  = *(iargs); break;
    77     case nsXPTType::T_U16    : dp->val.u16 = *(iargs); break;
    78     case nsXPTType::T_U32    : dp->val.u32 = *(iargs); break;
    79     case nsXPTType::T_U64    : dp->val.u64 = *(iargs); break;
    80     case nsXPTType::T_FLOAT  :
    81       isfloat = 1;
    82       if (i < 7)
    83         dp->val.f = (float) *((double*) fargs); /* register */
    84       else
    85         dp->val.u32 = *(fargs); /* memory */
    86       break;
    87     case nsXPTType::T_DOUBLE :
    88       isfloat = 1;
    89       dp->val.u64 = *(fargs);
    90       break;
    91     case nsXPTType::T_BOOL   : dp->val.b   = *(iargs); break;
    92     case nsXPTType::T_CHAR   : dp->val.c   = *(iargs); break;
    93     case nsXPTType::T_WCHAR  : dp->val.wc  = *(iargs); break;
    94     default:
    95       NS_ERROR("bad type");
    96       break;
    97     }
    98     if (i < 7)
    99     {
   100       /* we are parsing register arguments */
   101       if (i == 6)
   102       {
   103         // run out of register arguments, move on to memory arguments
   104         iargs = restargs;
   105         fargs = restargs;
   106       }
   107       else
   108       {
   109         ++iargs; // advance one integer register slot
   110         if (isfloat) ++fargs; // advance float register slot if isfloat
   111       }
   112     }
   113     else
   114     {
   115       /* we are parsing memory arguments */
   116       ++iargs;
   117       ++fargs;
   118     }
   119   }
   121   result = self->mOuter->CallMethod((uint16_t) methodIndex, info, dispatchParams);
   123   if(dispatchParams != paramBuffer)
   124     delete [] dispatchParams;
   126   return result;
   127 }
   129 extern "C" nsresult SharedStub(uint64_t,uint64_t,uint64_t,uint64_t,
   130  uint64_t,uint64_t,uint64_t,uint64_t,uint64_t,uint64_t *);
   132 /* Variable a0-a7 were put there so we can have access to the 8 input
   133    registers on Stubxyz entry */
   135 #define STUB_ENTRY(n) \
   136 nsresult nsXPTCStubBase::Stub##n(uint64_t a1, \
   137 uint64_t a2,uint64_t a3,uint64_t a4,uint64_t a5,uint64_t a6,uint64_t a7, \
   138 uint64_t a8) \
   139 { uint64_t a0 = (uint64_t) this; \
   140  return SharedStub(a0,a1,a2,a3,a4,a5,a6,a7,(uint64_t) n, &a8); \
   141 }
   143 #define SENTINEL_ENTRY(n) \
   144 nsresult nsXPTCStubBase::Sentinel##n() \
   145 { \
   146     NS_ERROR("nsXPTCStubBase::Sentinel called"); \
   147     return NS_ERROR_NOT_IMPLEMENTED; \
   148 }
   150 #include "xptcstubsdef.inc"

mercurial