[pypy-dev] pypy-jvm translating magic?

Antonio Cuni anto.cuni at gmail.com
Sat Oct 6 12:48:51 CEST 2007


Hi Nicholas,

Nicholas Riley wrote:

> I was able to translate targetnopstandalone to Java so it seems to
> work a little, but obviously there is a big difference between that
> and PyPy. :) Trawling the IRC logs I found:
> 
> [20:39] <antocuni> fijal: unfortunately pypy-jvm does not compile 
> out of the box
> [20:39] <antocuni> you have to manually patch two lines in rbigint 
> 
> Is this still true?  Is the patch available somewhere?

yes, it's still true; the patch is very little and simple:

Index: rlib/rbigint.py
===================================================================
--- rlib/rbigint.py     (revision 47111)
+++ rlib/rbigint.py     (working copy)
@@ -176,7 +176,8 @@
          return _AsLong(self)

      def tolonglong(self):
-        return _AsLongLong(self)
+        raise OverflowError # XXX
+        #return _AsLongLong(self)

      def tobool(self):
          return self.sign != 0


With this, you should be able to translate and compile pypy-jvm.

About performances, there are a lot of factors that could affect them. 
For example, I found that if we inline too much, performances are worse, 
probably because jvm's JIT compiles again and again the same code.

Moreover, PyPy provides also a number of optimizations to the 
interpreter which can greatly improve the efficiency: there is a 
--faassen option that includes all the optimizations known to be good 
for pypy-c, but I found that maybe not all of them are also good for 
pypy-jvm.

For example, I got better results with shadowtracking and methodcache 
disabled than with the full --fassen; I don't know why, it's probably 
worth of being investigated.

To conclude, you should try with the following command line to get best 
results:

./translate.py -b jvm --inline-threshold 0 targetpypystandalone.py 
--faassen --no-objspace-std-withshadowtracking 
--no-objspace-std-withmethodcache

You can also try to use only --fassen to see if the performances are 
worse also for you. Any other experiment with the options is very 
welcome, of course :-).

ciao Anto



More information about the Pypy-dev mailing list