mozilla/ia64 patch
Below is a patch that makes mozilla work on IA-64 (native, not via IA-32 emulation). The patch is relative to a recent snapshot of the CVS tree (I think I took the snapshot on May 12th). The first part is stuff that Jim Nance and a couple of mozilla developers contributed a while ago. The new code consists of the two files at the end of the
patch: xptcinvoke_ffi.cpp and xptcstubs_ffi.cpp. These files implement the mozilla xptcall facility using a (slightly enhanced) version of libffi ("foreign function interface"). The nice thing about using libffi is that the resulting mozilla files are platform-independent with two minor exceptions: layout of the vtable and the C++ name mangling. Even so, the current libffi based implementation *should* work both on IA-64 and Alpha, as far as I can tell (the latter has not been tested though).
With the patch below applied and a libffi patch that I'll mail out separately, you should be able to build a working mozilla/ia64 binary. I used the g++ compiler as included in the latest Red Hat beta ("wolverine"). Originally, I tried the g++ in the gcc3.0 CVS tree, but that didn't get me very far: g++ 3.0 seems more picky about static casts between pointers and 32-bit ints and there was also an internal-compiler-error on one file (I reported the problem to Jim Wilson).
My build had debugging enabled and optimization turned off. I have no reason to believe that it won't work with debugging turned off, but I haven't tried that (actually, I don't know how to build an optimized version... ;-). Testing has not been extensive. The TestXPTCInvoke test suite completes successfully, but this doesn't test the "stubs" facility of xptcall at all. Visiting various web sites (some with JavaScript) seemed to work fine, so I'll assume that the "stubs" facility works at least to some degree. Even the mail/news reader, document editor, and the address book seem to work fine (though I rarely use these, so I'm not exactly a power user...).
I don't expect to have much more time to play/debug mozilla/ia64, but I hope the attached patch is good enough to get others started. Also, if there are any questions/problems regarding the ffi based implementation of xptcall, I'd be happy to try to help. Note: one thing I'm sure needs fixing is the Makefile in xpcom/build (look for "fix me" in the patch below). I'm not familiar with the Mozilla build process and therefore did just the quick and dirty thing to always link in libffi. Obviously, this should be done only on those platforms that use this implementation.
Enjoy,
--david
Index: nsprpub/pr/include/md/_linux.cfg
=================================RCS file: /cvsroot/mozilla/nsprpub/pr/include/md/_linux.cfg,v retrieving revision 3.8.2.1
pr/include/md/nsprpub/pr/include/md/_linux.cfg +46 -0
@@ -120,6 +120,52 @@ #define PR_BYTES_PER_WORD_LOG2 3 #define PR_BYTES_PER_DWORD_LOG2 3 +#elif defined(__ia64__) + +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define IS_64 + +#define PR_BYTES_PER_BYTE 1 +#define PR_BYTES_PER_SHORT 2 +#define PR_BYTES_PER_INT 4 +#define PR_BYTES_PER_INT64 8 +#define PR_BYTES_PER_LONG 8 +#define PR_BYTES_PER_FLOAT 4 +#define PR_BYTES_PER_DOUBLE 8 +#define PR_BYTES_PER_WORD 8 +#define PR_BYTES_PER_DWORD 8 + +#define PR_BITS_PER_BYTE 8 +#define PR_BITS_PER_SHORT 16 +#define PR_BITS_PER_INT 32 +#define PR_BITS_PER_INT64 64 +#define PR_BITS_PER_LONG 64 +#define PR_BITS_PER_FLOAT 32 +#define PR_BITS_PER_DOUBLE 64 +#define PR_BITS_PER_WORD 64 + +#define PR_BITS_PER_BYTE_LOG2 3 +#define PR_BITS_PER_SHORT_LOG2 4 +#define PR_BITS_PER_INT_LOG2 5 +#define PR_BITS_PER_INT64_LOG2 6 +#define PR_BITS_PER_LONG_LOG2 6 +#define PR_BITS_PER_FLOAT_LOG2 5 +#define PR_BITS_PER_DOUBLE_LOG2 6 +#define PR_BITS_PER_WORD_LOG2 6 + +#define PR_ALIGN_OF_SHORT 2 +#define PR_ALIGN_OF_INT 4 +#define PR_ALIGN_OF_LONG 8 +#define PR_ALIGN_OF_INT64 8 +#define PR_ALIGN_OF_FLOAT 4 +#define PR_ALIGN_OF_DOUBLE 8 +#define PR_ALIGN_OF_POINTER 8 +#define PR_ALIGN_OF_WORD 8 + +#define PR_BYTES_PER_WORD_LOG2 3 +#define PR_BYTES_PER_DWORD_LOG2 3 + #elif defined(__mc68000__) #undef IS_LITTLE_ENDIAN
Index: nsprpub/pr/include/md/_linux.h
=================================RCS file: /cvsroot/mozilla/nsprpub/pr/include/md/_linux.h,v retrieving revision 3.24.2.2
pr/include/md/nsprpub/pr/include/md/_linux.h +13 -1
@@ -31,6 +31,8 @@#define _PR_SI_ARCHITECTURE "ppc"#elif defined(__alpha)#define _PR_SI_ARCHITECTURE "alpha" +#elif defined(__ia64__) +#define _PR_SI_ARCHITECTURE "ia64"#elif defined(__mc68000__)#define _PR_SI_ARCHITECTURE "m68k"#elif defined(__sparc__)
@@ -78,7 +80,7 @@#endif #undef _PR_USE_POLL#define _PR_STAT_HAS_ONLY_ST_ATIME -#if defined(__alpha) +#if defined(__alpha) || defined(__ia64__)#define _PR_HAVE_LARGE_OFF_T#else #define _PR_NO_LARGE_FILES
@@ -141,6 +143,16 @@/* XXX not sure if this is correct, or maybe it should be 17? */ #define PR_NUM_GCREGS 9 + +#elif defined(__ia64) + +#define _MD_GET_SP (_t) ((long *)((_t)->md.context[0].__jmpbuf)[0]) +#define _MD_SET_FP (_t, val) +#define _MD_GET_SP_PTR (_t) &(_MD_GET_SP(_t)) +#define _MD_GET_FP_PTR (_t) ((void *) 0) +#define _MD_SP_TYPE long int + +#define PR_NUM_GCREGS _JBLEN#elif defined(__mc68000__)/* m68k based Linux */
Index: xpcom/build/Makefile.in
=================================RCS file: /cvsroot/mozilla/xpcom/build/Makefile.in,v retrieving revision 1.27
build/xpcom/build/Makefile.in +2 -0
@@ -63,6 +63,8 @@ -I$(srcdir)/../proxy/src \ $(NULL) +EXTRA_DSO_LDOPTS += -lffi # XXX fix me + ifdef MOZ_DEMANGLE_SYMBOLS EXTRA_DSO_LDOPTS += -liberty endif
reflect/xptcall/src/md/unix/xptcstubs_ffi.cpp renamed from reflect/xptcall/src/md/unix/xptcinvoke_ffi.cpp +125 -57
206 lines not on this page · raw message
reflect/xptcall/src/md/unix/xptcinvoke_ffi.cpp new file +105 -0
105 lines not on this page · raw message
reflect/xptcall/src/md/unix/xptcstubs_ffi.cpp new file +173 -0
173 lines not on this page · raw message