My rule of thumb is: if you know that one concrete code shape will always fit the execution, I'd just emit the bytecode. Invokedynamic is great for cases where the executed code needs to change from time to time. You can also combine it - the invocation of actual property getters "getA()", "getB()" etc. are invokeDynamic linked, and the branching is in bytecode; i.e. if you know that the sequence at that point in the code will always be "a.b.c.d".
Attila. On Sun, May 27, 2012 at 11:12 AM, Dain Sundstrom <d...@iq80.com> wrote: > Hi all, > > I have a general strategy question about using invoke dynamic. Say I have a > dynamic language that has null safe property chaining where "a.b.c.d" results > in null if a null is encountered anywhere in the chain. I could implement > this two ways, 1) generate byte code that checks for nulls or 2) use a > guarded method handle at each step that takes care of the nulls. Either > option is ok with me, but I'd rather not write both versions to and then try > to figure out which one will make the JVM angry. > > As a broader question, there are lots of places where I can make this type of > decision (e.g., pass by value parameters, copy on assignment value classes), > is there a rule of thumb for going with traditional byte code over branching > method handles? > > Thanks, > > -dain > _______________________________________________ > mlvm-dev mailing list > mlvm-dev@openjdk.java.net > http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev _______________________________________________ mlvm-dev mailing list mlvm-dev@openjdk.java.net http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev