decomp: reconstruct CHANSVm opcode-local error paths #967

Merged
coah80 merged 1 commits from agent/bittle/chansvm-opcode-flow into main 2026-10-02 21:59:59 +00:00
coah80 commented 2026-10-02 21:58:41 +00:00 (Migrated from github.com)

Focused structural reconstruction

Follow-up to #963, preserving its semantic fix. Restores three target direct-error returns instead of shared result/break tails, and models DELETE_INDIRECT with a typed accumulator/index and scoped result merge. No new behavioral defect or exact-function gain is claimed. No headers, linking flags, metadata, data or assembly changes.

Parent independently checked target Step offsets +0x410/+0x414, +0xD90/+0xD94 and +0xEFC/+0xF00 returning directly to the epilogue. DELETE_INDIRECT +0xF80..+0xFB4 now has identical instructions and operands, including the index load at +0xF94.

Fresh verification on b2089fbd

  • Step decompiled/fuzzy 96.673584% → 96.913800%; 1253 instructions unchanged; differing positions 297 → 285.
  • Unit decompiled/fuzzy 99.383840% → 99.406320%.
  • Exact 221/233, code 37608/53564 and data 6904/6904 unchanged; no regressions.
  • All 1027 allocated objects audited: only CHANSVm text bytes change; its size and all relocations unchanged. All data and every other object unchanged.
  • Pool 125/125 identical. Literal audit: 233 functions, 40 arguments, zero candidates/errors/skips.
  • Parent reran four source-extracted DELETE_INDIRECT behavior cases and the previous six string-load cases; these are stubbed host tests, not Wii execution.
  • Full 43U all_source/progress/report/DOL passes SHA1 26116613f624061ba99c8d1a299aaa6efa85670d.
  • Tests 8/36/27/8, worktree checks and diff check pass.

Remote tree fa4359e908 equals tested tree. Remaining Step and other VM matching work stays open. Left for review; no merge performed.

Note

Return opcode-local errors directly in CHANSVmStep and rework DELETE_INDIRECT

Reconstructs error handling in the CHANSVmStep interpreter in CHANSVm.c. Failed binary-operand validation now returns CHANS_VM_ERR_RESULT_TYPE immediately, and invalid GET_PROPERTY_NAME and jump destinations return CHANS_VM_ERR_CODE_RANGE immediately, instead of deferring to the common opcode flow. DELETE_INDIRECT is reworked to use a typed accumulator pointer, a local deletion-status variable, and the named value.data.len field for the index. Adds a reconstruction log covering retained changes, rejected experiments, build validation, and host-side DELETE_INDIRECT and LOAD_STRING_CONST tests in the attempt log. Risk: opcode-local returns change when CHANSVmStep exits for these three error paths — check the binary-operand, GET_PROPERTY_NAME, and jump-destination paths if the common opcode flow relied on the deferred statuses.

Macroscope summarized 6559d0b.

## Focused structural reconstruction Follow-up to #963, preserving its semantic fix. Restores three target direct-error returns instead of shared result/break tails, and models DELETE_INDIRECT with a typed accumulator/index and scoped result merge. No new behavioral defect or exact-function gain is claimed. No headers, linking flags, metadata, data or assembly changes. Parent independently checked target Step offsets +0x410/+0x414, +0xD90/+0xD94 and +0xEFC/+0xF00 returning directly to the epilogue. DELETE_INDIRECT +0xF80..+0xFB4 now has identical instructions and operands, including the index load at +0xF94. ## Fresh verification on b2089fbd - Step decompiled/fuzzy 96.673584% → 96.913800%; 1253 instructions unchanged; differing positions 297 → 285. - Unit decompiled/fuzzy 99.383840% → 99.406320%. - Exact 221/233, code 37608/53564 and data 6904/6904 unchanged; no regressions. - All 1027 allocated objects audited: only CHANSVm text bytes change; its size and all relocations unchanged. All data and every other object unchanged. - Pool 125/125 identical. Literal audit: 233 functions, 40 arguments, zero candidates/errors/skips. - Parent reran four source-extracted DELETE_INDIRECT behavior cases and the previous six string-load cases; these are stubbed host tests, not Wii execution. - Full 43U all_source/progress/report/DOL passes SHA1 26116613f624061ba99c8d1a299aaa6efa85670d. - Tests 8/36/27/8, worktree checks and diff check pass. Remote tree fa4359e908d261ede4f9eeab497b8330fda90b25 equals tested tree. Remaining Step and other VM matching work stays open. Left for review; no merge performed. <!-- Macroscope's pull request summary starts here --> <!-- Macroscope will only edit the content between these invisible markers, and the markers themselves will not be visible in the GitHub rendered markdown. --> <!-- If you delete either of the start / end markers from your PR's description, Macroscope will append its summary at the bottom of the description. --> > [!NOTE] > ### Return opcode-local errors directly in CHANSVmStep and rework DELETE_INDIRECT > Reconstructs error handling in the `CHANSVmStep` interpreter in [CHANSVm.c](https://github.com/coah80/wii-ipl/pull/967/files#diff-fcd94241dcc82f12e50e6a224211f94b32d8c83c08ab0880c20261cea99b4f75). Failed binary-operand validation now returns `CHANS_VM_ERR_RESULT_TYPE` immediately, and invalid `GET_PROPERTY_NAME` and jump destinations return `CHANS_VM_ERR_CODE_RANGE` immediately, instead of deferring to the common opcode flow. `DELETE_INDIRECT` is reworked to use a typed accumulator pointer, a local deletion-status variable, and the named `value.data.len` field for the index. Adds a reconstruction log covering retained changes, rejected experiments, build validation, and host-side `DELETE_INDIRECT` and `LOAD_STRING_CONST` tests in the [attempt log](https://github.com/coah80/wii-ipl/pull/967/files#diff-c83e36d7429d0b4fb259bb55e4cfa97c4dbeba8c8536f5ee2ba846175384738a). Risk: opcode-local returns change when `CHANSVmStep` exits for these three error paths — check the binary-operand, `GET_PROPERTY_NAME`, and jump-destination paths if the common opcode flow relied on the deferred statuses. > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized 6559d0b.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here -->
coah80 commented 2026-10-02 21:59:57 +00:00 (Migrated from github.com)

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.
Sign in to join this conversation.