Re: [pypy-dev] Towards pypy-jvm

2007-04-05 Thread Antonio Cuni
Niko Matsakis wrote:
 Some weeks ago I also tried to translate pypy-jvm; it seems that the 
 two most important missing features are r_dict and weakrefs.
 
 Ok, I implemented r_dicts now and checked it in.  Not too much work, 
 actually, ended up fitting fairly naturally into the existing code.  I 

Hi Niko!
This is very cool!  :-)
Most of r_dict tests are in test_objectmodel, though you may want to 
have also a look at rpython/test/test_rconstantdict.

About the distinction between r_dict and custom dict: do you find any 
place where they are used interchangeably?
I would say that r_dict referes so the rpython-level type 
(objectmodel.r_dict), while custom dict should refer to the low level 
type used by the rtyper (ootype.CustomDict). Also, probably CustomDict 
would be a better name than RDict for your java class, I guess.

  guess I'll look at weakrefs next, though no promises as to when that
  will be. :)

Adding weakrefs to gencli was very simple: I just needed to map 
lltypesystem.llmemory.WeakGcAddress to 'System.WeakReference', add the 
straightforward support for constants to cli/constant.py and add the 
also straightforward 'cast_ptr_to_weakadr' and 'cast_weakadr_to_ptr' 
operations in opcodes.py.
I don't know for jvm, but I guess it would not be much more complicate.

ciao Anto
___
pypy-dev@codespeak.net
http://codespeak.net/mailman/listinfo/pypy-dev


Re: [pypy-dev] Towards pypy-jvm

2007-04-05 Thread Niko Matsakis
 Most of r_dict tests are in test_objectmodel, though you may want  
 to have also a look at rpython/test/test_rconstantdict.

Ah, ok.

 About the distinction between r_dict and custom dict: do you find  
 any place where they are used interchangeably?

I guess not.  I just wasn't clear if they should be usable  
interchangeably or not.  As it happens, I renamed my Java class to  
CustomDict anyhow, because it was an implementation of the  
ootype.CustomDict, so it seemed right.

 Adding weakrefs to gencli was very simple: I just needed to map  
 lltypesystem.llmemory.WeakGcAddress to 'System.WeakReference', add  
 the straightforward support for constants to cli/constant.py and  
 add the also straightforward 'cast_ptr_to_weakadr' and  
 'cast_weakadr_to_ptr' operations in opcodes.py.
 I don't know for jvm, but I guess it would not be much more  
 complicate.

Cool, I'll check it out.


Niko
___
pypy-dev@codespeak.net
http://codespeak.net/mailman/listinfo/pypy-dev


Re: [pypy-dev] Towards pypy-jvm

2007-04-04 Thread Niko Matsakis
 Some weeks ago I also tried to translate pypy-jvm; it seems that  
 the two most important missing features are r_dict and weakrefs.

Ok, I implemented r_dicts now and checked it in.  Not too much work,  
actually, ended up fitting fairly naturally into the existing code.   
I guess I'll look at weakrefs next, though no promises as to when  
that will be. :)


Niko
___
pypy-dev@codespeak.net
http://codespeak.net/mailman/listinfo/pypy-dev


Re: [pypy-dev] Towards pypy-jvm

2007-04-03 Thread Niko Matsakis
 No, for .NET it was simpler because the standard Dictionary type  
 also accepts an optional class that implements the custom  
 functions, so all I need to do is to create a class for each unique  
 pair of equality and hashing functions (see cli/comparer.py).

So, on a whim I implemented a RDict class for the JVM that does the  
necessary adaptation.  (It consists almost entirely of generic type  
declarations and no actual code ;)  I haven't integrated it into the  
Python code yet, looking to see where best to do that.

Are most of the tests for custom dicts in test_objectmodel?  Also,  
why are they called rdicts in some places, and custom dicts in  
others?  Or is there a distinction I am missing?


Niko
___
pypy-dev@codespeak.net
http://codespeak.net/mailman/listinfo/pypy-dev


Re: [pypy-dev] Towards pypy-jvm

2007-04-01 Thread Antonio Cuni
Niko Matsakis wrote:
 The last time I checked what java's Hasttable offers and I saw you 
 can't pass to it custom hashing and equality functions, but maybe 
 there is a simple way to do it that I don't know.
 
 No, there isn't, but it shouldn't be too hard to cook up some kind of 
 Hashtable substitute that uses small wrapper classes to handle that.  I 
 think that's what you did for C#, right?

No, for .NET it was simpler because the standard Dictionary type also 
accepts an optional class that implements the custom functions, so all I 
need to do is to create a class for each unique pair of equality and 
hashing functions (see cli/comparer.py).

ciao Anto
___
pypy-dev@codespeak.net
http://codespeak.net/mailman/listinfo/pypy-dev


[pypy-dev] Towards pypy-jvm

2007-03-30 Thread Antonio Cuni
Hi Niko, hi all!

I've read in the IRC logs that there has been a bit of discussion about 
what genjvm still lacks in order to translate pypy.

Some weeks ago I also tried to translate pypy-jvm; it seems that the two 
most important missing features are r_dict and weakrefs.

The good news is that with some hacks it's possible to get a pypy 
version that doesn't make use of r_dict or weakrefs: have a look at this 
IRC log:
http://tismerysoft.de/pypy/irc-logs/pypy/%23pypy.log.20070307

The bad news is that even with those changes, jvm crashed because of a 
failed assertion, then I gave up. I've no clue what it's going wrong, 
but maybe it's not something terribly wrong to fix.

I hope that this infos can help you in some way :-).

ciao Anto
___
pypy-dev@codespeak.net
http://codespeak.net/mailman/listinfo/pypy-dev


Re: [pypy-dev] Towards pypy-jvm

2007-03-30 Thread Niko Matsakis
 The bad news is that even with those changes, jvm crashed because  
 of a failed assertion, then I gave up. I've no clue what it's going  
 wrong, but maybe it's not something terribly wrong to fix.

 I hope that this infos can help you in some way :-).

I'll look into it, thanks!  I think implementing rdicts and weakrefs  
would probably be pretty easy, so maybe I will just do that.  I've  
been itching to get back to PyPy-hacking anyhow!


Niko
___
pypy-dev@codespeak.net
http://codespeak.net/mailman/listinfo/pypy-dev