views:

338

answers:

4

The Psyco docs say:

Just for reference, Psyco does not work on any 64-bit systems at all. This fact is worth being noted again, now that the latest Mac OS/X 10.6 "Snow Leopart" comes with a default Python that is 64-bit on 64-bit machines. The only way to use Psyco on OS/X 10.6 is by recompiling a custom Python in 32-bit mode.

In general, porting programs from 32 to 64 bits is only really an issue when the code assumes a certain size for a pointer type and other similarly small(ish) issues. Considering that Psyco isn't a whole lot of code (~32K lines of C + ~8K lines of Python), how hard could it be? Has anyone tried this and hit a wall? I haven't really had a chance to take a good look at the Psyco sources yet, so I'd really appreciate knowing if I'm wasting my time looking into this...

+2  A: 

Since psyco is a compiler, it would need to be aware of the underlying assembly language to generate useful code. That would mean it would need to know about the 8 new registers, new opcodes for 64 bit code, etc.

Furthermore, to interop with the existing code, it would need to use the same calling conventions as 64 bit code. The AMD-64 calling convention is similar to the old fast-call conventions in that some parameters are passed in registers (in the 64 bit case rcx,rdx,r8,r9 for pointers and Xmm0-Xmm3 for floating point) and the rest are pushed onto spill space on the stack. Unlike x86, this extra space is usually allocated once for all of the possible calls. The IA64 conventions and assembly language are different yet.

So in short, I think this is probably not as simple as it sounds.

Joel
Shouldn't the C compiler for the 64-bit platform take care of most of this? There seems to be very little inline assembly in psyco (<5 lines).
Chinmay Kanchi
Bah. Ignore that. My grepping skills could use some polishing, obviously...
Chinmay Kanchi
+1  A: 

+1 for "... how hard could it be?".

Take a look here: http://codespeak.net/svn/psyco/dist/c/i386/iprocessor.c

All that ASM would have to be ported, and there are assumptions all over the place about the underlying processor.

I think it's fair to say that if it were trivial to port (or not too difficult), it would already have been done.

Seth
Fair enough. I'd like to know _why_ this is such a monumental task though. Further searching has pointed me to mailing list posts where even Google's engineers seem to have given up on porting Psyco for the Unladen Swallow project.
Chinmay Kanchi
PS: The "how hard could it be" comment was firmly tongue-in-cheek. I fully expected there to be issues that I had not comprehended (which was kind of the point in posting this in the first place). Otherwise, I would have just tried it.
Chinmay Kanchi
I find myself saying "how hard could it be?" the same way just about every time I talk to marketing :P
Seth
+3  A: 

Christian Tismer, one of the Psyco developers also seems to disagree with the "how hard could it be" - assumption (quoted from here):

Needs to come to x86-64? Why that! Seriously, I would love to do that, but this would be much harder than anybody would expect. Due to the way psyco is written, it would be really half a rewrite to releave it from its 32-bitterness. The 32 bit assumption is implicitly everywhere. It would be straight forward, if the memory model was all 64 bit. But no intel platform is that simple. so long, and thanks for all the fish -- chris

and

hum. It would cost at least 3 or 4 months of full-time work do do that, if not more. I doubt that I can get sponsorship for that.

If you want more details (firm inside knowledge of Psyco probably needed) I guess you can always try to ask on one of the psyco mailing lists ...

ChristopheD
A: 

Psyco assumes that sizeof(int) == sizeof(void*) a bit all over the place. That's much harder than just writing down 64bit calling conventions and assembler. On the sidenote, pypy has 64bit jit support these days.

Cheers, fijal

fijal