Bug 1325495 - xpcom: Save %r26 in arg0 stack slot on hppa with gcc. r=froydnj

In the 32-bit parisc runtime, the first four non floating-point
arguments are passed in registers (%r26, %r25, %r24 and %r23).
The remaining arguments are passed on the stack. There are four
reserved slots on the stack that the callee can use to save the
first four argument registers if the callee desires.

The StubN functions are special in that arguments are not explicitly
declared. %r26 is used for the "self" pointer. The call to SharedStub(n)
loads n into %r26 and clobbers the "self" pointer in %r26. The hppa
SharedStub implementation expects to find the "self" pointer on the
stack in the slot reserved for StubN. However, gcc doesn't copy any
arguments to the stack as no arguments are declared for StubN. Even
if it did, there's no guarantee that we could force gcc to save the
argument on the stack as that's more expensive than copying to a
free register. Thus, we need to copy %r26 to the stack slot manually.
This commit is contained in:
John David Anglin 2016-12-30 23:09:23 +01:00 committed by Mike Hommey
parent a661d573ed
commit 0beeba79e1

View File

@ -126,11 +126,21 @@ PrepareAndDispatch(nsXPTCStubBase* self, uint32_t methodIndex,
extern "C" nsresult SharedStub(int);
#ifdef __GNUC__
#define STUB_ENTRY(n) \
nsresult nsXPTCStubBase::Stub##n() \
{ \
/* Save arg0 in its stack slot. This assumes the frame size is 64. */ \
__asm__ __volatile__ ("STW %r26, -36-64(%sp)"); \
return SharedStub(n); \
}
#else
#define STUB_ENTRY(n) \
nsresult nsXPTCStubBase::Stub##n() \
{ \
return SharedStub(n); \
}
#endif
#define SENTINEL_ENTRY(n) \
nsresult nsXPTCStubBase::Sentinel##n() \