mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 15:52:07 +00:00
Bug 1476987 - Eliminate nsXPTCVariant::ptr. r=nika
MozReview-Commit-ID: JCazltUuMBf Differential Revision: https://phabricator.services.mozilla.com/D2241 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
c17a3e83a6
commit
4d4dfa4633
@ -94,8 +94,8 @@ invoke_copy_to_stack(uint64_t* stk, uint64_t *end,
|
||||
for (uint32_t i = 0; i < paramCount; i++, s++) {
|
||||
uint64_t word;
|
||||
|
||||
if (s->IsPtrData()) {
|
||||
word = (uint64_t)s->ptr;
|
||||
if (s->IsIndirect()) {
|
||||
word = (uint64_t)&s->val;
|
||||
} else {
|
||||
// According to the ABI, integral types that are smaller than 8
|
||||
// bytes are to be passed in 8-byte registers or 8-byte stack
|
||||
|
@ -74,9 +74,9 @@ invoke_copy_to_stack(uint32_t* stk, uint32_t *end,
|
||||
if (d == end) d = stk;
|
||||
NS_ASSERTION(d >= stk && d < end,
|
||||
"invoke_copy_to_stack is copying outside its given buffer");
|
||||
if(s->IsPtrData())
|
||||
if(s->IsIndirect())
|
||||
{
|
||||
*((void**)d) = s->ptr;
|
||||
*((void**)d) = &s->val;
|
||||
continue;
|
||||
}
|
||||
// According to the ARM EABI, integral types that are smaller than a word
|
||||
@ -314,8 +314,8 @@ invoke_copy_to_stack(uint32_t* stk, uint32_t *end,
|
||||
float *vfp_end = vfp_s_args + 16;
|
||||
|
||||
for (uint32_t i = 0; i < paramCount; i++, s++) {
|
||||
if (s->IsPtrData()) {
|
||||
copy_word(ireg_args, stk, end, (uint32_t)s->ptr);
|
||||
if (s->IsIndirect()) {
|
||||
copy_word(ireg_args, stk, end, (uint32_t)&s->val);
|
||||
continue;
|
||||
}
|
||||
// According to the ARM EABI, integral types that are smaller than a word
|
||||
|
@ -14,9 +14,9 @@ invoke_copy_to_stack(uint32_t paramCount, nsXPTCVariant* s, uint32_t* d)
|
||||
{
|
||||
for(uint32_t i = paramCount; i >0; i--, d++, s++)
|
||||
{
|
||||
if(s->IsPtrData())
|
||||
if(s->IsIndirect())
|
||||
{
|
||||
*((void**)d) = s->ptr;
|
||||
*((void**)d) = &s->val;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -25,8 +25,8 @@ InvokeCopyToStack(uint64_t * gpregs, double * fpregs,
|
||||
uint64_t value = 0u;
|
||||
|
||||
for (uint32_t i = 0; i < paramCount; i++, s++) {
|
||||
if (s->IsPtrData())
|
||||
value = (uint64_t) s->ptr;
|
||||
if (s->IsIndirect())
|
||||
value = (uint64_t) &s->val;
|
||||
else {
|
||||
switch (s->type) {
|
||||
case nsXPTType::T_FLOAT: break;
|
||||
@ -46,7 +46,7 @@ InvokeCopyToStack(uint64_t * gpregs, double * fpregs,
|
||||
}
|
||||
}
|
||||
|
||||
if (!s->IsPtrData() && s->type == nsXPTType::T_DOUBLE) {
|
||||
if (!s->IsIndirect() && s->type == nsXPTType::T_DOUBLE) {
|
||||
if (nr_fpr < FPR_COUNT)
|
||||
fpregs[nr_fpr++] = s->val.d;
|
||||
else {
|
||||
@ -54,7 +54,7 @@ InvokeCopyToStack(uint64_t * gpregs, double * fpregs,
|
||||
d++;
|
||||
}
|
||||
}
|
||||
else if (!s->IsPtrData() && s->type == nsXPTType::T_FLOAT) {
|
||||
else if (!s->IsIndirect() && s->type == nsXPTType::T_FLOAT) {
|
||||
if (nr_fpr < FPR_COUNT)
|
||||
// The value in %xmm register is already prepared to
|
||||
// be retrieved as a float. Therefore, we pass the
|
||||
|
@ -16,9 +16,9 @@ invoke_copy_to_stack(uint32_t* d, uint32_t paramCount, nsXPTCVariant* s)
|
||||
{
|
||||
for(; paramCount > 0; paramCount--, d++, s++)
|
||||
{
|
||||
if(s->IsPtrData())
|
||||
if(s->IsIndirect())
|
||||
{
|
||||
*((void**)d) = s->ptr;
|
||||
*((void**)d) = &s->val;
|
||||
continue;
|
||||
}
|
||||
switch(s->type)
|
||||
|
@ -12,9 +12,9 @@ invoke_copy_to_stack(uint64_t* d, uint32_t paramCount, nsXPTCVariant* s)
|
||||
{
|
||||
for(; paramCount > 0; paramCount--, d++, s++)
|
||||
{
|
||||
if(s->IsPtrData())
|
||||
if(s->IsIndirect())
|
||||
{
|
||||
*((void**)d) = s->ptr;
|
||||
*((void**)d) = &s->val;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -13,9 +13,9 @@ invoke_copy_to_stack(uint32_t paramCount, nsXPTCVariant* s, uint32_t* d)
|
||||
{
|
||||
for(uint32_t i = paramCount; i >0; i--, d++, s++)
|
||||
{
|
||||
if(s->IsPtrData())
|
||||
if(s->IsIndirect())
|
||||
{
|
||||
*((void**)d) = s->ptr;
|
||||
*((void**)d) = &s->val;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -76,7 +76,6 @@ struct nsXPTCVariant
|
||||
ExtendedVal ext;
|
||||
};
|
||||
|
||||
void* ptr;
|
||||
nsXPTType type;
|
||||
uint8_t flags;
|
||||
|
||||
@ -86,21 +85,9 @@ struct nsXPTCVariant
|
||||
// Bitflag definitions
|
||||
//
|
||||
|
||||
// Indicates that ptr (above, and distinct from val.p) is the value that
|
||||
// should be passed on the stack.
|
||||
//
|
||||
// In theory, ptr could point anywhere. But in practice it always points
|
||||
// to &val. So this flag is used to pass 'val' by reference, letting us
|
||||
// avoid the extra allocation we would incur if we were to use val.p.
|
||||
//
|
||||
// Various parts of XPConnect assume that ptr==&val, so we enforce it
|
||||
// explicitly with SetIndirect() and IsIndirect().
|
||||
//
|
||||
// Since ptr always points to &val, the semantics of this flag are kind of
|
||||
// dumb, since the ptr field is unnecessary. But changing them would
|
||||
// require changing dozens of assembly files, so they're likely to stay
|
||||
// the way they are.
|
||||
PTR_IS_DATA = 0x1,
|
||||
// Indicates that we &val.p should be passed n the stack, i.e. that
|
||||
// val should be passed by reference.
|
||||
IS_INDIRECT = 0x1,
|
||||
|
||||
// Indicates that the value we hold requires some sort of cleanup (memory
|
||||
// deallocation, interface release, JS::Value unrooting, etc). The precise
|
||||
@ -112,15 +99,12 @@ struct nsXPTCVariant
|
||||
};
|
||||
|
||||
void ClearFlags() {flags = 0;}
|
||||
void SetIndirect() {ptr = &val; flags |= PTR_IS_DATA;}
|
||||
void SetIndirect() {flags |= IS_INDIRECT;}
|
||||
void SetValNeedsCleanup() {flags |= VAL_NEEDS_CLEANUP;}
|
||||
|
||||
bool IsIndirect() const {return 0 != (flags & PTR_IS_DATA);}
|
||||
bool IsIndirect() const {return 0 != (flags & IS_INDIRECT);}
|
||||
bool DoesValNeedCleanup() const {return 0 != (flags & VAL_NEEDS_CLEANUP);}
|
||||
|
||||
// Internal use only. Use IsIndirect() instead.
|
||||
bool IsPtrData() const {return 0 != (flags & PTR_IS_DATA);}
|
||||
|
||||
// Implicitly convert to nsXPTCMiniVariant.
|
||||
operator nsXPTCMiniVariant&() {
|
||||
return *(nsXPTCMiniVariant*) &val;
|
||||
|
Loading…
Reference in New Issue
Block a user