What can we improve in JSR292 for Java 9?

Remi Forax forax at univ-mlv.fr
Thu Aug 27 00:33:01 UTC 2015


yes, you're right, 
so if think i prefer to 'allow a free intermixing of any number of steps (var updates) with any other number of pred/fini pairs' which requires less brain power to understand that the double encoding you are proposing :) 

Something like: 

public interface InnerLoopBuilder { 
// variableIndex in [0..inits.length[ 
void addVariableUpdate(int variableIndex, MethodHandle step); 

void addLoopExit(MethodHandle predicate, MethodHandle finisher); 
} 

MethodHandle loopMH(MethodHandle[] inits, Consumer<InnerLoopBuilder> consumer) { ... } 

cheers, 
Rémi 


----- Mail original -----

De: "John Rose" <john.r.rose at oracle.com> 
À: "Rémi Forax" <forax at univ-mlv.fr> 
Cc: "Da Vinci Machine Project" <mlvm-dev at openjdk.java.net> 
Envoyé: Jeudi 27 Août 2015 01:28:20 
Objet: Re: What can we improve in JSR292 for Java 9? 

On Aug 26, 2015, at 6:06 AM, Rémi Forax < forax at univ-mlv.fr > wrote: 



it's less powerful but it seems you can encode all your examples of loops too. 




No, I don't think so. Multiple pred/fini pairs implement multiple loop exits. 
Any loop with an "if-return" in it has an exit distinct from the loop's main test. 
And each exit requires a different fini function, to encode a special result. 

The match loop has this multi-exit character: 

for (int i; i < a.len; i++) { 
Object e = a[i]; 
if (ok(e)) return e; // first fini function; could also be e.payload 
} 
return null; // second fini function; could also be throwNotFound or Optional.none 

Sometimes even "&&" type predicate logic expands into multi-exit code, if the loop needs to return a value that encodes which sub-predicate caused the exit. 

— John 



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/mlvm-dev/attachments/20150827/b8f7c33a/attachment-0001.html>


More information about the mlvm-dev mailing list