Require C++26 and optimize invalidation bitfields with regression coverage - #2
Conversation
… validation Limit wrapped capture readback to the remaining blocks. Validate section headers and lengths before both returning a matching section and skipping one. Reuse the one-line ARMJIT fix authored by Ogato in melonDS-emu#2654; its base ARMJIT.cpp blob matches this fork. The savestate work is informed by melonDS-emu#2712 but also validates matching sections before returning. FIFO validation from that PR is not included. Add focused standalone C++ regression tests and a GCC/Clang sanitizer workflow. Document measurement-first performance direction without introducing a language rewrite or unmeasured SIMD requirements. Locally verified: 7/7 CTest entries with GCC 14.2 and Clang 17 ASan/UBSan. These are dependency-isolated tests, not a complete emulator build, real OpenGL execution, or game/performance validation.
Raise project-owned C++ targets and the regression suite to C++26 mode with CMake 3.30+, remove the core's C++17 override, and export cxx_std_26 to consumers. Keep vendored project settings and C11 sources unchanged. Replace bit-count builtins with standard <bit> operations and clear the lowest set bit with x & (x - 1). Fix zero-length range shifts and iterator padding bounds. Add direct-header regression tests, a language-mode guard, an optional reproducible microbenchmark, and JIT-on/off core build jobs. Update the Ubuntu CI toolchain and document the runtime compatibility change. Local verification: baseline padding test fails and UBSan reports the empty-range shift; patched tests pass with GCC 14.2 and Clang 17 ASan/UBSan. CMake C++26 probe passes, C++23 guard fails as intended. Paired same-flags microbenchmarks show a compiler/workload-dependent improvement, not emulator FPS or hardware-accuracy proof. Full repository builds and the combined regression suite are delegated to this commit's CI; no result is claimed before execution.
Full-core CI exposed the C++20+ change from std::string to std::u8string in filesystem::path::u8string. Adapt the three FATStorage call sites explicitly without disabling char8_t or converting paths through the native code page. Add a small byte-preserving conversion and direct-header tests for ASCII, Korean, Japanese, non-BMP, long, empty and embedded-NUL strings. Local GCC 14.2 and Clang 17 ASan/UBSan runs pass; the original boundary conversion fails compilation as expected. Full core and application results are checked separately in CI.
Documentation-only follow-up: update the previous C++17/CMake 3.16 instructions and describe the ten-test suite. Production code and build configurations are unchanged from 7044cf1.
Verified HEAD: 5be8f74The final documentation follow-up changes only The new HEAD's Core regressions run has passed all four jobs:
The suite contains 10 CTest entries. The inspected Clang log on the identical code commit For The documentation-only HEAD's application workflows were still rebuilding at this check; Windows/macOS/BSD are not declared passed. Do not conflate core-only compilation, complete application compilation, actual native JIT execution, real GPU output, game compatibility, or real DS/DSi agreement. The PR remains draft and unmerged. No end-to-end FPS or new hardware-accuracy result is claimed. Bitfield timings in the PR body remain isolated, same-flags microbenchmarks; the initially-empty Clang case shows no improvement. |
Scope
This branch builds on
986e8e0and includes the still-unmerged fixes from #1. New work:e8dbcc9(C++26/bitfields) and7044cf1(UTF-8 migration fix). Neithermasternor the upstream repository has been merged or modified.cxx_std_26to consumers. Unsupported compilers fail instead of silently falling back.<bit>operations and clear the lowest set bit usingx &= x - 1.filesystem::path::u8string()returningstd::u8stringsince C++20. Do not disable char8_t or use native-code-page.string()as a workaround.continue-on-error.docs/Cpp26.md.Verification at commit 7044cf1
GitHub Actions run: https://github.com/gajae1/melonDS/actions/runs/34088504727
Core builds use
BUILD_QT_SDL=OFFandENABLE_OGLRENDERER=OFF; a successful static core build is not a full frontend link or native JIT execution test. Application/package workflows are checked separately and must not be inferred successful from this table.The first C++26 full-core CI attempt correctly failed at the FATStorage char8_t boundary. Commit
7044cf1addresses that actual failure and the new run above passed both core configurations.Local source-fixture verification (not a full checkout): original bitfield valid nonempty ranges pass, padding test fails, and UBSan reports the empty-range shift. Patched bitfield and UTF-8 tests pass with GCC 14.2 and Clang 17 ASan/UBSan. A local CMake probe for language mode, bitfield and UTF-8 passes 3/3 on each compiler; the C++23 dialect guard is rejected as intended. Git blob hashes were checked for the original headers and FATStorage source. ASCII, Korean, Japanese, non-BMP, long, empty and embedded-NUL byte cases are covered; filesystem mutation and complete FAT synchronization are not.
Isolated performance result, NOT emulator FPS
Identical flags for before/after:
-std=c++2c -O3 -fwrapv, no-march=native, added AVX or LTO. Same deterministic harness, one logical CPU on an AMD EPYC 9V74 virtual host, nine randomized-order paired samples after warmup. All 72 paired checksums agree.These are bitfield-iteration microbenchmarks, not whole-emulator speedups or proof that C++26 alone is faster. Results vary by compiler, workload and host. No fixed wall-clock CI thresholds are added.
Accuracy and compatibility boundaries
No guest timing constants, ARM semantics, DMA/IRQ model, native JIT emitter, renderer interfaces, storage layout or save format were changed. Real DS/DSi comparisons, game playback and real GPU output were not executed here. This is not yet a measured hardware-accuracy milestone.
C++26 implementations remain partial/experimental. This pass uses established C++20 bit facilities under the requested newer dialect. Linux CI now targets Ubuntu 24.04; do not assume its artifacts run on Ubuntu 22.04. Older BSD/Nix/toolchain configurations may need updates. The PR remains draft pending platform build review and game regression evidence.