A fast JSON serializer

2016-09-14 Thread Remi Forax
Another idea from the JVM Summit,
because the JDK9 now uses fast string concatenation by default, a JSON 
serializer based on reflection can be outperformed by a hand written code.  

The following code is a small JSON serializer that use the StringConcatFactory 
of JDK9
  https://gist.github.com/forax/76124b69631475105f87ddd2205a4d91

enjoy,
Rémi
___
mlvm-dev mailing list
mlvm-dev@openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev


Making the loop combinator fast !

2016-09-14 Thread Remi Forax
One idea i've got during the JVM Summit,
here is a code that implements the Stream.filter/map/reduce operations using 
the new loop method handle,
  https://gist.github.com/forax/b5257dfac85e74335e02b5a6b95c9182

Currently, the code that use method handles is far slower than the 
java.util.stream.Stream equivalent,
so the challenge is how to make it perform better.

Maybe, it means we should introduce a special method handle combiner/something 
else that explicit ask for compiling to bytecode + JITing a method handle.

cheers,
Rémi
___
mlvm-dev mailing list
mlvm-dev@openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev


MethodHandle loop body parameters and Stream.reduce accumulator parameters are not in the same order

2016-09-14 Thread Remi Forax
Hi everybody,
i've just found that the parameters of the body (a MethodHandle) of 
MethodHandles.countedLoop (both overloads) and iteratedLoop are not in the same 
order as the accumulator in methods Stream.reduce, given that they conceptually 
represent the same thing, i think the first two parameters of body should be 
swapped in countedLoop and iteratedLoop.

in Stream:
 U reduce(U identity,
 BiFunction accumulator,
 BinaryOperator combiner)
 so this is equivalent to value = accumulator(value, element)

In MethodHandles:
   MethodHandle iteratedLoop(MethodHandle iterator,
 MethodHandle init,
 MethodHandle body)
  with value = body(element, value, iterable)
it should be
  value = body(value, element, iterable).

Same things for 
   MethodHandle countedLoop(MethodHandle start,
MethodHandle end,
MethodHandle init,
MethodHandle body)  
  it should be
value = body(value, index, array); 
  instead of
value = body(index, value, array);

the other loop combinators do not be to be changed.

cheers,
Rémi
___
mlvm-dev mailing list
mlvm-dev@openjdk.java.net
http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev