xpcom/reflect/xptcall/src/md/unix/xptcinvoke_mips.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: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     2  * Version: MPL 1.1
     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/. */
     8 /* This code is for MIPS using the O32 ABI. */
    10 /* Platform specific code to invoke XPCOM methods on native objects */
    12 #include "xptcprivate.h"
    14 #include <stdint.h>
    16 extern "C" uint32_t
    17 invoke_count_words(uint32_t paramCount, nsXPTCVariant* s)
    18 {
    19     // Count a word for a0 even though it's never stored or loaded
    20     // We do this only for alignment of register pairs.
    21     uint32_t result = 1;
    22     for (uint32_t i = 0; i < paramCount; i++, result++, s++)
    23     {
    24         if (s->IsPtrData())
    25             continue;
    27         switch(s->type)
    28         {
    29         case nsXPTType::T_I64    :
    30         case nsXPTType::T_U64    :
    31         case nsXPTType::T_DOUBLE :
    32 	    if (result & 1)
    33 		result++;
    34 	    result++;
    35 	    break;
    37         default:
    38             break;
    39         }
    40     }
    41     return (result + 1) & ~(uint32_t)1;
    42 }
    44 extern "C" void
    45 invoke_copy_to_stack(uint32_t* d, uint32_t paramCount,
    46                      nsXPTCVariant* s)
    47 {
    48     // Skip the unused a0 slot, which we keep only for register pair alignment.
    49     d++;
    51     for (uint32_t i = 0; i < paramCount; i++, d++, s++)
    52     {
    53         if (s->IsPtrData())
    54         {
    55             *((void**)d) = s->ptr;
    56             continue;
    57         }
    59         switch(s->type)
    60         {
    61         case nsXPTType::T_I8     : *d = (uint32_t) s->val.i8;   break;
    62         case nsXPTType::T_I16    : *d = (uint32_t) s->val.i16;  break;
    63         case nsXPTType::T_I32    : *d = (uint32_t) s->val.i32;  break;
    64         case nsXPTType::T_I64    :
    65             if ((intptr_t)d & 4) d++;
    66             *((int64_t*) d)  = s->val.i64;    d++;
    67             break;
    68         case nsXPTType::T_U8     : *d = (uint32_t) s->val.u8;   break;
    69         case nsXPTType::T_U16    : *d = (uint32_t) s->val.u16;  break;
    70         case nsXPTType::T_U32    : *d = (uint32_t) s->val.u32;  break;
    71         case nsXPTType::T_U64    :
    72             if ((intptr_t)d & 4) d++;
    73             *((uint64_t*) d) = s->val.u64;    d++;
    74             break;
    75         case nsXPTType::T_FLOAT  : *((float*)   d) = s->val.f;  break;
    76         case nsXPTType::T_DOUBLE :
    77             if ((intptr_t)d & 4) d++;
    78             *((double*)   d) = s->val.d;      d++;
    79             break;
    80         case nsXPTType::T_BOOL   : *d = (bool)  s->val.b;     break;
    81         case nsXPTType::T_CHAR   : *d = (char)    s->val.c;     break;
    82         case nsXPTType::T_WCHAR  : *d = (wchar_t) s->val.wc;    break;
    83         default:
    84             *((void**)d) = s->val.p;
    85             break;
    86         }
    87     }
    88 }
    90 extern "C" nsresult _NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex,
    91                                         uint32_t paramCount,
    92                                         nsXPTCVariant* params);
    94 EXPORT_XPCOM_API(nsresult)
    95 NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex,
    96                    uint32_t paramCount, nsXPTCVariant* params)
    97 {
    98     return _NS_InvokeByIndex(that, methodIndex, paramCount, params);
    99 }

mercurial