[codenameone/CodenameOne] f4d6eb: js-port: structured emission for natural loops (la...

0 views
Skip to first unread message

Shai Almog

unread,
Jun 11, 2026, 8:36:56 PM (5 hours ago) Jun 11
to codenameo...@googlegroups.com
Branch: refs/heads/initializr-local-javascript-build
Home: https://github.com/codenameone/CodenameOne
Commit: f4d6eb176a626dfa98fffe9662454c84deebfc37
https://github.com/codenameone/CodenameOne/commit/f4d6eb176a626dfa98fffe9662454c84deebfc37
Author: Shai Almog <67850168+...@users.noreply.github.com>
Date: 2026-06-12 (Fri, 12 Jun 2026)

Changed paths:
M vm/ByteCodeTranslator/src/com/codename1/tools/translator/JavascriptMethodGenerator.java
M vm/ByteCodeTranslator/src/javascript/parparvm_runtime.js

Log Message:
-----------
js-port: structured emission for natural loops (labeled for(;;)/continue)

Extends the labeled-break structured emitter to single-header natural
loops: back edges lower to continue B<h> inside B<h>: for(;;) regions,
loop exits stay labeled breaks, forward entries to a header go through
a pre-header label closing just before the for opens, and a region end
that can fall off the bottom gets a synthesized break so the for cannot
spin. Loop regions must nest properly and may only be entered at the
header (irreducible flow bails to the interpreter). Labeled blocks nest
WITH the region structure -- a target inside a loop opens its label
after that loop's for(;;) brace, since a function-top label there would
sever the for ('continue B3' outside its loop is a syntax error).

Two codegen-soundness fixes found by hash-bisecting a boot wedge down
to the UTF-8 decoder:
- IINC is a local WRITE and now materialises deferred pending reads of
that local first, exactly like the store opcodes -- without it,
data[off + i++] read the post-increment index (the decoder skipped
byte 0 of every string and boot died silently).
- Entering a merge point drops stale pendings left by dead fall-off
paths so they cannot shadow the flushed slot values.

Ships debug bisection knobs (parparvm.js.structured.maxblocks /
maxloopspan / loopkeep / looponly) and a diag-gated long-sleep tracer
used to isolate the wedge. 1,205 loops structured; -309KB raw on the
test app (6.98MB -> 6.67MB; 11.93MB at the start of the effort).

Co-Authored-By: Claude Fable 5 <nor...@anthropic.com>



To unsubscribe from these emails, change your notification settings at https://github.com/codenameone/CodenameOne/settings/notifications
Reply all
Reply to author
Forward
0 new messages