Skip to content

Playground: build via local ParparVM JavaScript target#5250

Open
shai-almog wants to merge 3 commits into
masterfrom
playground-local-javascript-target
Open

Playground: build via local ParparVM JavaScript target#5250
shai-almog wants to merge 3 commits into
masterfrom
playground-local-javascript-target

Conversation

@shai-almog

Copy link
Copy Markdown
Collaborator

Migrates the Playground off the pinned old release + cloud javascript build target onto the local ParparVM local-javascript target — the same path the initializr uses (#5200) — and removes the class-exclusion list and version pinning that worked around the lagging cloud TeaVM backend.

Playground (scripts/cn1playground/)

  • Build target: javascript/pom.xml codename1.defaultBuildTarget and build.sh/build.bat switch javascriptlocal-javascript. The cloud javascript target remains a fallback.
  • Un-pin: dropped the one-release cn1.registry.version (7.0.234) pin. The bean-shell access registry now tracks the current API directly. New cn1.accessRegistry.useLocalSources property (true under the cn1-local-workspace profile) generates the registry from the repo's own CN1 sources (8.0-SNAPSHOT has no source jars on Central); common/pom.xml passes it to the generator as CN1_ACCESS_USE_LOCAL_SOURCES.
  • Exclusion list (GenerateCN1AccessRegistry.java): removed the security.* / nfc.* exclusions — those were cloud-TeaVM-lag workarounds, and the local target builds current sources. Kept the structural exclusions: Accessor/IOAccessor internals, and Simd (its alloca scratch arrays may not escape the reflection bridge under the bytecode-compliance check, which the local target enforces too). Also fixed an array-component varargs codegen bug surfaced by re-including NFC: emit new byte[len][], not the malformed new byte[][len], for T[]... params.

JS-port translator (vm/ByteCodeTranslator/)

The Playground's reflective registry references nearly the whole API, exercising paths a normal app doesn't:

  • Array class literals: the JS backend only handled object ldc class literals and threw Unsupported ldc constant on array literals (byte[].class, String[].class), which the registry emits for every array-typed parameter. Now lowered to jvm.getArrayClass(component, dims).classObject (cached under the same name array instances use).
  • Error swallowing: Parser.writeOutput caught Throwable but only rethrew Exception, so an OutOfMemoryError mid-emit let the translator exit 0 with a truncated dist (parparvm_runtime.js but no worker.js/translated_app.js). Now rethrows Errors so the build fails loudly.

Plugin / build wiring

  • JavaScriptBuilder: a -Xmx in CN1_TRANSLATOR_OPTS now overrides the default 512m translator heap.
  • The Playground keeps nearly the whole API reachable, so the JS RTA tree-shaking pass can't prune yet runs 100min+. build.sh/build.bat and the website build_playground_for_site set CN1_TRANSLATOR_OPTS=-Dparparvm.js.rta.off -Xmx6g; the website extraction flattens the single wrapper dir so index.html lands at the served root (mirroring the initializr path).

Verification

Built locally with the local 8.0-SNAPSHOT plugin: the local-javascript build produces a complete bundle (index.html, worker.js, translated_app + 6 chunks, parparvm_runtime.js, browser_bridge.js, js/ assets, themes, Monaco editor html.tar, native-interface stub) that loads in headless Chromium with no fatal JS/VM errors. The regenerated registry now includes com.codename1.security.* / com.codename1.nfc.* and still excludes the internals + Simd.

Note: most of the diff is the regenerated bsh/cn1/GeneratedCN1Access*.java (checked-in generated source, regenerated each build).

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

✅ ByteCodeTranslator Quality Report

Test & Coverage

  • Tests: 390 total, 0 failed, 14 skipped

Benchmark Results

  • Execution Time: 15679 ms

  • Hotspots (Top 20 sampled methods):

    • 23.03% java.util.ArrayList.indexOf (331 samples)
    • 6.82% com.codename1.tools.translator.BytecodeMethod.addToConstantPool (98 samples)
    • 5.78% com.codename1.tools.translator.Parser.addToConstantPool (83 samples)
    • 4.18% java.lang.StringBuilder.append (60 samples)
    • 3.27% com.codename1.tools.translator.BytecodeMethod.optimize (47 samples)
    • 2.64% com.codename1.tools.translator.BytecodeMethod.equals (38 samples)
    • 2.30% org.objectweb.asm.tree.analysis.Analyzer.analyze (33 samples)
    • 2.23% com.codename1.tools.translator.BytecodeMethod.appendCMethodPrefix (32 samples)
    • 2.16% com.codename1.tools.translator.Parser.generateClassAndMethodIndexHeader (31 samples)
    • 2.02% java.lang.Object.hashCode (29 samples)
    • 1.88% java.lang.System.identityHashCode (27 samples)
    • 1.74% com.codename1.tools.translator.Parser.classIndex (25 samples)
    • 1.67% org.objectweb.asm.tree.analysis.Analyzer.findSubroutine (24 samples)
    • 1.04% java.util.TreeMap.getEntry (15 samples)
    • 1.04% com.codename1.tools.translator.ByteCodeClass.markDependent (15 samples)
    • 0.97% com.codename1.tools.translator.BytecodeMethod.addInstruction (14 samples)
    • 0.97% com.codename1.tools.translator.Parser.resolveDupForms (14 samples)
    • 0.90% org.objectweb.asm.ClassReader.readCode (13 samples)
    • 0.84% com.codename1.tools.translator.MethodDependencyGraph.getCallers (12 samples)
    • 0.70% java.io.FileOutputStream.open0 (10 samples)
  • ⚠️ Coverage report not generated.

Static Analysis

  • ✅ SpotBugs: no findings (report was not generated by the build).
  • ⚠️ PMD report not generated.
  • ⚠️ Checkstyle report not generated.

Generated automatically by the PR CI workflow.

@shai-almog

shai-almog commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 128 screenshots: 128 matched.

Native Android coverage

  • 📊 Line coverage: 14.22% (8655/60877 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 11.51% (42633/370328), branch 5.06% (1763/34839), complexity 6.05% (2021/33383), method 10.51% (1639/15601), class 17.13% (377/2201)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6327 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.ClassReader – 0.00% (0/1519 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1148 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.MethodWriter – 0.00% (0/923 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/730 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/623 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.Frame – 0.00% (0/564 lines covered)
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysJvmKt – 0.00% (0/495 lines covered)
      • kotlinx.coroutines.kotlinx.coroutines.JobSupport – 0.00% (0/423 lines covered)

✅ Native Android screenshot tests passed.

Native Android coverage

  • 📊 Line coverage: 14.22% (8655/60877 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 11.51% (42633/370328), branch 5.06% (1763/34839), complexity 6.05% (2021/33383), method 10.51% (1639/15601), class 17.13% (377/2201)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6327 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.ClassReader – 0.00% (0/1519 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1148 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.MethodWriter – 0.00% (0/923 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/730 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/623 lines covered)
      • org.jacoco.agent.rt.internal_b6258fc.asm.org.jacoco.agent.rt.internal_b6258fc.asm.Frame – 0.00% (0/564 lines covered)
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysJvmKt – 0.00% (0/495 lines covered)
      • kotlinx.coroutines.kotlinx.coroutines.JobSupport – 0.00% (0/423 lines covered)

Benchmark Results

Detailed Performance Metrics

Metric Duration
SIMD kernel backend scalar fallback (no native SIMD)
SIMD int-add (64K x300) java 177ms / native 94ms = 1.8x speedup
SIMD float-mul (64K x300) java 165ms / native 135ms = 1.2x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path gated to scalar (CPU autovectorizes scalar; explicit SIMD not beneficial here)
Base64 CN1 encode 243.000 ms
Base64 CN1 decode 313.000 ms
Base64 native encode 983.000 ms
Base64 encode ratio (CN1/native) 0.247x (75.3% faster)
Base64 native decode 871.000 ms
Base64 decode ratio (CN1/native) 0.359x (64.1% faster)
Image encode benchmark status skipped (SIMD unsupported)

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

✅ Continuous Quality Report

Test & Coverage

Static Analysis

  • SpotBugs [HTML preview] [Download]
    • ByteCodeTranslator: 2 findings (Normal: 2)
    • android: 0 findings (no issues)
    • codenameone-maven-plugin: 0 findings (no issues)
    • core-unittests: 0 findings (no issues)
    • ios: 0 findings (no issues)
  • PMD: 0 findings (no issues) [Report archive]
  • Checkstyle: 0 findings (no issues) [Report archive]

Generated automatically by the PR CI workflow.

@shai-almog

shai-almog commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 125 screenshots: 125 matched.
Native Windows port (x64 / Intel-AMD): full hellocodenameone screenshot suite rendered offscreen with Direct2D/DirectWrite, plus the real benchmarks (base64 native/CN1/SIMD, image createMask/applyMask/modifyAlpha/PNG/JPEG, SSE2 SIMD kernels). Compared against the in-repo baseline in scripts/windows/screenshots.

Benchmark Results

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 71ms / native 4ms = 17.7x speedup
SIMD float-mul (64K x300) java 70ms / native 4ms = 17.5x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 native bridge unavailable (CN1 + SIMD + image benchmarks only)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path gated to scalar (CPU autovectorizes scalar; explicit SIMD not beneficial here)
Base64 CN1 encode 279.000 ms
Base64 CN1 decode 175.000 ms
Base64 SIMD encode 132.000 ms
Base64 encode ratio (SIMD/CN1) 0.473x (52.7% faster)
Base64 SIMD decode 133.000 ms
Base64 decode ratio (SIMD/CN1) 0.760x (24.0% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 35.000 ms
Image createMask (SIMD on) 13.000 ms
Image createMask ratio (SIMD on/off) 0.371x (62.9% faster)
Image applyMask (SIMD off) 56.000 ms
Image applyMask (SIMD on) 34.000 ms
Image applyMask ratio (SIMD on/off) 0.607x (39.3% faster)
Image modifyAlpha (SIMD off) 60.000 ms
Image modifyAlpha (SIMD on) 24.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.400x (60.0% faster)
Image modifyAlpha removeColor (SIMD off) 64.000 ms
Image modifyAlpha removeColor (SIMD on) 26.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.406x (59.4% faster)

@shai-almog

shai-almog commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 121 screenshots: 121 matched.
✅ JavaScript-port screenshot tests passed.

@shai-almog

shai-almog commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 125 screenshots: 125 matched.
Native Windows port, REAL shipping pipeline: the hellocodenameone screenshot suite rendered by a binary CROSS-COMPILED on Linux (clang-cl + xwin, WebView2 linked) and RUN on a Windows x64 runner. Compared against the in-repo baseline in scripts/windows/screenshots.

Benchmark Results

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 76ms / native 6ms = 12.6x speedup
SIMD float-mul (64K x300) java 66ms / native 3ms = 22.0x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 native bridge unavailable (CN1 + SIMD + image benchmarks only)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path gated to scalar (CPU autovectorizes scalar; explicit SIMD not beneficial here)
Base64 CN1 encode 296.000 ms
Base64 CN1 decode 184.000 ms
Base64 SIMD encode 165.000 ms
Base64 encode ratio (SIMD/CN1) 0.557x (44.3% faster)
Base64 SIMD decode 128.000 ms
Base64 decode ratio (SIMD/CN1) 0.696x (30.4% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 36.000 ms
Image createMask (SIMD on) 15.000 ms
Image createMask ratio (SIMD on/off) 0.417x (58.3% faster)
Image applyMask (SIMD off) 63.000 ms
Image applyMask (SIMD on) 31.000 ms
Image applyMask ratio (SIMD on/off) 0.492x (50.8% faster)
Image modifyAlpha (SIMD off) 60.000 ms
Image modifyAlpha (SIMD on) 27.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.450x (55.0% faster)
Image modifyAlpha removeColor (SIMD off) 61.000 ms
Image modifyAlpha removeColor (SIMD on) 30.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.492x (50.8% faster)

@shai-almog

shai-almog commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 127 screenshots: 127 matched.
Native Linux port (x64), GTK3/Cairo/Pango, ParparVM bytecode-to-C (no JVM): the hellocodenameone screenshot suite rendered by a native ELF built + run on the GitHub x64 runner. Baseline: scripts/linux/screenshots.

@shai-almog

shai-almog commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 127 screenshots: 127 matched.
Native Linux port (arm64), GTK3/Cairo/Pango, ParparVM bytecode-to-C (no JVM): the hellocodenameone screenshot suite rendered by a native ELF built + run on the GitHub arm64 runner. Baseline: scripts/linux/screenshots-arm.

@shai-almog

shai-almog commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 128 screenshots: 128 matched.
✅ Native Mac screenshot tests passed.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 186 seconds

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 55ms / native 3ms = 18.3x speedup
SIMD float-mul (64K x300) java 56ms / native 2ms = 28.0x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path active (NEON-accelerated)
Base64 CN1 encode 260.000 ms
Base64 CN1 decode 194.000 ms
Base64 native encode 756.000 ms
Base64 encode ratio (CN1/native) 0.344x (65.6% faster)
Base64 native decode 438.000 ms
Base64 decode ratio (CN1/native) 0.443x (55.7% faster)
Base64 SIMD encode 51.000 ms
Base64 encode ratio (SIMD/CN1) 0.196x (80.4% faster)
Base64 SIMD decode 43.000 ms
Base64 decode ratio (SIMD/CN1) 0.222x (77.8% faster)
Base64 encode ratio (SIMD/native) 0.067x (93.3% faster)
Base64 decode ratio (SIMD/native) 0.098x (90.2% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 17.000 ms
Image createMask (SIMD on) 3.000 ms
Image createMask ratio (SIMD on/off) 0.176x (82.4% faster)
Image applyMask (SIMD off) 74.000 ms
Image applyMask (SIMD on) 51.000 ms
Image applyMask ratio (SIMD on/off) 0.689x (31.1% faster)
Image modifyAlpha (SIMD off) 89.000 ms
Image modifyAlpha (SIMD on) 58.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.652x (34.8% faster)
Image modifyAlpha removeColor (SIMD off) 76.000 ms
Image modifyAlpha removeColor (SIMD on) 53.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.697x (30.3% faster)

@shai-almog

shai-almog commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 125 screenshots: 125 matched.
Native Windows port (arm64 / Apple Silicon - Arm): full hellocodenameone screenshot suite rendered offscreen with Direct2D/DirectWrite, plus the real benchmarks (base64 native/CN1/SIMD, image createMask/applyMask/modifyAlpha/PNG/JPEG, NEON SIMD kernels). Compared against the in-repo baseline in scripts/windows/screenshots.

Benchmark Results

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 62ms / native 3ms = 20.6x speedup
SIMD float-mul (64K x300) java 61ms / native 3ms = 20.3x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 native bridge unavailable (CN1 + SIMD + image benchmarks only)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path gated to scalar (CPU autovectorizes scalar; explicit SIMD not beneficial here)
Base64 CN1 encode 606.000 ms
Base64 CN1 decode 241.000 ms
Base64 SIMD encode 103.000 ms
Base64 encode ratio (SIMD/CN1) 0.170x (83.0% faster)
Base64 SIMD decode 138.000 ms
Base64 decode ratio (SIMD/CN1) 0.573x (42.7% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 23.000 ms
Image createMask (SIMD on) 7.000 ms
Image createMask ratio (SIMD on/off) 0.304x (69.6% faster)
Image applyMask (SIMD off) 39.000 ms
Image applyMask (SIMD on) 14.000 ms
Image applyMask ratio (SIMD on/off) 0.359x (64.1% faster)
Image modifyAlpha (SIMD off) 38.000 ms
Image modifyAlpha (SIMD on) 12.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.316x (68.4% faster)
Image modifyAlpha removeColor (SIMD off) 41.000 ms
Image modifyAlpha removeColor (SIMD on) 12.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.293x (70.7% faster)

@shai-almog shai-almog force-pushed the playground-local-javascript-target branch from 3e84cf7 to 0684ad9 Compare June 16, 2026 12:22
@shai-almog

shai-almog commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 124 screenshots: 124 matched.
✅ Native iOS screenshot tests passed.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 261 seconds

Build and Run Timing

Metric Duration
Simulator Boot 90000 ms
Simulator Boot (Run) 1000 ms
App Install 14000 ms
App Launch 9000 ms
Test Execution 337000 ms

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 203ms / native 3ms = 67.6x speedup
SIMD float-mul (64K x300) java 93ms / native 4ms = 23.2x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path active (NEON-accelerated)
Base64 CN1 encode 596.000 ms
Base64 CN1 decode 407.000 ms
Base64 native encode 1002.000 ms
Base64 encode ratio (CN1/native) 0.595x (40.5% faster)
Base64 native decode 534.000 ms
Base64 decode ratio (CN1/native) 0.762x (23.8% faster)
Base64 SIMD encode 130.000 ms
Base64 encode ratio (SIMD/CN1) 0.218x (78.2% faster)
Base64 SIMD decode 74.000 ms
Base64 decode ratio (SIMD/CN1) 0.182x (81.8% faster)
Base64 encode ratio (SIMD/native) 0.130x (87.0% faster)
Base64 decode ratio (SIMD/native) 0.139x (86.1% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 29.000 ms
Image createMask (SIMD on) 3.000 ms
Image createMask ratio (SIMD on/off) 0.103x (89.7% faster)
Image applyMask (SIMD off) 85.000 ms
Image applyMask (SIMD on) 61.000 ms
Image applyMask ratio (SIMD on/off) 0.718x (28.2% faster)
Image modifyAlpha (SIMD off) 78.000 ms
Image modifyAlpha (SIMD on) 59.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.756x (24.4% faster)
Image modifyAlpha removeColor (SIMD off) 115.000 ms
Image modifyAlpha removeColor (SIMD on) 98.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.852x (14.8% faster)

@shai-almog

shai-almog commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 128 screenshots: 128 matched.
✅ Native iOS Metal screenshot tests passed.

Benchmark Results

  • VM Translation Time: 0 seconds
  • Compilation Time: 299 seconds

Build and Run Timing

Metric Duration
Simulator Boot 65000 ms
Simulator Boot (Run) 1000 ms
App Install 16000 ms
App Launch 37000 ms
Test Execution 279000 ms

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 142ms / native 6ms = 23.6x speedup
SIMD float-mul (64K x300) java 82ms / native 3ms = 27.3x speedup
SIMD kernel correctness PASS (native result == scalar reference)
Base64 payload size 8192 bytes
Base64 benchmark iterations 6000
Base64 SIMD byte path active (NEON-accelerated)
Base64 CN1 encode 548.000 ms
Base64 CN1 decode 350.000 ms
Base64 native encode 868.000 ms
Base64 encode ratio (CN1/native) 0.631x (36.9% faster)
Base64 native decode 353.000 ms
Base64 decode ratio (CN1/native) 0.992x (0.8% faster)
Base64 SIMD encode 82.000 ms
Base64 encode ratio (SIMD/CN1) 0.150x (85.0% faster)
Base64 SIMD decode 53.000 ms
Base64 decode ratio (SIMD/CN1) 0.151x (84.9% faster)
Base64 encode ratio (SIMD/native) 0.094x (90.6% faster)
Base64 decode ratio (SIMD/native) 0.150x (85.0% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 31.000 ms
Image createMask (SIMD on) 2.000 ms
Image createMask ratio (SIMD on/off) 0.065x (93.5% faster)
Image applyMask (SIMD off) 97.000 ms
Image applyMask (SIMD on) 74.000 ms
Image applyMask ratio (SIMD on/off) 0.763x (23.7% faster)
Image modifyAlpha (SIMD off) 174.000 ms
Image modifyAlpha (SIMD on) 148.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.851x (14.9% faster)
Image modifyAlpha removeColor (SIMD off) 174.000 ms
Image modifyAlpha removeColor (SIMD on) 192.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 1.103x (10.3% slower)

Migrate the Playground off the pinned old release + cloud `javascript`
build target onto the local ParparVM `local-javascript` target, the same
path the initializr uses.

Playground changes (scripts/cn1playground/):
- javascript/pom.xml: codename1.defaultBuildTarget javascript -> local-javascript
- build.sh / build.bat: javascript target -> local-javascript
- pom.xml: drop the one-release `cn1.registry.version` (7.0.234) pin. The
  bean-shell access registry now tracks the current API directly. A new
  cn1.accessRegistry.useLocalSources property (true under the
  cn1-local-workspace profile) makes the registry generate from the repo's
  own CN1 sources, since 8.0-SNAPSHOT has no source jars on Maven Central.
- common/pom.xml: pass that property through to the registry generator as
  CN1_ACCESS_USE_LOCAL_SOURCES.
- tools/GenerateCN1AccessRegistry.java: remove the security.* / nfc.* class
  exclusions (they worked around the legacy cloud TeaVM backend lagging the
  release channel; the local target builds the current sources). Keep the
  structural exclusions (Accessor/IOAccessor internals, and Simd whose
  alloca scratch arrays cannot escape the reflection bridge under the
  bytecode-compliance check). Also exclude the com.codename1.testing.junit
  package: it is the JavaSE-port JUnit 5 test-extension API (not a runtime
  API a playground script can use, and not on the common compile classpath),
  which un-pinning the registry version newly pulled in and broke the build.
  Fix array-component varargs codegen: emit `new byte[len][]`, not the
  malformed `new byte[][len]`, for `T[]...`.
- tools/generate-cn1-access-registry.sh: drop the registry-version logic.
- README / tools/README: document the new path.

JS-port translator fixes (vm/ByteCodeTranslator/) needed for the Playground's
full-API reflective registry:
- JavascriptMethodGenerator: support array class literals (`ldc [B`,
  `String[].class`, ...) via jvm.getArrayClass(component, dims).classObject.
  The registry emits these for every array-typed parameter; the JS backend
  previously only handled object class literals and threw
  "Unsupported ldc constant".
- Parser: rethrow Errors (e.g. OutOfMemoryError) from writeOutput instead of
  swallowing them, which had let the translator exit 0 with a truncated dist.

Plugin / build wiring:
- JavaScriptBuilder: let a -Xmx in CN1_TRANSLATOR_OPTS override the default
  512m translator heap.
- The Playground keeps nearly the whole API reachable, so the JS RTA
  tree-shaking pass cannot prune much yet runs 100min+. build.sh/build.bat and
  the website build_playground_for_site set CN1_TRANSLATOR_OPTS to disable RTA
  (-Dparparvm.js.rta.off) and raise the heap (-Xmx6g); the website extraction
  flattens the single wrapper dir so index.html lands at the served root.

Verified locally: the local-javascript build produces a complete bundle
(index.html, worker.js, translated_app + chunks, parparvm_runtime.js,
browser_bridge.js, js/ assets, themes, editor html.tar, native-interface
stub) that loads in headless Chromium with no fatal JS/VM errors, and the
playground language smoke tests pass (registry regenerated in release mode,
325/325 syntax, 312/312 paint, 20/20 preview).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@shai-almog shai-almog force-pushed the playground-local-javascript-target branch from 0684ad9 to ebbb018 Compare June 16, 2026 13:16
@github-actions

Copy link
Copy Markdown
Contributor

Cloudflare Preview

shai-almog and others added 2 commits June 16, 2026 18:57
JavascriptBundleWriter.hoistStringConstants emits top-level
`const _q<alias>="..."` aliases for repeated string literals, but it
reset the alias counter to 0 for every chunk. The translated_app chunks
are concatenated into one worker scope via importScripts, so two chunks
each declaring e.g. `const _q0O` (with different string values) is a
`SyntaxError: redeclaration of const _q0O` that aborts worker startup.

This only triggered once a bundle was large enough to split into
multiple chunks (>20 MB) -- the Playground is the first such app; smaller
local-javascript apps (initializr, HelloCodenameOne) are single-chunk and
were unaffected.

Thread one shared alias counter through every chunk so each gets a
disjoint alias range -- exactly the naming a single un-split chunk would
produce. Verified: node --check on the concatenated 57 MB Playground
bundle parses cleanly (0 cross-chunk duplicate const names).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The ParparVM localforage shim (synchronous-callback, localStorage-backed)
bailed out if a real `window.localforage` was already present:

    if (window.localforage && typeof window.localforage.setItem === "function") return;

But fontmetrics.js bundles a real localForage 1.7.3 and globally exposes
it, and it loads BEFORE the shim. So the shim bailed, CN1 Storage hit the
real localForage's Promise-based callback path, and the worker-bridged
callback failed with `TypeError: b is not a function` (localForage's
executeCallback invoking a non-function) right after the app's main()
ran -- the Playground is the first local-javascript app to touch Storage
on boot.

The worker can't pump the async microtask loop the real localForage
relies on, so the synchronous shim MUST own window.localforage. Install
unconditionally, overriding any real localForage; only skip re-installing
over ourselves (idempotent via a __cn1ShimInstalled marker). fontmetrics
keeps its own bundled instance (referenced through its module closure) for
font-metric caching.

Verified: the Playground bundle boots in headless Chromium with no
`b is not a function` (0 fatal JS errors) where it previously threw on
every Storage access.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant