Open WhiteTrashLord opened 8 years ago
Could you please give more information about the Optimization Levels?
They are not about code size, but about debug experience/speed tradeoff. But this may depend on different circumstances. For example, with FULL
optimization level WebAssembly backend produces slightly less code, which is not true for JS backend. The general rule is:
SIMPLE
optimizations recommended for development. On this level TeaVM tries to preserve debug information untouched.ADVANCED
optimizations recommended for production. They are similar to SIMPLE
, but ignore any debugging information (i.e. variable names and line numbers) and can change control flow, so they can give a little faster code.FULL
optimizations can be used for production, but their result is unpredictable. They can either increase or decrease performance. You should try both FULL
and ADVANCED
, measure speed and choose FULL
only if it actually gives a better result. Also, FULL
optimizations increase compilation time. FULL
optimizations usually give significantly better performance (15-20%) on WebAssembly backend.Here the the full table for now (this can be changed):
SIMLE
: Devirtualization, UnusedVariableElimination, EmptyBlockElimination, RedundantJumpElimination, GlobalValueNumbering, ClassInitElimination, UnreachableBasicBlockElimination. GVN does not touch named variables. Register allocator does not give same color to variables that have different names in debug information.ADVANCED
: SIMPLE
+ LoopInversion, LoopInvariantMotion, ConstantConditionElimination. Both GVN and register allocator ignore variables names.FULL
: ADVANCED
+ Inlining.Currently I can only work with the version 0.4.3 which doesn't have this new settings.
You can build TeaVM from sources and work with the most recent version.
git clone https://github.com/konsoletyper/teavm.git
cd teavm
mvn clean install -DskipTests
A high optimation level will reduce this kind of code?
No, you can't make TeaVM to strip this code. It's even impossible to remove this code completely, since without it TeaVM won't work at all.
Or you won't do anything about it because you don't think that this is important?
I don't know whether it's really important for you. You are speculating about "TeaVM generating too large files". You have to cease speculating and ask several questions.
.js
file generated by TeaVM?$rt_metadata
fragment?gzip
ing JS file? Is the compressed file still too huge?Thank you for your answer. I tried it with this very simple code:
public static void main() {
Window.alert(Window.current());
}
I was finally able to compile it by changing some of the TeaVM code. Using separate mode it generates a 17 kB Javascript file and the 30 kB runtime.js.
TeaVM is the best compiler among the compilers I have tested. So I think I will use it anyway. But it would be even better if it would produce even smaller Javascript output.
Why optimize TeaVM for "Hello World" writers? It's possible to optimize TeaVM a little in this direction, but the efforts won't worth spending.
Could you please give more information about the Optimization Levels? Currently I can only work with the version 0.4.3 which doesn't have this new settings.
In my case TeaVM would be a perfect if it would produce more efficient code.
Even very small code generates quite big Javascript files because there is a lot of code like this:
"java.util.Comparator",E,[],0,0,[],[],GC,"java.lang.String$1",E,[TB],0,0,[],["a",function(){DD(this);}],W,"java.lang.annotation.Annotation",E,[],0,0,[],[],J,"java.lang.AbstractStringBuilder",E,[DB,U],0,J_$clinit,['KC','DC','XD'],["a",function(){KC(this);},"c",function(a){DC(this,a);}],XB,"java.lang.Appendable",E,[],0,0,[],[],PC,"java.lang.StringBuilder",J,[XB],0,0,[],["a",function(){YE(this);}],FB,"java.io.InputStream",E,[AB],0,0,[],["a",function(){CE(this);}],IC,"java.lang.ConsoleInputStream",FB,[],0,0,[],
A high optimation level will reduce this kind of code? Or you won't do anything about it because you don't think that this is important?