You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
js-port translator: elide clinit guards for classes with no initializer (TeaVM parity)
GETSTATIC/PUTSTATIC/NEW/static-call sites emitted `_I(owner)`
(ensureClassInitialized) unconditionally, even when the owner's entire
hierarchy has no `<clinit>` and no deferred static-field initialization -- in
which case the runtime helper just walks the supertypes, finds nothing to run,
and returns. A TeaVM build of hellocodenameone emits ~90 class-init guards;
ParparVM emitted ~8900.
Add classNeedsInitialization(className): walks the class + superclasses +
(transitive) superinterfaces and returns true iff any has an explicit clinit or
deferred static init. Over-approximates (returns true) on unknown classes /
hierarchy cycles so a needed guard is never dropped; static fields are
default-initialised at defineClass time, so a clinit-less class is safe to read
unguarded. Consulted at all four `_I(...)` emission sites (straight-line,
interpreter, static-method entry, static wrapper). Result cached per
translation run (cleared in setClassIndex).
hellocodenameone: clinit guards 8906 -> 6075 (-32%); translated_app.js
5127 -> 5101 KB raw, 1075 -> 1070 gzip; fewer runtime ensureClassInitialized
calls (startup perf). Verified: clean boot, UI renders, no errors. The
remaining guards are on genuinely init-bearing hierarchies; closing the rest of
the gap to TeaVM needs whole-program "already-initialised" propagation.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments