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

michael@0 1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 // Platform specific code to invoke XPCOM methods on native objects
michael@0 7
michael@0 8 // The purpose of NS_InvokeByIndex() is to map a platform
michael@0 9 // indepenpent call to the platform ABI. To do that,
michael@0 10 // NS_InvokeByIndex() has to determine the method to call via vtable
michael@0 11 // access. The parameters for the method are read from the
michael@0 12 // nsXPTCVariant* and prepared for th native ABI. For the Linux/PPC
michael@0 13 // ABI this means that the first 8 integral and floating point
michael@0 14 // parameters are passed in registers.
michael@0 15
michael@0 16 #include "xptcprivate.h"
michael@0 17
michael@0 18 // 8 integral parameters are passed in registers
michael@0 19 #define GPR_COUNT 8
michael@0 20
michael@0 21 // 8 floating point parameters are passed in registers, floats are
michael@0 22 // promoted to doubles when passed in registers
michael@0 23 #define FPR_COUNT 8
michael@0 24
michael@0 25 extern "C" uint32_t
michael@0 26 invoke_count_words(uint32_t paramCount, nsXPTCVariant* s)
michael@0 27 {
michael@0 28 return uint32_t(((paramCount * 2) + 3) & ~3);
michael@0 29 }
michael@0 30
michael@0 31 extern "C" void
michael@0 32 invoke_copy_to_stack(uint32_t* d,
michael@0 33 uint32_t paramCount,
michael@0 34 nsXPTCVariant* s,
michael@0 35 uint32_t* gpregs,
michael@0 36 double* fpregs)
michael@0 37 {
michael@0 38 uint32_t gpr = 1; // skip one GP reg for 'that'
michael@0 39 uint32_t fpr = 0;
michael@0 40 uint32_t tempu32;
michael@0 41 uint64_t tempu64;
michael@0 42
michael@0 43 for(uint32_t i = 0; i < paramCount; i++, s++) {
michael@0 44 if(s->IsPtrData()) {
michael@0 45 if(s->type == nsXPTType::T_JSVAL)
michael@0 46 tempu32 = (uint32_t) &(s->ptr);
michael@0 47 else
michael@0 48 tempu32 = (uint32_t) s->ptr;
michael@0 49 } else {
michael@0 50 switch(s->type) {
michael@0 51 case nsXPTType::T_FLOAT: break;
michael@0 52 case nsXPTType::T_DOUBLE: break;
michael@0 53 case nsXPTType::T_I8: tempu32 = s->val.i8; break;
michael@0 54 case nsXPTType::T_I16: tempu32 = s->val.i16; break;
michael@0 55 case nsXPTType::T_I32: tempu32 = s->val.i32; break;
michael@0 56 case nsXPTType::T_I64: tempu64 = s->val.i64; break;
michael@0 57 case nsXPTType::T_U8: tempu32 = s->val.u8; break;
michael@0 58 case nsXPTType::T_U16: tempu32 = s->val.u16; break;
michael@0 59 case nsXPTType::T_U32: tempu32 = s->val.u32; break;
michael@0 60 case nsXPTType::T_U64: tempu64 = s->val.u64; break;
michael@0 61 case nsXPTType::T_BOOL: tempu32 = s->val.b; break;
michael@0 62 case nsXPTType::T_CHAR: tempu32 = s->val.c; break;
michael@0 63 case nsXPTType::T_WCHAR: tempu32 = s->val.wc; break;
michael@0 64 default: tempu32 = (uint32_t) s->val.p; break;
michael@0 65 }
michael@0 66 }
michael@0 67
michael@0 68 if (!s->IsPtrData() && s->type == nsXPTType::T_DOUBLE) {
michael@0 69 if (fpr < FPR_COUNT)
michael@0 70 fpregs[fpr++] = s->val.d;
michael@0 71 else {
michael@0 72 if ((uint32_t) d & 4) d++; // doubles are 8-byte aligned on stack
michael@0 73 *((double*) d) = s->val.d;
michael@0 74 d += 2;
michael@0 75 }
michael@0 76 }
michael@0 77 else if (!s->IsPtrData() && s->type == nsXPTType::T_FLOAT) {
michael@0 78 if (fpr < FPR_COUNT)
michael@0 79 fpregs[fpr++] = s->val.f; // if passed in registers, floats are promoted to doubles
michael@0 80 else
michael@0 81 *((float*) d++) = s->val.f;
michael@0 82 }
michael@0 83 else if (!s->IsPtrData() && (s->type == nsXPTType::T_I64
michael@0 84 || s->type == nsXPTType::T_U64)) {
michael@0 85 if ((gpr + 1) < GPR_COUNT) {
michael@0 86 if (gpr & 1) gpr++; // longlongs are aligned in odd/even register pairs, eg. r5/r6
michael@0 87 *((uint64_t*) &gpregs[gpr]) = tempu64;
michael@0 88 gpr += 2;
michael@0 89 }
michael@0 90 else {
michael@0 91 if ((uint32_t) d & 4) d++; // longlongs are 8-byte aligned on stack
michael@0 92 *((uint64_t*) d) = tempu64;
michael@0 93 d += 2;
michael@0 94 }
michael@0 95 }
michael@0 96 else {
michael@0 97 if (gpr < GPR_COUNT)
michael@0 98 gpregs[gpr++] = tempu32;
michael@0 99 else
michael@0 100 *d++ = tempu32;
michael@0 101 }
michael@0 102
michael@0 103 }
michael@0 104 }
michael@0 105
michael@0 106 extern "C"
michael@0 107 EXPORT_XPCOM_API(nsresult)
michael@0 108 NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex,
michael@0 109 uint32_t paramCount, nsXPTCVariant* params);

mercurial