working with JCForLoop

Jonathan Gibbons jonathan.gibbons at oracle.com
Wed Mar 2 22:17:06 PST 2011


On 03/02/2011 10:07 PM, Omkar Raut wrote:
> Hi Jonathan,
>
> Thank you for your reply. I was wondering if there is a documentation 
> for the Tree transformation. Is the method documentation is all that 
> is available?

That and looking at the examples embodied in the existing code.  For 
example, look at visitSwitch/visitEnumSwitch/visitStringSwitch to see 
how switch-on-enum and switch-on-strings are transformed into simpler 
code.  Of course, you're going the other way, from simple code to more 
complex code ( :-) ) but the principle's the same.

-- Jon


>
> Thanks,
> Omkar
>
> On Wed, Mar 2, 2011 at 9:47 PM, Jonathan Gibbons 
> <jonathan.gibbons at oracle.com <mailto:jonathan.gibbons at oracle.com>> wrote:
>
>     Omkar,
>
>     Tree transformations are normally better done in Lower.
>
>     -- Jon
>
>
>
>     On 03/02/2011 05:22 PM, Omkar Raut wrote:
>>     Hi
>>
>>     I am trying to modify the for loop for parallelization as part of
>>     school project i.e. when the body of for loop can be parallelized
>>     I will put some threads which do the partial iterations of loop
>>     and at the end combine the result. Something like below:
>>     *Original statements:*
>>     int[] a = new int[8];
>>     for(int i=0;i <8; i++){ a[i] = i;}
>>     *After my modification:*
>>     int[] a = new int[8];
>>     class ForThread extends Thread { ... define constructor to take
>>     array a, define run method to execute for loop for partial range
>>     i.e. a[0] - a[3] & a[4] - a[7] }
>>     ForThread t1 = new ForThread(a, 0, 3);
>>     ForThread t2 = new ForThread(a, 4, 7);
>>     t1.start();
>>     t2.start();
>>
>>     My approach:
>>     For this I am changing the AST to include a new Node. I am trying
>>     to modify the JavacParser.java at method parseStatement(). When
>>     in encounter case FOR: I will return a JCBlock object which has
>>     the thread definition and the following statements to execute
>>     threads.
>>
>>     Am I going in the right direction? Or I should define a new
>>     JCParForLoop object instead of putting JCBlock for the
>>     parallelization?
>>
>>     Thank you!
>>     Omkar Raut
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20110302/a3db461d/attachment.html 


More information about the compiler-dev mailing list