xpcom/reflect/xptcall/src/md/unix/xptcstubs_mips64.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.

     1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     6 #include "xptcprivate.h"
     7 #include "xptiprivate.h"
     9 #if (_MIPS_SIM != _ABIN32)
    10 #error "This code is for MIPS N32 only"
    11 #endif
    13 /*
    14  * This is for MIPS N32 ABI
    15  *
    16  * When we're called, the "gp" registers are stored in gprData and
    17  * the "fp" registers are stored in fprData.  There are 8 regs
    18  * available which correspond to the first 7 parameters of the
    19  * function and the "this" pointer.  If there are additional parms,
    20  * they are stored on the stack at address "args".
    21  *
    22  */
    23 extern "C" nsresult ATTRIBUTE_USED
    24 PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex, uint64_t* args,
    25                    uint64_t *gprData, double *fprData)
    26 {
    27 #define PARAM_BUFFER_COUNT        16
    28 #define PARAM_GPR_COUNT            7
    29 #define PARAM_FPR_COUNT            7
    31     nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
    32     nsXPTCMiniVariant* dispatchParams = nullptr;
    33     const nsXPTMethodInfo* info;
    34     uint8_t paramCount;
    35     uint8_t i;
    36     nsresult result = NS_ERROR_FAILURE;
    38     NS_ASSERTION(self,"no self");
    40     self->mEntry->GetMethodInfo(uint16_t(methodIndex), &info);
    41     NS_ASSERTION(info,"no method info");
    43     paramCount = info->GetParamCount();
    45     // setup variant array pointer
    46     if(paramCount > PARAM_BUFFER_COUNT)
    47         dispatchParams = new nsXPTCMiniVariant[paramCount];
    48     else
    49         dispatchParams = paramBuffer;
    50     NS_ASSERTION(dispatchParams,"no place for params");
    52     uint64_t* ap = args;
    53     uint32_t iCount = 0;
    54     for(i = 0; i < paramCount; i++)
    55     {
    56         const nsXPTParamInfo& param = info->GetParam(i);
    57         const nsXPTType& type = param.GetType();
    58         nsXPTCMiniVariant* dp = &dispatchParams[i];
    60         if(param.IsOut() || !type.IsArithmetic())
    61         {
    62             if (iCount < PARAM_GPR_COUNT)
    63                 dp->val.p = (void*)gprData[iCount++];
    64             else
    65                 dp->val.p = (void*)*ap++;
    66             continue;
    67         }
    68         // else
    69         switch(type)
    70         {
    71         case nsXPTType::T_I8:
    72             if (iCount < PARAM_GPR_COUNT)
    73                 dp->val.i8  = (int8_t)gprData[iCount++];
    74             else
    75                 dp->val.i8  = (int8_t)*ap++;
    76             break;
    78         case nsXPTType::T_I16:
    79              if (iCount < PARAM_GPR_COUNT)
    80                  dp->val.i16  = (int16_t)gprData[iCount++];
    81              else
    82                  dp->val.i16  = (int16_t)*ap++;
    83              break;
    85         case nsXPTType::T_I32:
    86              if (iCount < PARAM_GPR_COUNT)
    87                  dp->val.i32  = (int32_t)gprData[iCount++];
    88              else
    89                  dp->val.i32  = (int32_t)*ap++;
    90              break;
    92         case nsXPTType::T_I64:
    93              if (iCount < PARAM_GPR_COUNT)
    94                  dp->val.i64  = (int64_t)gprData[iCount++];
    95              else
    96                  dp->val.i64  = (int64_t)*ap++;
    97              break;
    99         case nsXPTType::T_U8:
   100              if (iCount < PARAM_GPR_COUNT)
   101                  dp->val.u8  = (uint8_t)gprData[iCount++];
   102              else
   103                  dp->val.u8  = (uint8_t)*ap++;
   104              break;
   106         case nsXPTType::T_U16:
   107              if (iCount < PARAM_GPR_COUNT)
   108                  dp->val.u16  = (uint16_t)gprData[iCount++];
   109              else
   110                   dp->val.u16  = (uint16_t)*ap++;
   111              break;
   113         case nsXPTType::T_U32:
   114              if (iCount < PARAM_GPR_COUNT)
   115                  dp->val.u32  = (uint32_t)gprData[iCount++];
   116              else
   117                  dp->val.u32  = (uint32_t)*ap++;
   118              break;
   120         case nsXPTType::T_U64:
   121              if (iCount < PARAM_GPR_COUNT)
   122                  dp->val.u64  = (uint64_t)gprData[iCount++];
   123              else
   124                  dp->val.u64  = (uint64_t)*ap++;
   125              break;
   127         case nsXPTType::T_FLOAT:
   128               if (iCount < PARAM_FPR_COUNT)
   129                   dp->val.f  = (double)fprData[iCount++];
   130               else
   131                   dp->val.f  = *((double*)ap++);
   132               break;
   134         case nsXPTType::T_DOUBLE:
   135                if (iCount < PARAM_FPR_COUNT)
   136                    dp->val.d  = (double)fprData[iCount++];
   137                else
   138                    dp->val.d  = *((double*)ap++);
   139                break;
   141         case nsXPTType::T_BOOL:
   142             if (iCount < PARAM_GPR_COUNT)
   143                 dp->val.b  = (bool)gprData[iCount++];
   144             else
   145                 dp->val.b  = (bool)*ap++;
   146             break;
   148         case nsXPTType::T_CHAR:
   149             if (iCount < PARAM_GPR_COUNT)
   150                 dp->val.c  = (char)gprData[iCount++];
   151             else
   152                 dp->val.c  = (char)*ap++;
   153             break;
   155         case nsXPTType::T_WCHAR:
   156             if (iCount < PARAM_GPR_COUNT)
   157                 dp->val.wc  = (wchar_t)gprData[iCount++];
   158             else
   159                 dp->val.wc  = (wchar_t)*ap++;
   160             break;
   162         default:
   163             NS_ASSERTION(0, "bad type");
   164             break;
   165         }
   166     }
   168     result = self->mOuter->CallMethod((uint16_t)methodIndex, info, dispatchParams);
   170     if(dispatchParams != paramBuffer)
   171         delete [] dispatchParams;
   173     return result;
   174 }
   176 #define STUB_ENTRY(n)        /* defined in the assembly file */
   178 #define SENTINEL_ENTRY(n)                              \
   179 nsresult nsXPTCStubBase::Sentinel##n()                 \
   180 {                                                      \
   181     NS_ASSERTION(0,"nsXPTCStubBase::Sentinel called"); \
   182     return NS_ERROR_NOT_IMPLEMENTED;                   \
   183 }
   185 #include "xptcstubsdef.inc"

mercurial