[pypy-dev] Work on the JVM backend

Michał Bendowski michal at bendowski.pl
Mon Jan 16 13:03:18 CET 2012



On Monday, 16 January 2012 at 12:09 , Antonio Cuni wrote:

> Hello Michał,
>  
> On 01/16/2012 01:00 AM, Michał Bendowski wrote:
> > longlong2float and float2longlong turn out to be pretty straightforward in Java, so I implemented them and added tests. I tried to update the pull request to include this commit, but that crashed BitBucket :/ Maybe you can just pull it from my repo?
>  
>  
>  
> I reviewed your pull request. A few notes:
>  
> 1. float2longlong & longlong2float can be implemented in a more direct way by  
> using Double.doubleToRawLongBits and Double.longBitsToDouble


Good point, thanks.  

> 2. in revision 25d4d323cb5f, you implemented _identityhash of builtin types by  
> returning hash(self). This is wrong, because as the name suggests, it needs to  
> return different hashes for objects which are not identical. For example, look  
> at the following code:
>  
> > > > from pypy.rlib import objectmodel
> > > > a = 'foo'
> > > > b = 'f'; b += 'oo'
> > > > a == b
> > >  
> >  
>  
> True
> > > > a is b
> > >  
> >  
>  
> False
> > > > objectmodel.compute_identity_hash(a)
> > >  
> >  
>  
> 192311087
> > > > objectmodel.compute_identity_hash(b)
> > >  
> >  
>  
> -1955336075
>  
> The test should probably try to compute_unique_id of two strings which are
> equal but not identical, and check that they are different
>  

I have copied the hash(self) from ootype._instance – didn't consider subclasses messing with __hash__. Anyway, as compute_identity_hash is defined as the RPython equivalent of object.__hash__(x), the "stub implementation" in _builtin_type (and _instance) should just return object.__hash__(self), am I right?
  
>  
> 3. could you please transplant your checkins to some branch other than  
> default, e.g. jvm-improvements? This way I could just merge the pull request  
> and then run the test on buildbot, before doing the actual merge to default.


Sure. Do you want me to fix the mentioned problems in new commits or modify the patches using mq? I'm new to Mercurial and don't really know what is the preferred workflow.

Michał 


More information about the pypy-dev mailing list