Skip to content

Gate against relying on ClassCastException, which ParparVM does not throw (#5531) - #5532

Merged
shai-almog merged 2 commits into
masterfrom
fix/5531-cast-semantics-gate
Aug 7, 2026
Merged

Gate against relying on ClassCastException, which ParparVM does not throw (#5531)#5532
shai-almog merged 2 commits into
masterfrom
fix/5531-cast-semantics-gate

Conversation

@shai-almog

Copy link
Copy Markdown
Collaborator

Refs #5531.

What actually happens

CHECKCAST is unchecked in ParparVM. BC_CHECKCAST expands to nothing
(cn1_globals.h:351, // todo map instanceof and throw typecast exception) and
BytecodeMethod.optimize() deletes the instruction outright, so a failed cast hands
the wrong pointer to the next instruction instead of throwing.

The reporter's optDouble is

try { return Double.parseDouble((String) opt(key)); } catch (Exception e) { return def; }

with a Double under the key. On the simulator and Android the cast throws and the
catch returns the fallback. On iOS the Double reaches StringToReal.parseDouble,
which calls s.trim() -- String is final, so ParparVM devirtualizes and inlines raw
field access -- and the process dies at cn1_intrinsics.h:90 dereferencing
s->java_lang_String_value read out of a Double. No Java catch can see it.

Confirmed locally with vm/benchmarks/translate-and-build.sh (SIGSEGV, backtrace
above) and fixed-up code returns the fallback correctly.

Why not make CHECKCAST throw

That would put a class check on every cast in every app. It measures inside benchmark
noise, but it is a cost every user pays to compensate for code that should not have
been written that way. The rule is instead that our own code must not depend on the
exception -- test the type and branch:

if (o instanceof Number) { return ((Number) o).doubleValue(); }

The reporter's optDouble lives in ca.weblite.codename1.json (CN1JSON), not in this
repo; the fix belongs upstream there.

What this PR adds

CastSemanticsVerifier (vm/ByteCodeTranslator) reports a CHECKCAST inside a
try whose handler catches ClassCastException or a supertype -- the handler that
would absorb the failure everywhere except iOS.

Two things it deliberately does not report, both covered by tests:

  • A catch (ClassCastException) with no cast under it. ParparVM delivers an
    explicitly thrown ClassCastException perfectly well; only the implicit one from a
    failed CHECKCAST is missing. java.util.AbstractSet.equals is exactly this -- its
    handler is there for a foreign containsAll, and flagging it would send people
    editing correct code.
  • A cast already guarded by instanceof. javac still emits the CHECKCAST, so
    without this the gate would reject its own remedy. A small local-slot analysis
    recognises ALOAD n; INSTANCEOF T; IFEQ end, drops the proof on reassignment, and
    stops at the branch target. Anything it does not recognise stays reportable, so being
    incomplete costs noise rather than correctness.

scripts/check-cast-semantics.sh runs it over JavaAPI, core, android and ios, held
against scripts/cast-semantics-baseline.txt -- a ratchet of 187 pre-existing
sites, not an allow-list. Most are casts that merely sit inside a broad defensive
catch (Throwable) and cannot actually fail; new code cannot add entries.

Wired into pr.yml (Java 8 leg), where core/android/ios are already compiled for
SpotBugs.

Two genuine cases fixed (both left the baseline as a result):

  • Purchase.getReceipts read a storage entry of any type as List<Receipt> and
    relied on the cast failing into catch (Exception) to substitute an empty list.
  • PropertyIndex.newInstance returned whatever getClass().newInstance() produced as
    a PropertyBusinessObject, relying on the cast to fail into catch (Exception).

PrettyPrinter.valueToString had a vestigial try/catch around an already-guarded
cast; left alone because the file carries a pre-existing Sun BSD header that touching
would pull into the copyright gate, and the instanceof recognition already exempts it.

Verification

  • CastSemanticsVerifierTest -- 10 tests, all pinning one behaviour each
  • Gate fails on a synthetic new offender (exit 1) and passes on the tree as committed
  • SpotBugs on ByteCodeTranslator: 0 findings
  • Copyright header gate: 4 files checked, all pass
  • ParparVM translation is unchanged by this PR -- no VM behaviour is modified

Follow-up

The 187 baselined sites are worth burning down; IOSImplementation,
CommonTransitions.paint and UIBuilder.createContainer are the densest clusters.

🤖 Generated with Claude Code

ParparVM's CHECKCAST is unchecked: BC_CHECKCAST expands to nothing and
BytecodeMethod.optimize() drops the instruction, so a failed cast hands the
wrong pointer to the next instruction rather than throwing. Code written to
catch the failure therefore behaves differently on iOS than on the simulator
and Android -- in the reported case StringToReal.parseDouble ran with a Double
as its String argument and died at cn1_intrinsics.h:90 reading
java_lang_String_value out of it, uncatchable from Java.

Making CHECKCAST throw would put a class check on every cast in every app, so
the rule is instead that our own code must not depend on the exception. Adds
CastSemanticsVerifier, which reports a CHECKCAST inside a try whose handler
catches ClassCastException or a supertype, and wires it into the PR CI Java 8
leg over JavaAPI, core, android and ios.

The rule is about the cast, not the handler: a catch(ClassCastException) with
no cast under it is fine, because an explicitly thrown ClassCastException
still propagates normally (java.util.AbstractSet.equals is that case). Casts
already guarded by an instanceof are recognised and never reported, so the
remedy the gate asks for satisfies it.

Findings are held against scripts/cast-semantics-baseline.txt -- a ratchet of
187 pre-existing sites, most of them casts that merely sit inside a broad
defensive guard. New code cannot add entries.

Fixes two genuine cases found this way:
- Purchase.getReceipts read a storage entry of any type as a List<Receipt>
- PropertyIndex.newInstance returned any newInstance() as a business object

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 68f440f683

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +133 to +134
public String key() {
return className + "#" + methodName + methodDesc;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Baseline individual cast sites, not entire methods

When a method already present in cast-semantics-baseline.txt gains another unguarded CHECKCAST, this key remains unchanged and baseline.contains(violation.key()) suppresses the new violation along with the old one. Because the baseline already covers 133 methods—including several large methods with multiple existing casts—new code in precisely these debt-heavy areas can reintroduce the iOS crash while the gate passes; the key or comparison needs to preserve individual sites or per-method violation counts.

Useful? React with 👍 / 👎.

Comment thread .github/workflows/pr.yml Outdated
Comment on lines +354 to +358
- name: Check cast semantics
if: ${{ matrix.java-version == 8 }}
run: |
mvn -B -q -f vm/pom.xml -pl JavaAPI -am package -DskipTests
scripts/check-cast-semantics.sh

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Trigger this check when its enforcement files change

In the inspected .github/workflows/pr.yml, both the pull_request and push triggers ignore scripts/**, while parparvm-tests.yml only watches vm/**; consequently, a change limited to the newly added checker or its baseline runs neither this step nor the verifier tests. This allows enforcement logic or pre-added baseline exemptions to merge without validation, so these two script paths need to trigger an applicable workflow.

Useful? React with 👍 / 👎.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

✅ ByteCodeTranslator Quality Report

Test & Coverage

  • Tests: 430 total, 0 failed, 14 skipped

Benchmark Results

  • Execution Time: 24296 ms

  • Hotspots (Top 20 sampled methods):

    • 22.05% com.codename1.tools.translator.Parser.addToConstantPool (458 samples)
    • 8.86% java.util.ArrayList.indexOf (184 samples)
    • 4.91% com.codename1.tools.translator.ByteCodeClass.hasDeclaredMethod (102 samples)
    • 3.66% java.lang.StringBuilder.append (76 samples)
    • 3.18% com.codename1.tools.translator.Parser.cn1EnsureSubclassIndex (66 samples)
    • 2.70% com.codename1.tools.translator.BytecodeMethod.equals (56 samples)
    • 2.65% com.codename1.tools.translator.ByteCodeClass.fillVirtualMethodTable (55 samples)
    • 2.02% org.objectweb.asm.tree.analysis.Analyzer.analyze (42 samples)
    • 1.78% java.lang.Object.hashCode (37 samples)
    • 1.73% org.objectweb.asm.tree.analysis.Analyzer.findSubroutine (36 samples)
    • 1.69% java.util.HashMap.hash (35 samples)
    • 1.59% com.codename1.tools.translator.Parser.classIndex (33 samples)
    • 1.44% com.codename1.tools.translator.bytecodes.Invoke.resolveDirectTarget (30 samples)
    • 1.16% com.codename1.tools.translator.BytecodeMethod.optimize (24 samples)
    • 1.11% com.codename1.tools.translator.BytecodeMethod.appendMethodSignatureSuffixFromDesc (23 samples)
    • 1.01% java.lang.String.equals (21 samples)
    • 1.01% sun.nio.fs.UnixNativeDispatcher.open0 (21 samples)
    • 0.96% java.io.UnixFileSystem.getBooleanAttributes0 (20 samples)
    • 0.91% com.codename1.tools.translator.Parser.resolveDupForms (19 samples)
    • 0.87% java.util.TreeMap.getEntry (18 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.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

✅ Continuous Quality Report

Test & Coverage

Static Analysis

  • SpotBugs [Report archive]
    • ByteCodeTranslator: 0 findings (no issues)
    • 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.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Cloudflare Preview

The baseline shipped in the previous commit was generated against a stale
maven/android/target/classes, so three AndroidImplementation methods that exist
in the source were missing from it and PR CI failed on code that was not new.

Rebuilds android + ios with -Pcompile-android and regenerates: nothing is
removed, the four Android findings are added.

Adds --require-all, used by CI, so a module that is not built fails the gate
instead of silently shrinking its coverage -- which is what let the stale build
through. Also records why maven/java-runtime (Ports/CLDC11) is deliberately
out of scope: it runs on a real JVM, where a failed cast does throw.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@shai-almog

shai-almog commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 151 screenshots: 151 matched.

Native Android coverage

  • 📊 Line coverage: 8.04% (7799/97060 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 8.04% (41436/515259), branch 2.86% (1390/48675), complexity 3.18% (1663/52236), method 4.90% (1355/27630), class 10.00% (368/3680)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6367 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.ClassReader – 0.00% (0/1524 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1187 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.MethodWriter – 0.00% (0/922 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/736 lines covered)
      • com.google.common.cache.com.google.common.cache.LocalCache$Segment – 0.00% (0/726 lines covered)
      • okio.okio.Buffer – 0.00% (0/687 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/625 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.Frame – 0.00% (0/570 lines covered)

✅ Native Android screenshot tests passed.

Native Android coverage

  • 📊 Line coverage: 8.04% (7799/97060 lines covered) [HTML preview] (artifact android-coverage-report, jacocoAndroidReport/html/index.html)
    • Other counters: instruction 8.04% (41436/515259), branch 2.86% (1390/48675), complexity 3.18% (1663/52236), method 4.90% (1355/27630), class 10.00% (368/3680)
    • Lowest covered classes
      • kotlin.collections.kotlin.collections.ArraysKt___ArraysKt – 0.00% (0/6367 lines covered)
      • kotlin.collections.unsigned.kotlin.collections.unsigned.UArraysKt___UArraysKt – 0.00% (0/2384 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.ClassReader – 0.00% (0/1524 lines covered)
      • kotlin.collections.kotlin.collections.CollectionsKt___CollectionsKt – 0.00% (0/1187 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.MethodWriter – 0.00% (0/922 lines covered)
      • kotlin.sequences.kotlin.sequences.SequencesKt___SequencesKt – 0.00% (0/736 lines covered)
      • com.google.common.cache.com.google.common.cache.LocalCache$Segment – 0.00% (0/726 lines covered)
      • okio.okio.Buffer – 0.00% (0/687 lines covered)
      • kotlin.text.kotlin.text.StringsKt___StringsKt – 0.00% (0/625 lines covered)
      • org.jacoco.agent.rt.internal_0e20598.asm.org.jacoco.agent.rt.internal_0e20598.asm.Frame – 0.00% (0/570 lines covered)

Benchmark Results

Detailed Performance Metrics

Metric Duration
SIMD kernel backend scalar fallback (no native SIMD)
SIMD int-add (64K x300) java 279ms / native 194ms = 1.4x speedup
SIMD float-mul (64K x300) java 238ms / native 122ms = 1.9x 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 89.000 ms
Base64 CN1 decode 87.000 ms
Base64 native encode 323.000 ms
Base64 encode ratio (CN1/native) 0.276x (72.4% faster)
Base64 native decode 272.000 ms
Base64 decode ratio (CN1/native) 0.320x (68.0% faster)
Image encode benchmark status skipped (SIMD unsupported)

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6e534cb3cb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +241 to +243
if (opcode == Opcodes.ASTORE) {
dropSlot(((org.objectweb.asm.tree.VarInsnNode) insn).var);
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Invalidate guards across loop back-edges

When a guarded local is reassigned after a cast and execution loops back—such as if (o instanceof String) { while (...) { use((String) o); o = other; } }—the second iteration's cast is no longer safe. This linear scan exempts the CHECKCAST before it later encounters the ASTORE, then never revisits the cast after the backward jump, so this pattern passes the gate even though a failed cast can still reach iOS and use the wrong object. The guard analysis needs to account for back-edge control flow or conservatively reject proofs spanning such loops.

Useful? React with 👍 / 👎.

@shai-almog

shai-almog commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 146 screenshots: 146 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 46ms / native 3ms = 15.3x speedup
SIMD float-mul (64K x300) java 45ms / native 3ms = 15.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 145.000 ms
Base64 CN1 decode 99.000 ms
Base64 SIMD encode 78.000 ms
Base64 encode ratio (SIMD/CN1) 0.538x (46.2% faster)
Base64 SIMD decode 70.000 ms
Base64 decode ratio (SIMD/CN1) 0.707x (29.3% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 18.000 ms
Image createMask (SIMD on) 12.000 ms
Image createMask ratio (SIMD on/off) 0.667x (33.3% faster)
Image applyMask (SIMD off) 30.000 ms
Image applyMask (SIMD on) 26.000 ms
Image applyMask ratio (SIMD on/off) 0.867x (13.3% faster)
Image modifyAlpha (SIMD off) 29.000 ms
Image modifyAlpha (SIMD on) 112.000 ms
Image modifyAlpha ratio (SIMD on/off) 3.862x (286.2% slower)
Image modifyAlpha removeColor (SIMD off) 27.000 ms
Image modifyAlpha removeColor (SIMD on) 19.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.704x (29.6% faster)

@shai-almog

shai-almog commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 146 screenshots: 146 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 60ms / native 4ms = 15.0x speedup
SIMD float-mul (64K x300) java 66ms / native 4ms = 16.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 191.000 ms
Base64 CN1 decode 128.000 ms
Base64 SIMD encode 100.000 ms
Base64 encode ratio (SIMD/CN1) 0.524x (47.6% faster)
Base64 SIMD decode 93.000 ms
Base64 decode ratio (SIMD/CN1) 0.727x (27.3% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 155.000 ms
Image createMask (SIMD on) 15.000 ms
Image createMask ratio (SIMD on/off) 0.097x (90.3% faster)
Image applyMask (SIMD off) 40.000 ms
Image applyMask (SIMD on) 36.000 ms
Image applyMask ratio (SIMD on/off) 0.900x (10.0% faster)
Image modifyAlpha (SIMD off) 34.000 ms
Image modifyAlpha (SIMD on) 27.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.794x (20.6% faster)
Image modifyAlpha removeColor (SIMD off) 53.000 ms
Image modifyAlpha removeColor (SIMD on) 31.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.585x (41.5% faster)

@shai-almog

shai-almog commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 147 screenshots: 147 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 Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 147 screenshots: 147 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 Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 146 screenshots: 146 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 56ms / native 4ms = 14.0x speedup
SIMD float-mul (64K x300) java 54ms / native 3ms = 18.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 246.000 ms
Base64 CN1 decode 128.000 ms
Base64 SIMD encode 65.000 ms
Base64 encode ratio (SIMD/CN1) 0.264x (73.6% faster)
Base64 SIMD decode 63.000 ms
Base64 decode ratio (SIMD/CN1) 0.492x (50.8% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 12.000 ms
Image createMask (SIMD on) 8.000 ms
Image createMask ratio (SIMD on/off) 0.667x (33.3% faster)
Image applyMask (SIMD off) 25.000 ms
Image applyMask (SIMD on) 19.000 ms
Image applyMask ratio (SIMD on/off) 0.760x (24.0% faster)
Image modifyAlpha (SIMD off) 17.000 ms
Image modifyAlpha (SIMD on) 12.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.706x (29.4% faster)
Image modifyAlpha removeColor (SIMD off) 147.000 ms
Image modifyAlpha removeColor (SIMD on) 13.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.088x (91.2% faster)

@shai-almog

shai-almog commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

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

@shai-almog

shai-almog commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

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

Benchmark Results

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

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 92ms / native 7ms = 13.1x speedup
SIMD float-mul (64K x300) java 116ms / native 6ms = 19.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 155.000 ms
Base64 CN1 decode 98.000 ms
Base64 native encode 610.000 ms
Base64 encode ratio (CN1/native) 0.254x (74.6% faster)
Base64 native decode 504.000 ms
Base64 decode ratio (CN1/native) 0.194x (80.6% faster)
Base64 SIMD encode 57.000 ms
Base64 encode ratio (SIMD/CN1) 0.368x (63.2% faster)
Base64 SIMD decode 57.000 ms
Base64 decode ratio (SIMD/CN1) 0.582x (41.8% faster)
Base64 encode ratio (SIMD/native) 0.093x (90.7% faster)
Base64 decode ratio (SIMD/native) 0.113x (88.7% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 9.000 ms
Image createMask (SIMD on) 2.000 ms
Image createMask ratio (SIMD on/off) 0.222x (77.8% faster)
Image applyMask (SIMD off) 63.000 ms
Image applyMask (SIMD on) 57.000 ms
Image applyMask ratio (SIMD on/off) 0.905x (9.5% faster)
Image modifyAlpha (SIMD off) 70.000 ms
Image modifyAlpha (SIMD on) 60.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.857x (14.3% faster)
Image modifyAlpha removeColor (SIMD off) 72.000 ms
Image modifyAlpha removeColor (SIMD on) 70.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 0.972x (2.8% faster)

@shai-almog

shai-almog commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 217 screenshots: 217 matched.
✅ Native Apple Watch (watchOS, Core Graphics) screenshot tests passed.

@shai-almog

shai-almog commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

Compared 144 screenshots: 144 matched.
✅ Native Apple TV (tvOS, Metal) screenshot tests passed.

@shai-almog
shai-almog merged commit b6ae919 into master Aug 7, 2026
54 of 55 checks passed
@shai-almog
shai-almog deleted the fix/5531-cast-semantics-gate branch August 7, 2026 06:27
@shai-almog

shai-almog commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

iOS Metal screenshot updates

Compared 149 screenshots: 148 matched, 1 updated.

  • VRStereoScene — updated screenshot. Screenshot differs (1179x2556 px, bit depth 8).

    VRStereoScene
    Preview info: JPEG preview quality 70; JPEG preview quality 70; downscaled to 825x1789.
    Full-resolution PNG saved as VRStereoScene.png in workflow artifacts.

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 67000 ms
Simulator Boot (Run) 1000 ms
App Install 14000 ms
App Launch 7000 ms
Test Execution 564000 ms

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 69ms / native 3ms = 23.0x speedup
SIMD float-mul (64K x300) java 55ms / native 3ms = 18.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 236.000 ms
Base64 CN1 decode 101.000 ms
Base64 native encode 897.000 ms
Base64 encode ratio (CN1/native) 0.263x (73.7% faster)
Base64 native decode 384.000 ms
Base64 decode ratio (CN1/native) 0.263x (73.7% faster)
Base64 SIMD encode 59.000 ms
Base64 encode ratio (SIMD/CN1) 0.250x (75.0% faster)
Base64 SIMD decode 46.000 ms
Base64 decode ratio (SIMD/CN1) 0.455x (54.5% faster)
Base64 encode ratio (SIMD/native) 0.066x (93.4% faster)
Base64 decode ratio (SIMD/native) 0.120x (88.0% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 8.000 ms
Image createMask (SIMD on) 2.000 ms
Image createMask ratio (SIMD on/off) 0.250x (75.0% faster)
Image applyMask (SIMD off) 390.000 ms
Image applyMask (SIMD on) 294.000 ms
Image applyMask ratio (SIMD on/off) 0.754x (24.6% faster)
Image modifyAlpha (SIMD off) 460.000 ms
Image modifyAlpha (SIMD on) 231.000 ms
Image modifyAlpha ratio (SIMD on/off) 0.502x (49.8% faster)
Image modifyAlpha removeColor (SIMD off) 279.000 ms
Image modifyAlpha removeColor (SIMD on) 366.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 1.312x (31.2% slower)

@shai-almog

shai-almog commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

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

Benchmark Results

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

Build and Run Timing

Metric Duration
Simulator Boot 72000 ms
Simulator Boot (Run) 1000 ms
App Install 12000 ms
App Launch 9000 ms
Test Execution 655000 ms

Detailed Performance Metrics

Metric Duration
SIMD kernel backend SSE2 (x64) / NEON (arm64) native kernels
SIMD int-add (64K x300) java 98ms / native 3ms = 32.6x speedup
SIMD float-mul (64K x300) java 59ms / native 3ms = 19.6x 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 164.000 ms
Base64 CN1 decode 115.000 ms
Base64 native encode 897.000 ms
Base64 encode ratio (CN1/native) 0.183x (81.7% faster)
Base64 native decode 317.000 ms
Base64 decode ratio (CN1/native) 0.363x (63.7% faster)
Base64 SIMD encode 49.000 ms
Base64 encode ratio (SIMD/CN1) 0.299x (70.1% faster)
Base64 SIMD decode 44.000 ms
Base64 decode ratio (SIMD/CN1) 0.383x (61.7% faster)
Base64 encode ratio (SIMD/native) 0.055x (94.5% faster)
Base64 decode ratio (SIMD/native) 0.139x (86.1% faster)
Image encode benchmark iterations 100
Image createMask (SIMD off) 120.000 ms
Image createMask (SIMD on) 17.000 ms
Image createMask ratio (SIMD on/off) 0.142x (85.8% faster)
Image applyMask (SIMD off) 290.000 ms
Image applyMask (SIMD on) 119.000 ms
Image applyMask ratio (SIMD on/off) 0.410x (59.0% faster)
Image modifyAlpha (SIMD off) 100.000 ms
Image modifyAlpha (SIMD on) 161.000 ms
Image modifyAlpha ratio (SIMD on/off) 1.610x (61.0% slower)
Image modifyAlpha removeColor (SIMD off) 225.000 ms
Image modifyAlpha removeColor (SIMD on) 263.000 ms
Image modifyAlpha removeColor ratio (SIMD on/off) 1.169x (16.9% slower)

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