Skip to content

v0.4.0 — "Handed Over"

Choose a tag to compare

@sp00nznet sp00nznet released this 20 Oct 22:28
· 65 commits to main since this release

The first outside contributions: eight pull requests from two people. Most of
it came from bringing LocoRoco (UCES00304) and Monster Hunter Portable 3rd
(NPJB40001) up on the toolkit, and it fixed the open lead in
BRINGUP.md. On the WTF Lumberjack module the object pointer
that was coming out as zero is now correct. The run makes no bad memory
accesses where it used to make 253 million, and it now stops at the thread
model rather than on corrupted state.

Emitter

  • A body that falls out into another body's label continues there, through
    that label's thunk, instead of silently returning. 579 bodies on LocoRoco
    ended this way. The label map is now built module-wide before any body is
    emitted, and the thunk declarations go in the shared header —
    @andyst-dev (#7)
  • A delay slot belongs to its branch. A slot that another body owns is no
    longer stepped over, so the fall-out is looked for at the right address. The
    branch's taken path now runs the slot too. On LocoRoco this removed ten
    negative stack leaks and two reads of the module's own code as a table —
    @andyst-dev (#10)
  • A body-ending transfer stays a tail jump. Nothing is emitted between the
    call and the return, so the compiler can reuse the frame. A guest loop
    whose back-edge crosses a body boundary used to exhaust a 16 MB host stack.
    It now runs at 9 KB —
    @andyst-dev (#11)
  • viim/vfim write the register the encoding names (bits 16..22, not the
    generic vd), and non-finite immediates are spelled NAN/INFINITY rather
    than the invalid tokens nanf/inff —
    @andyst-dev (#3)

Discovery

  • Code pointers built with lui+addiu/ori are harvested as entries.
    This catches the thread entry handed to sceKernelCreateThread, which is
    never a jal target —
    @Invictus-potens (#2)

Runtime and HLE

  • psp_syscall() and psp_unimplemented() are defined by the runtime
    (src/traps.c), so emitted C links without a host shim. They come with
    counters and a reset —
    @andyst-dev (#4)
  • The unimplemented-call message is rate-limited. One 30-second LocoRoco
    run wrote 1.37 GB of it. The message now prints a bounded number of times,
    then one line saying further calls are only counted. The zero-return ring
    counter is 64-bit, so it no longer wraps negative and reads out of bounds —
    @andyst-dev (#5)
  • Stack imbalances are grouped by site. psp_sp_hist() and
    psp_sp_call_hist() return one row per distinct (site, delta), largest
    magnitude first, so a -656 leak no longer hides behind a crowd of +16s —
    @andyst-dev (#8)
  • A hand-over is judged by its own sign. PSP_SP_LEAVE /
    psp_trace_sp_leave treat $sp below the entry as expected at a fall-out,
    and report it only when it is above. This explains BRINGUP's -64 group —
    @andyst-dev (#11)
  • sceKernelSleepThread and sceKernelSleepThreadCB are registered, with
    the same immediate-return approximation as sceKernelDelayThread —
    @Invictus-potens (#2)

Maintainer fixups during integration

All eight PRs were written against caca759, before the corpus was split into
translation units (39f1f4b). These fixups are mine, one commit each:

  • #2's harvest now only accepts targets inside the scanned range. Without that
    restriction it lifted .data as code: 1,282 extra functions and 1,125 extra
    VFPU trap sites on Lumberjack. With it, #2 adds 78 functions there and
    87–214 on each of the other five WTF modules.
  • The #7 merge resolution puts the thunk declarations in the shared header, so
    that every unit sees them, and runs the module-wide label pass in dump
    too.
  • #3, #7 and #11's tests read split units. #11's checks had been skipping
    silently on that and also failed on Windows line endings; both are fixed.
  • #10's fall-out check expects #11's PSP_SP_LEAVE, and #11's high hand-overs
    are recorded in #8's site report.

Not in this release: #9 (real threads with an explicit CPU hand-over) is
still under review. It needs a build that works on MSVC.

Full history: CHANGELOG.md. Contributors: CONTRIBUTORS.md.