xpcom/reflect/xptcall/src/md/unix/xptcinvoke_ppc64_linux.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 // independent 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 the native ABI.
michael@0 13
michael@0 14 // The PowerPC64 platform ABI can be found here:
michael@0 15 // http://www.freestandards.org/spec/ELF/ppc64/
michael@0 16 // and in particular:
michael@0 17 // http://www.freestandards.org/spec/ELF/ppc64/PPC-elf64abi-1.9.html#FUNC-CALL
michael@0 18
michael@0 19 #include <stdio.h>
michael@0 20 #include "xptcprivate.h"
michael@0 21
michael@0 22 // 8 integral parameters are passed in registers, not including 'that'
michael@0 23 #define GPR_COUNT 7
michael@0 24
michael@0 25 // 8 floating point parameters are passed in registers, floats are
michael@0 26 // promoted to doubles when passed in registers
michael@0 27 #define FPR_COUNT 13
michael@0 28
michael@0 29 extern "C" uint32_t
michael@0 30 invoke_count_words(uint32_t paramCount, nsXPTCVariant* s)
michael@0 31 {
michael@0 32 return uint32_t(((paramCount * 2) + 3) & ~3);
michael@0 33 }
michael@0 34
michael@0 35 extern "C" void
michael@0 36 invoke_copy_to_stack(uint64_t* gpregs,
michael@0 37 double* fpregs,
michael@0 38 uint32_t paramCount,
michael@0 39 nsXPTCVariant* s,
michael@0 40 uint64_t* d)
michael@0 41 {
michael@0 42 uint64_t tempu64;
michael@0 43
michael@0 44 for(uint32_t i = 0; i < paramCount; i++, s++) {
michael@0 45 if(s->IsPtrData())
michael@0 46 tempu64 = (uint64_t) s->ptr;
michael@0 47 else {
michael@0 48 switch(s->type) {
michael@0 49 case nsXPTType::T_FLOAT: break;
michael@0 50 case nsXPTType::T_DOUBLE: break;
michael@0 51 case nsXPTType::T_I8: tempu64 = s->val.i8; break;
michael@0 52 case nsXPTType::T_I16: tempu64 = s->val.i16; break;
michael@0 53 case nsXPTType::T_I32: tempu64 = s->val.i32; break;
michael@0 54 case nsXPTType::T_I64: tempu64 = s->val.i64; break;
michael@0 55 case nsXPTType::T_U8: tempu64 = s->val.u8; break;
michael@0 56 case nsXPTType::T_U16: tempu64 = s->val.u16; break;
michael@0 57 case nsXPTType::T_U32: tempu64 = s->val.u32; break;
michael@0 58 case nsXPTType::T_U64: tempu64 = s->val.u64; break;
michael@0 59 case nsXPTType::T_BOOL: tempu64 = s->val.b; break;
michael@0 60 case nsXPTType::T_CHAR: tempu64 = s->val.c; break;
michael@0 61 case nsXPTType::T_WCHAR: tempu64 = s->val.wc; break;
michael@0 62 default: tempu64 = (uint64_t) s->val.p; break;
michael@0 63 }
michael@0 64 }
michael@0 65
michael@0 66 if (!s->IsPtrData() && s->type == nsXPTType::T_DOUBLE) {
michael@0 67 if (i < FPR_COUNT)
michael@0 68 fpregs[i] = s->val.d;
michael@0 69 else
michael@0 70 *(double *)d = s->val.d;
michael@0 71 }
michael@0 72 else if (!s->IsPtrData() && s->type == nsXPTType::T_FLOAT) {
michael@0 73 if (i < FPR_COUNT) {
michael@0 74 fpregs[i] = s->val.f; // if passed in registers, floats are promoted to doubles
michael@0 75 } else {
michael@0 76 float *p = (float *)d;
michael@0 77 #ifndef __LITTLE_ENDIAN__
michael@0 78 p++;
michael@0 79 #endif
michael@0 80 *p = s->val.f;
michael@0 81 }
michael@0 82 }
michael@0 83 else {
michael@0 84 if (i < GPR_COUNT)
michael@0 85 gpregs[i] = tempu64;
michael@0 86 else
michael@0 87 *d = tempu64;
michael@0 88 }
michael@0 89 if (i >= 7)
michael@0 90 d++;
michael@0 91 }
michael@0 92 }
michael@0 93
michael@0 94 EXPORT_XPCOM_API(nsresult)
michael@0 95 NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex,
michael@0 96 uint32_t paramCount, nsXPTCVariant* params);
michael@0 97

mercurial