I think it's better to make
  tab[i].invokeExact(...)
a tailcall,
so the loop will be part of the implementation, not part of the spec.

Rémi

----- Mail original -----
> De: "John Rose" <john.r.r...@oracle.com>
> À: "Da Vinci Machine Project" <mlvm-dev@openjdk.java.net>
> Envoyé: Jeudi 4 Août 2016 00:14:37
> Objet: Re: Threaded interpreter in Java

> On Aug 3, 2016, at 1:22 PM, Remi Forax <fo...@univ-mlv.fr> wrote:
>> 
>> Charles ask if we can make a fast register interpreter in Java,
>> here is my take on a threaded-like interpreter
>> 
>> https://gist.github.com/forax/f38b533e089217cfc4d0ae3c6e2de9c9
> 
> Nicely done.  We were talking last night at dinner about making
> bytecode interpreters go fast, and this is helpful.
> 
> I think there may be a combinator here, for bytecode dispatch loops.
> (This feels like the PIC combinator, both fundamental and tricky to get 
> right.)
> A "bytecode" dispatch combinator might provide a pattern like the following:
> 
> MethodHandle init, pred, step, fini, index;
> @NonNull MethodHandle[] tab;
> R dispatch(A… a) {
>   V v = init(a…);  // one here; there might be many v…
>   while (pred(a…)) {
>      v = step(v, a…);
>      // execute one "instruction":
>      int i = index(v, a…);
>      tab[i].invokeExact(v, a…);
>   }
>   return fini(V, a…);
> }
> 
> The explicit table would be recopied internally to an @Stable array for 
> constant
> folding.
> The various index values could be tracked and turned into traces (or some 
> other
> profile
> driven structure) which would be compiled together, in specialized segments of
> the unrolled
> interpreter loop.
> 
> Or maybe just the table lookup part alone makes a good combinator, to be 
> paired
> with the loop combinators?
> 
> Comments welcome…
> 
> — John
> 
> P.S. Another new RFE:
> experimental hook for creating heisenboxes
> https://bugs.openjdk.java.net/browse/JDK-8163133
> _______________________________________________
> 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

Reply via email to