xpcom/reflect/xptcall/src/md/unix/xptcinvoke_linux_s390.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 *
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 /* Platform specific code to invoke XPCOM methods on native objects */
michael@0 8
michael@0 9 #include "xptcprivate.h"
michael@0 10
michael@0 11
michael@0 12 static uint32_t
michael@0 13 invoke_count_words(uint32_t paramCount, nsXPTCVariant* s)
michael@0 14 {
michael@0 15 uint32_t overflow = 0, gpr = 1 /*this*/, fpr = 0;
michael@0 16 for(uint32_t i = 0; i < paramCount; i++, s++)
michael@0 17 {
michael@0 18 if(s->IsPtrData())
michael@0 19 {
michael@0 20 if (gpr < 5) gpr++; else overflow++;
michael@0 21 continue;
michael@0 22 }
michael@0 23 switch(s->type)
michael@0 24 {
michael@0 25 case nsXPTType::T_I8 :
michael@0 26 case nsXPTType::T_I16 :
michael@0 27 case nsXPTType::T_I32 :
michael@0 28 if (gpr < 5) gpr++; else overflow++;
michael@0 29 break;
michael@0 30 case nsXPTType::T_I64 :
michael@0 31 if (gpr < 4) gpr+=2; else gpr=5, overflow+=2;
michael@0 32 break;
michael@0 33 case nsXPTType::T_U8 :
michael@0 34 case nsXPTType::T_U16 :
michael@0 35 case nsXPTType::T_U32 :
michael@0 36 if (gpr < 5) gpr++; else overflow++;
michael@0 37 break;
michael@0 38 case nsXPTType::T_U64 :
michael@0 39 if (gpr < 4) gpr+=2; else gpr=5, overflow+=2;
michael@0 40 break;
michael@0 41 case nsXPTType::T_FLOAT :
michael@0 42 if (fpr < 2) fpr++; else overflow++;
michael@0 43 break;
michael@0 44 case nsXPTType::T_DOUBLE :
michael@0 45 if (fpr < 2) fpr++; else overflow+=2;
michael@0 46 break;
michael@0 47 case nsXPTType::T_BOOL :
michael@0 48 case nsXPTType::T_CHAR :
michael@0 49 case nsXPTType::T_WCHAR :
michael@0 50 if (gpr < 5) gpr++; else overflow++;
michael@0 51 break;
michael@0 52 default:
michael@0 53 // all the others are plain pointer types
michael@0 54 if (gpr < 5) gpr++; else overflow++;
michael@0 55 break;
michael@0 56 }
michael@0 57 }
michael@0 58 /* Round up number of overflow words to ensure stack
michael@0 59 stays aligned to 8 bytes. */
michael@0 60 return (overflow + 1) & ~1;
michael@0 61 }
michael@0 62
michael@0 63 static void
michael@0 64 invoke_copy_to_stack(uint32_t paramCount, nsXPTCVariant* s, uint32_t* d_ov, uint32_t overflow)
michael@0 65 {
michael@0 66 uint32_t *d_gpr = d_ov + overflow;
michael@0 67 uint64_t *d_fpr = (uint64_t *)(d_gpr + 4);
michael@0 68 uint32_t gpr = 1 /*this*/, fpr = 0;
michael@0 69
michael@0 70 for(uint32_t i = 0; i < paramCount; i++, s++)
michael@0 71 {
michael@0 72 if(s->IsPtrData())
michael@0 73 {
michael@0 74 if (gpr < 5)
michael@0 75 *((void**)d_gpr) = s->ptr, d_gpr++, gpr++;
michael@0 76 else
michael@0 77 *((void**)d_ov ) = s->ptr, d_ov++;
michael@0 78 continue;
michael@0 79 }
michael@0 80 switch(s->type)
michael@0 81 {
michael@0 82 case nsXPTType::T_I8 :
michael@0 83 if (gpr < 5)
michael@0 84 *((int32_t*) d_gpr) = s->val.i8, d_gpr++, gpr++;
michael@0 85 else
michael@0 86 *((int32_t*) d_ov ) = s->val.i8, d_ov++;
michael@0 87 break;
michael@0 88 case nsXPTType::T_I16 :
michael@0 89 if (gpr < 5)
michael@0 90 *((int32_t*) d_gpr) = s->val.i16, d_gpr++, gpr++;
michael@0 91 else
michael@0 92 *((int32_t*) d_ov ) = s->val.i16, d_ov++;
michael@0 93 break;
michael@0 94 case nsXPTType::T_I32 :
michael@0 95 if (gpr < 5)
michael@0 96 *((int32_t*) d_gpr) = s->val.i32, d_gpr++, gpr++;
michael@0 97 else
michael@0 98 *((int32_t*) d_ov ) = s->val.i32, d_ov++;
michael@0 99 break;
michael@0 100 case nsXPTType::T_I64 :
michael@0 101 if (gpr < 4)
michael@0 102 *((int64_t*) d_gpr) = s->val.i64, d_gpr+=2, gpr+=2;
michael@0 103 else
michael@0 104 *((int64_t*) d_ov ) = s->val.i64, d_ov+=2, gpr=5;
michael@0 105 break;
michael@0 106 case nsXPTType::T_U8 :
michael@0 107 if (gpr < 5)
michael@0 108 *((uint32_t*) d_gpr) = s->val.u8, d_gpr++, gpr++;
michael@0 109 else
michael@0 110 *((uint32_t*) d_ov ) = s->val.u8, d_ov++;
michael@0 111 break;
michael@0 112 case nsXPTType::T_U16 :
michael@0 113 if (gpr < 5)
michael@0 114 *((uint32_t*)d_gpr) = s->val.u16, d_gpr++, gpr++;
michael@0 115 else
michael@0 116 *((uint32_t*)d_ov ) = s->val.u16, d_ov++;
michael@0 117 break;
michael@0 118 case nsXPTType::T_U32 :
michael@0 119 if (gpr < 5)
michael@0 120 *((uint32_t*)d_gpr) = s->val.u32, d_gpr++, gpr++;
michael@0 121 else
michael@0 122 *((uint32_t*)d_ov ) = s->val.u32, d_ov++;
michael@0 123 break;
michael@0 124 case nsXPTType::T_U64 :
michael@0 125 if (gpr < 4)
michael@0 126 *((uint64_t*)d_gpr) = s->val.u64, d_gpr+=2, gpr+=2;
michael@0 127 else
michael@0 128 *((uint64_t*)d_ov ) = s->val.u64, d_ov+=2, gpr=5;
michael@0 129 break;
michael@0 130 case nsXPTType::T_FLOAT :
michael@0 131 if (fpr < 2)
michael@0 132 *((float*) d_fpr) = s->val.f, d_fpr++, fpr++;
michael@0 133 else
michael@0 134 *((float*) d_ov ) = s->val.f, d_ov++;
michael@0 135 break;
michael@0 136 case nsXPTType::T_DOUBLE :
michael@0 137 if (fpr < 2)
michael@0 138 *((double*) d_fpr) = s->val.d, d_fpr++, fpr++;
michael@0 139 else
michael@0 140 *((double*) d_ov ) = s->val.d, d_ov+=2;
michael@0 141 break;
michael@0 142 case nsXPTType::T_BOOL :
michael@0 143 if (gpr < 5)
michael@0 144 *((uint32_t*)d_gpr) = s->val.b, d_gpr++, gpr++;
michael@0 145 else
michael@0 146 *((uint32_t*)d_ov ) = s->val.b, d_ov++;
michael@0 147 break;
michael@0 148 case nsXPTType::T_CHAR :
michael@0 149 if (gpr < 5)
michael@0 150 *((uint32_t*)d_gpr) = s->val.c, d_gpr++, gpr++;
michael@0 151 else
michael@0 152 *((uint32_t*)d_ov ) = s->val.c, d_ov++;
michael@0 153 break;
michael@0 154 case nsXPTType::T_WCHAR :
michael@0 155 if (gpr < 5)
michael@0 156 *((uint32_t*)d_gpr) = s->val.wc, d_gpr++, gpr++;
michael@0 157 else
michael@0 158 *((uint32_t*)d_ov ) = s->val.wc, d_ov++;
michael@0 159 break;
michael@0 160 default:
michael@0 161 // all the others are plain pointer types
michael@0 162 if (gpr < 5)
michael@0 163 *((void**) d_gpr) = s->val.p, d_gpr++, gpr++;
michael@0 164 else
michael@0 165 *((void**) d_ov ) = s->val.p, d_ov++;
michael@0 166 break;
michael@0 167 }
michael@0 168 }
michael@0 169 }
michael@0 170
michael@0 171 typedef nsresult (*vtable_func)(nsISupports *, uint32_t, uint32_t, uint32_t, uint32_t, double, double);
michael@0 172
michael@0 173 EXPORT_XPCOM_API(nsresult)
michael@0 174 NS_InvokeByIndex(nsISupports* that, uint32_t methodIndex,
michael@0 175 uint32_t paramCount, nsXPTCVariant* params)
michael@0 176 {
michael@0 177 vtable_func *vtable = *reinterpret_cast<vtable_func **>(that);
michael@0 178 vtable_func method = vtable[methodIndex];
michael@0 179 uint32_t overflow = invoke_count_words (paramCount, params);
michael@0 180 uint32_t *stack_space = reinterpret_cast<uint32_t *>(__builtin_alloca((overflow + 8 /* 4 32-bits gpr + 2 64-bits fpr */) * 4));
michael@0 181
michael@0 182 invoke_copy_to_stack(paramCount, params, stack_space, overflow);
michael@0 183
michael@0 184 uint32_t *d_gpr = stack_space + overflow;
michael@0 185 double *d_fpr = reinterpret_cast<double *>(d_gpr + 4);
michael@0 186
michael@0 187 return method(that, d_gpr[0], d_gpr[1], d_gpr[2], d_gpr[3], d_fpr[0], d_fpr[1]);
michael@0 188 }
michael@0 189

mercurial