зеркало из https://github.com/mozilla/gecko-dev.git
Fixed quad-word alignment issues, vTable layout problems.
This commit is contained in:
Родитель
4bfb7582c3
Коммит
d23c738373
|
@ -25,8 +25,8 @@
|
|||
|
||||
*/
|
||||
XPTC_InvokeByIndex:
|
||||
save %sp,-(64 + 8),%sp ! room for the register window and
|
||||
! struct pointer, rounded up to 0 % 8
|
||||
save %sp,-(64 + 16),%sp ! room for the register window and
|
||||
! struct pointer, rounded up to 0 % 16
|
||||
mov %i2,%o0 ! paramCount
|
||||
mov %i3,%o1 ! params
|
||||
call invoke_count_words ! returns the required stack size in %o0
|
||||
|
@ -44,9 +44,12 @@ XPTC_InvokeByIndex:
|
|||
!
|
||||
! calculate the target address from the vtable
|
||||
!
|
||||
sll %i1,2,%l0 ! index *= 4
|
||||
sll %i1,3,%l0 ! index *= 8
|
||||
add %l0,12,%l0 ! += 12 (there's 1 extra entry in the vTable)
|
||||
! and we need the fn ptr which is the second
|
||||
! half of the 8 byte vTable entry
|
||||
ld [%i0],%l1 ! *that --> address of vtable
|
||||
ld [%l0 + %l1],%l0 ! that->vtable[index * 4] --> target address
|
||||
ld [%l0 + %l1],%l0 ! that->vtable[index * 8 + 12] --> target address
|
||||
!
|
||||
! set 'that' as the 'this' pointer and then load the next arguments
|
||||
! into the outgoing registers
|
||||
|
|
|
@ -72,6 +72,9 @@ invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s)
|
|||
break;
|
||||
}
|
||||
}
|
||||
// nuts, I know there's a cooler way of doing this, but it's late
|
||||
// now and it'll probably come to me in the morning.
|
||||
if (result & 0x3) result += 4 - (result & 0x3); // ensure q-word alignment
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -87,6 +90,12 @@ invoke_copy_to_stack(PRUint32* d, PRUint32 paramCount, nsXPTCVariant* s)
|
|||
nsXPTCVariant *l_s = s;
|
||||
uint32 l_paramCount = paramCount;
|
||||
|
||||
typedef struct {
|
||||
uint32 hi;
|
||||
uint32 lo;
|
||||
} DU; // have to move 64 bit entities as 32 bit halves since
|
||||
// stack slots are not guaranteed 16 byte aligned
|
||||
|
||||
for(uint32 i = 0; i < l_paramCount; i++, l_d++, l_s++)
|
||||
{
|
||||
if(l_s->IsPtrData())
|
||||
|
@ -96,19 +105,21 @@ invoke_copy_to_stack(PRUint32* d, PRUint32 paramCount, nsXPTCVariant* s)
|
|||
}
|
||||
switch(l_s->type)
|
||||
{
|
||||
case nsXPTType::T_I8 : *((int8*) l_d) = l_s->val.i8; break;
|
||||
case nsXPTType::T_I16 : *((int16*) l_d) = l_s->val.i16; break;
|
||||
case nsXPTType::T_I8 : *((int32*) l_d) = l_s->val.i8; break;
|
||||
case nsXPTType::T_I16 : *((int32*) l_d) = l_s->val.i16; break;
|
||||
case nsXPTType::T_I32 : *((int32*) l_d) = l_s->val.i32; break;
|
||||
case nsXPTType::T_I64 : *((int64*) l_d) = l_s->val.i64; l_d++; break;
|
||||
case nsXPTType::T_U8 : *((uint8*) l_d) = l_s->val.u8; break;
|
||||
case nsXPTType::T_U16 : *((uint16*) l_d) = l_s->val.u16; break;
|
||||
case nsXPTType::T_I64 :
|
||||
case nsXPTType::T_U64 :
|
||||
case nsXPTType::T_DOUBLE : *((uint32*) l_d++) = ((DU *)l_s)->hi;
|
||||
*((uint32*) l_d) = ((DU *)l_s)->lo;
|
||||
break;
|
||||
case nsXPTType::T_U8 : *((uint32*) l_d) = l_s->val.u8; break;
|
||||
case nsXPTType::T_U16 : *((uint32*) l_d) = l_s->val.u16; break;
|
||||
case nsXPTType::T_U32 : *((uint32*) l_d) = l_s->val.u32; break;
|
||||
case nsXPTType::T_U64 : *((uint64*) l_d) = l_s->val.u64; l_d++; break;
|
||||
case nsXPTType::T_FLOAT : *((float*) l_d) = l_s->val.f; break;
|
||||
case nsXPTType::T_DOUBLE : *((double*) l_d) = l_s->val.d; l_d++; break;
|
||||
case nsXPTType::T_BOOL : *((PRBool*) l_d) = l_s->val.b; break;
|
||||
case nsXPTType::T_CHAR : *((char*) l_d) = l_s->val.c; break;
|
||||
case nsXPTType::T_WCHAR : *((wchar_t*)l_d) = l_s->val.wc; break;
|
||||
case nsXPTType::T_CHAR : *((uint32*) l_d) = l_s->val.c; break;
|
||||
case nsXPTType::T_WCHAR : *((int32*)l_d) = l_s->val.wc; break;
|
||||
default:
|
||||
// all the others are plain pointer types
|
||||
*((void**)l_d) = l_s->val.p;
|
||||
|
|
|
@ -39,8 +39,8 @@ SharedStub:
|
|||
st %i4, [%fp + 84]
|
||||
st %i5, [%fp + 88]
|
||||
! now we can build our own stack frame
|
||||
save %sp,-(64 + 8),%sp ! room for the register window and
|
||||
! struct pointer, rounded up to 0 % 8
|
||||
save %sp,-(64 + 16),%sp ! room for the register window and
|
||||
! struct pointer, rounded up to 0 % 16
|
||||
! our function now appears to have been called
|
||||
! as SharedStub(nsISupports* that, PRUint32 index, PRUint32* args)
|
||||
! so we can just copy these through
|
||||
|
|
|
@ -25,6 +25,13 @@
|
|||
extern "C" nsresult
|
||||
PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, uint32* args)
|
||||
{
|
||||
|
||||
typedef struct {
|
||||
uint32 hi;
|
||||
uint32 lo;
|
||||
} DU; // have to move 64 bit entities as 32 bit halves since
|
||||
// stack slots are not guaranteed 16 byte aligned
|
||||
|
||||
#define PARAM_BUFFER_COUNT 16
|
||||
|
||||
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||
|
@ -67,19 +74,22 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, uint32* args)
|
|||
// else
|
||||
switch(type)
|
||||
{
|
||||
case nsXPTType::T_I8 : dp->val.i8 = *((PRInt8*) ap); break;
|
||||
case nsXPTType::T_I16 : dp->val.i16 = *((PRInt16*) ap); break;
|
||||
case nsXPTType::T_I8 : dp->val.i8 = *((PRInt32*) ap); break;
|
||||
case nsXPTType::T_I16 : dp->val.i16 = *((PRInt32*) ap); break;
|
||||
case nsXPTType::T_I32 : dp->val.i32 = *((PRInt32*) ap); break;
|
||||
case nsXPTType::T_I64 : dp->val.i64 = *((PRInt64*) ap); ap++; break;
|
||||
case nsXPTType::T_U8 : dp->val.u8 = *((PRUint8*) ap); break;
|
||||
case nsXPTType::T_U16 : dp->val.u16 = *((PRUint16*)ap); break;
|
||||
case nsXPTType::T_DOUBLE :
|
||||
case nsXPTType::T_U64 :
|
||||
case nsXPTType::T_I64 : ((DU *)dp)->hi = ((DU *)ap)->hi;
|
||||
((DU *)dp)->lo = ((DU *)ap)->lo;
|
||||
ap++;
|
||||
break;
|
||||
case nsXPTType::T_U8 : dp->val.u8 = *((PRUint32*) ap); break;
|
||||
case nsXPTType::T_U16 : dp->val.u16 = *((PRUint32*)ap); break;
|
||||
case nsXPTType::T_U32 : dp->val.u32 = *((PRUint32*)ap); break;
|
||||
case nsXPTType::T_U64 : dp->val.u64 = *((PRUint64*)ap); ap++; break;
|
||||
case nsXPTType::T_FLOAT : dp->val.f = *((float*) ap); break;
|
||||
case nsXPTType::T_DOUBLE : dp->val.d = *((double*) ap); ap++; break;
|
||||
case nsXPTType::T_BOOL : dp->val.b = *((PRBool*) ap); break;
|
||||
case nsXPTType::T_CHAR : dp->val.c = *((char*) ap); break;
|
||||
case nsXPTType::T_WCHAR : dp->val.wc = *((wchar_t*) ap); break;
|
||||
case nsXPTType::T_CHAR : dp->val.c = *((PRUint32*) ap); break;
|
||||
case nsXPTType::T_WCHAR : dp->val.wc = *((PRInt32*) ap); break;
|
||||
default:
|
||||
NS_ASSERTION(0, "bad type");
|
||||
break;
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
|
||||
*/
|
||||
XPTC_InvokeByIndex:
|
||||
save %sp,-(64 + 8),%sp ! room for the register window and
|
||||
! struct pointer, rounded up to 0 % 8
|
||||
save %sp,-(64 + 16),%sp ! room for the register window and
|
||||
! struct pointer, rounded up to 0 % 16
|
||||
mov %i2,%o0 ! paramCount
|
||||
mov %i3,%o1 ! params
|
||||
call invoke_count_words ! returns the required stack size in %o0
|
||||
|
@ -44,9 +44,12 @@ XPTC_InvokeByIndex:
|
|||
!
|
||||
! calculate the target address from the vtable
|
||||
!
|
||||
sll %i1,2,%l0 ! index *= 4
|
||||
sll %i1,3,%l0 ! index *= 8
|
||||
add %l0,12,%l0 ! += 12 (there's 1 extra entry in the vTable)
|
||||
! and we need the fn ptr which is the second
|
||||
! half of the 8 byte vTable entry
|
||||
ld [%i0],%l1 ! *that --> address of vtable
|
||||
ld [%l0 + %l1],%l0 ! that->vtable[index * 4] --> target address
|
||||
ld [%l0 + %l1],%l0 ! that->vtable[index * 8 + 12] --> target address
|
||||
!
|
||||
! set 'that' as the 'this' pointer and then load the next arguments
|
||||
! into the outgoing registers
|
||||
|
|
|
@ -72,6 +72,9 @@ invoke_count_words(PRUint32 paramCount, nsXPTCVariant* s)
|
|||
break;
|
||||
}
|
||||
}
|
||||
// nuts, I know there's a cooler way of doing this, but it's late
|
||||
// now and it'll probably come to me in the morning.
|
||||
if (result & 0x3) result += 4 - (result & 0x3); // ensure q-word alignment
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -87,6 +90,12 @@ invoke_copy_to_stack(PRUint32* d, PRUint32 paramCount, nsXPTCVariant* s)
|
|||
nsXPTCVariant *l_s = s;
|
||||
uint32 l_paramCount = paramCount;
|
||||
|
||||
typedef struct {
|
||||
uint32 hi;
|
||||
uint32 lo;
|
||||
} DU; // have to move 64 bit entities as 32 bit halves since
|
||||
// stack slots are not guaranteed 16 byte aligned
|
||||
|
||||
for(uint32 i = 0; i < l_paramCount; i++, l_d++, l_s++)
|
||||
{
|
||||
if(l_s->IsPtrData())
|
||||
|
@ -96,19 +105,21 @@ invoke_copy_to_stack(PRUint32* d, PRUint32 paramCount, nsXPTCVariant* s)
|
|||
}
|
||||
switch(l_s->type)
|
||||
{
|
||||
case nsXPTType::T_I8 : *((int8*) l_d) = l_s->val.i8; break;
|
||||
case nsXPTType::T_I16 : *((int16*) l_d) = l_s->val.i16; break;
|
||||
case nsXPTType::T_I8 : *((int32*) l_d) = l_s->val.i8; break;
|
||||
case nsXPTType::T_I16 : *((int32*) l_d) = l_s->val.i16; break;
|
||||
case nsXPTType::T_I32 : *((int32*) l_d) = l_s->val.i32; break;
|
||||
case nsXPTType::T_I64 : *((int64*) l_d) = l_s->val.i64; l_d++; break;
|
||||
case nsXPTType::T_U8 : *((uint8*) l_d) = l_s->val.u8; break;
|
||||
case nsXPTType::T_U16 : *((uint16*) l_d) = l_s->val.u16; break;
|
||||
case nsXPTType::T_I64 :
|
||||
case nsXPTType::T_U64 :
|
||||
case nsXPTType::T_DOUBLE : *((uint32*) l_d++) = ((DU *)l_s)->hi;
|
||||
*((uint32*) l_d) = ((DU *)l_s)->lo;
|
||||
break;
|
||||
case nsXPTType::T_U8 : *((uint32*) l_d) = l_s->val.u8; break;
|
||||
case nsXPTType::T_U16 : *((uint32*) l_d) = l_s->val.u16; break;
|
||||
case nsXPTType::T_U32 : *((uint32*) l_d) = l_s->val.u32; break;
|
||||
case nsXPTType::T_U64 : *((uint64*) l_d) = l_s->val.u64; l_d++; break;
|
||||
case nsXPTType::T_FLOAT : *((float*) l_d) = l_s->val.f; break;
|
||||
case nsXPTType::T_DOUBLE : *((double*) l_d) = l_s->val.d; l_d++; break;
|
||||
case nsXPTType::T_BOOL : *((PRBool*) l_d) = l_s->val.b; break;
|
||||
case nsXPTType::T_CHAR : *((char*) l_d) = l_s->val.c; break;
|
||||
case nsXPTType::T_WCHAR : *((wchar_t*)l_d) = l_s->val.wc; break;
|
||||
case nsXPTType::T_CHAR : *((uint32*) l_d) = l_s->val.c; break;
|
||||
case nsXPTType::T_WCHAR : *((int32*)l_d) = l_s->val.wc; break;
|
||||
default:
|
||||
// all the others are plain pointer types
|
||||
*((void**)l_d) = l_s->val.p;
|
||||
|
|
|
@ -39,8 +39,8 @@ SharedStub:
|
|||
st %i4, [%fp + 84]
|
||||
st %i5, [%fp + 88]
|
||||
! now we can build our own stack frame
|
||||
save %sp,-(64 + 8),%sp ! room for the register window and
|
||||
! struct pointer, rounded up to 0 % 8
|
||||
save %sp,-(64 + 16),%sp ! room for the register window and
|
||||
! struct pointer, rounded up to 0 % 16
|
||||
! our function now appears to have been called
|
||||
! as SharedStub(nsISupports* that, PRUint32 index, PRUint32* args)
|
||||
! so we can just copy these through
|
||||
|
|
|
@ -25,6 +25,13 @@
|
|||
extern "C" nsresult
|
||||
PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, uint32* args)
|
||||
{
|
||||
|
||||
typedef struct {
|
||||
uint32 hi;
|
||||
uint32 lo;
|
||||
} DU; // have to move 64 bit entities as 32 bit halves since
|
||||
// stack slots are not guaranteed 16 byte aligned
|
||||
|
||||
#define PARAM_BUFFER_COUNT 16
|
||||
|
||||
nsXPTCMiniVariant paramBuffer[PARAM_BUFFER_COUNT];
|
||||
|
@ -67,19 +74,22 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32 methodIndex, uint32* args)
|
|||
// else
|
||||
switch(type)
|
||||
{
|
||||
case nsXPTType::T_I8 : dp->val.i8 = *((PRInt8*) ap); break;
|
||||
case nsXPTType::T_I16 : dp->val.i16 = *((PRInt16*) ap); break;
|
||||
case nsXPTType::T_I8 : dp->val.i8 = *((PRInt32*) ap); break;
|
||||
case nsXPTType::T_I16 : dp->val.i16 = *((PRInt32*) ap); break;
|
||||
case nsXPTType::T_I32 : dp->val.i32 = *((PRInt32*) ap); break;
|
||||
case nsXPTType::T_I64 : dp->val.i64 = *((PRInt64*) ap); ap++; break;
|
||||
case nsXPTType::T_U8 : dp->val.u8 = *((PRUint8*) ap); break;
|
||||
case nsXPTType::T_U16 : dp->val.u16 = *((PRUint16*)ap); break;
|
||||
case nsXPTType::T_DOUBLE :
|
||||
case nsXPTType::T_U64 :
|
||||
case nsXPTType::T_I64 : ((DU *)dp)->hi = ((DU *)ap)->hi;
|
||||
((DU *)dp)->lo = ((DU *)ap)->lo;
|
||||
ap++;
|
||||
break;
|
||||
case nsXPTType::T_U8 : dp->val.u8 = *((PRUint32*) ap); break;
|
||||
case nsXPTType::T_U16 : dp->val.u16 = *((PRUint32*)ap); break;
|
||||
case nsXPTType::T_U32 : dp->val.u32 = *((PRUint32*)ap); break;
|
||||
case nsXPTType::T_U64 : dp->val.u64 = *((PRUint64*)ap); ap++; break;
|
||||
case nsXPTType::T_FLOAT : dp->val.f = *((float*) ap); break;
|
||||
case nsXPTType::T_DOUBLE : dp->val.d = *((double*) ap); ap++; break;
|
||||
case nsXPTType::T_BOOL : dp->val.b = *((PRBool*) ap); break;
|
||||
case nsXPTType::T_CHAR : dp->val.c = *((char*) ap); break;
|
||||
case nsXPTType::T_WCHAR : dp->val.wc = *((wchar_t*) ap); break;
|
||||
case nsXPTType::T_CHAR : dp->val.c = *((PRUint32*) ap); break;
|
||||
case nsXPTType::T_WCHAR : dp->val.wc = *((PRInt32*) ap); break;
|
||||
default:
|
||||
NS_ASSERTION(0, "bad type");
|
||||
break;
|
||||
|
|
Загрузка…
Ссылка в новой задаче