Saturday, January 23, 2016

Re: JsInterop and indexed types


Famous TeaVM also can`t do that, unfortunately. 
 You are wrong. You can do that via @JSIndexer annotation. 

TeaVM java array class has a field "data" with the underlying native array, so that each access requires to read that field which dramatically hurts real-time performance.
Not really. TeaVM's IR has separate instructions for accessing data field (unwrap) and getting element by an index (get). When converting from JVM bytecodes, every occurrence of AALOAD/IALOAD/... is represented by these conseqential instructions. Now consider this Java code:

int a = array[x];
int b = array[y];

We get the following IR:

array1 = unwrap(array);
a = get(array1, x);
array2 = unwrap(array);
b = get(array2, y);

When GVN scans this sequence, it realizes that array1 and array2 are really the same and eliminates array2:

array1 = unwrap(array);
a = get(array1, x);
b = get(array1, y);

Unfortunately, GVN is incapable of handling loops. TeaVM does not perform LICM yet, but it is possible to implement. LICM should solve the issue.

Also, did you try to write benchmarks before claiming that wrapper slows down performance? V8 performs sophisticated performance optimizations. There is a great chance that V8 is capable to recognize an eliminate unnecessary access to data field.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment