[LLVMdev] Iterator protocols

Talin viridia at gmail.com
Tue May 13 18:22:09 PDT 2008


Dan Gohman wrote:
> On May 12, 2008, at 6:49 PM, Talin wrote:
>   
>> So the question is, what's the trade-off. In most languages that  
>> support
>> exceptions, you tend to think of exceptions as expensive operations  
>> that
>> should only be thrown if something truly "exceptional" happens. OTOH,
>> the Java case is also made worse by the fact that a large part of the
>> time you'll be using the more expensive interface dispatching, rather
>> than simple vtable dispatching.
>>     
>
> How dynamic is your language? Is it possible that the resolution of
> the hasNext method could change as the loop executes? If not, it
> would be neat to find a way to resolve the hasNext callee once,
> before the loop, and then just make a simple call on each iteration.
>   
That's a good idea, actually - all my vtables are LLVM constants.

Actually, what I am hoping for is a little better than that: In the 
cases where the compiler can "see" the concrete class of the iterator, 
and the "hasNext" method is declared final (which it should be), it 
ought to be able to inline the "hasNext" method directly into the loop code.

However, such cases may end up being rare, so I need to consider the 
less optimal case.
> Dan
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>   




More information about the llvm-dev mailing list