konsoletyper / teavm

Compiles Java bytecode to JavaScript, WebAssembly and C
https://teavm.org
Apache License 2.0
2.64k stars 265 forks source link

Incremental build #9

Closed konsoletyper closed 10 years ago

konsoletyper commented 10 years ago

TeaVM gets working too long, that is inconvenient for frequent build and run phase. Instead of the full rebuild it could cache results of different build phases and then reuse them to generate the final JS file. This cache must be capable of invalidating on per-class basis. Here are the list of things that can be cached:

  1. Name table must be shared between classes and stored into cache for use by another parts of cache. This allows to decrease a total size of the cache by referring to method table by index instead of storing full method name.
  2. Dependency checker should store dependency graph of each method. This will allow to create a more compact dependency graph of a method, which will increase the speed of dependency checker in general, as it has to visit less amount of nodes. However, fresh build will be slower, as dependency checker has to spend time optimizing each method's dependency graph.
  3. Decompiler should store optimized AST of each method.
  4. Inter-method optimizations like devirtualization and inlining should be either avoided of handled carefully.
konsoletyper commented 10 years ago

This feature is implemented. However, it is very hard to make dependency analyzer to be incremental, so "incremental" build just caches some stages of build. This speeds up build time about twice, when no resources changed. May be some day I'll try to invent incremental dependency analyzer.