Skip to content

iris-gui: port live MIPS estimate to CyclesPtr - #77

Merged
techomancer merged 1 commit into
techomancer:mainfrom
tenox7:fix-gui-cycles-ptr
Aug 8, 2026
Merged

iris-gui: port live MIPS estimate to CyclesPtr#77
techomancer merged 1 commit into
techomancer:mainfrom
tenox7:fix-gui-cycles-ptr

Conversation

@tenox7

@tenox7 tenox7 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Problem

iris-gui doesn't compile on current main:

error[E0308]: mismatched types
   --> iris-gui/src/handle.rs:409:34
    |
409 |                         cycles = m.get_rex3().map(|r| r.cycles.clone());
    |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Option<Arc<Atomic<u64>>>`, found `Option<Cell<CyclesPtr>>`
error: could not compile `iris-gui` (bin "iris-gui") due to 1 previous error

926d56f ("convert cycles atomic into regular volatile variable") changed Rex3::cycles from Arc<AtomicU64> to Cell<CyclesPtr> across 11 files under src/, but iris-gui/ wasn't updated. The GUI's worker loop uses that counter for its live MIPS estimate, so it was still calling .clone() on the Arc and .load(Ordering::Relaxed) to read it.

The CLI (iris, iris-ci) builds fine — only the GUI is affected.

Fix

Latch the CyclesPtr by value rather than cloning an Arc, and read it with .get():

let mut cycles: Option<iris::mips_core::CyclesPtr> = None;
...
cycles = m.get_rex3().map(|r| r.cycles.get());
prev_cycles = cycles.map(|c| c.get()).unwrap_or(0);

This mirrors REX3's own refresh thread at src/rex3.rs:3863 (self.cycles.get().get()Cell::get for the pointer, then CyclesPtr::get for the count).

Notes on correctness:

  • CyclesPtr is Copy/Send/Sync and its doc comment names cross-thread status displays as the intended consumer, valid for the process lifetime. The GUI's MIPS readout is exactly that — it exists because the GUI never runs REX3's own refresh/status-bar loop.
  • Being Copy, the Option no longer needs .as_ref().
  • .get() is null-safe (returns 0 while dangling), and the pointer is already wired up by the time the GUI latches it, since that happens after Machine::new returns.
  • The existing Stop/SyncDisks paths already reset cycles = None before the machine is dropped, so no dangling read.

Testing

./build.sh on macOS arm64 (rustc 1.99.0-nightly), CLI features lightning,rex-jit,tlbvmap,idle-pause and GUI features iris/lightning,iris/idle-pause: all three binaries build clean. No new warnings.

926d56f converted REX3's cycle counter from Arc<AtomicU64> to a
Cell<CyclesPtr> volatile read but only updated src/, leaving
iris-gui/src/handle.rs on the old API and the GUI build broken:

  error[E0308]: mismatched types
    --> iris-gui/src/handle.rs:409:34
     | expected `Option<Arc<Atomic<u64>>>`, found `Option<Cell<CyclesPtr>>`

Latch the CyclesPtr instead of cloning an Arc and read it with .get(),
mirroring REX3's own refresh thread in src/rex3.rs. CyclesPtr is Copy,
so the Option no longer needs .as_ref(); .get() is null-safe, and the
existing Stop/SyncDisks paths already clear it to None.
Copilot AI lite review requested due to automatic review settings August 8, 2026 06:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates iris-gui to match the emulator core’s newer cycle-counter plumbing by switching the GUI’s live MIPS estimate from an Arc<AtomicU64>-based counter to the mips_core::CyclesPtr pointer-based counter used by REX3.

Changes:

  • Replace the GUI worker-loop cached cycle counter type from Option<Arc<AtomicU64>> to Option<iris::mips_core::CyclesPtr>.
  • Update the periodic MIPS-estimate refresh logic to read cycles via CyclesPtr::get() instead of AtomicU64::load(Ordering::Relaxed).
  • Latch the cycle counter from REX3 via r.cycles.get() (copying the pointer value out of the Cell) and initialize prev_cycles via CyclesPtr::get().

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@techomancer

Copy link
Copy Markdown
Owner

oh crap. sorry

@techomancer
techomancer merged commit 2be036c into techomancer:main Aug 8, 2026
1 check passed
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.

3 participants