Use java.util.List in type system

Renze Torensma renzetorensma at gmail.com
Wed Apr 8 20:03:30 UTC 2015


Hi Christian,

I created a basic List interface so I can swap the current basic implementation for a more optimized one later on without changing the type system and execute functions.
Is this considered good practice in Truffle or should I just use the implementation class? And you noted that Truffle inlines everything until it sees a virtual call, so if I understand correctly using the List interface in the type system creates virtual calls when methods on those List interface are called? For example, in “@Specialization concat(List a, List b) { a.add(b); }" a and b would actually be of class BasicList but specified with interface List, so the add method would be a virtual call and stop inlining even though it should be inlined?

Also all logic of the list operations like concatenation and insertion is implemented in the BasicList class that implements the List interface, and the addition node simply calls 
the concat method of the list interface to do the work for it. But Chris Seaton advised me to not implement logic in the type classes like I did now but in the node classes 
where the operation is specialized (see http://mail.openjdk.java.net/pipermail/graal-dev/2015-April/003015.html <http://mail.openjdk.java.net/pipermail/graal-dev/2015-April/003015.html>). If I apply his advise I think I should limit the List interface 
to getting and putting objects and use those methods to implement the concat and other operations in the node classes directly?

Sorry for the long post,
Renze

> On 7 apr. 2015, at 23:46, Renze Torensma <renzetorensma at gmail.com> wrote:
> 
> Thanks for your suggestions! Now I know why no current implementation uses the java.util.List subclasses :)
> 
> I will have a look at the implementations of jRuby and ZipPy, and I will start with a minimal version of my own List class.
> 
> Renze
>> On 7 apr. 2015, at 20:17, Stefan Marr <java at stefan-marr.de> wrote:
>> 
>> Hi Renze:
>> 
>>> On 07 Apr 2015, at 20:09, Christian Humer <christian.humer at gmail.com> wrote:
>>> 
>>> You can get some inspiration on the array implementation of JRuby:
>>> https://github.com/jruby/jruby/blob/master/truffle/src/main/java/org/jruby/truffle/runtime/core/RubyArray.java
>> 
>> Also interesting might be ZipPy’s solution:
>> 
>> https://bitbucket.org/ssllab/zippy/src/03c969e32efd9dd6f2949f71b5a8ecd79b962741/edu.uci.python.runtime/src/edu/uci/python/runtime/sequence/?at=default
>> 
>> Best regards
>> Stefan
>> 
>> -- 
>> Stefan Marr
>> INRIA Lille - Nord Europe
>> http://stefan-marr.de/research/
>> 
>> 
>> 
> 



More information about the graal-dev mailing list