pr8.2
This commit is contained in:
parent
c07a1cc230
commit
25d4f3eacb
@ -360,6 +360,88 @@ impl VirtualMachine {
|
||||
}
|
||||
|
||||
|
||||
/// Harness: run exactly `frames` logical frames deterministically.
|
||||
///
|
||||
/// This repeatedly calls `run_budget` with the provided `budget_per_slice` until
|
||||
/// a full logical frame is completed (i.e., a `FrameSync` is observed). If a
|
||||
/// terminal condition is reached earlier (Halt/EndOfRom/Panic/Trap/Breakpoint),
|
||||
/// the function returns early with all collected slice reports so far.
|
||||
pub fn run_frames(
|
||||
&mut self,
|
||||
frames: u64,
|
||||
budget_per_slice: u64,
|
||||
native: &mut dyn NativeInterface,
|
||||
ctx: &mut HostContext,
|
||||
) -> Result<Vec<BudgetReport>, String> {
|
||||
assert!(budget_per_slice > 0, "budget_per_slice must be > 0");
|
||||
|
||||
let mut out = Vec::new();
|
||||
let mut frames_done = 0u64;
|
||||
while frames_done < frames {
|
||||
let rep = self.run_budget(budget_per_slice, native, ctx)?;
|
||||
let terminal = matches!(
|
||||
rep.reason,
|
||||
LogicalFrameEndingReason::Halted
|
||||
| LogicalFrameEndingReason::EndOfRom
|
||||
| LogicalFrameEndingReason::Panic(_)
|
||||
| LogicalFrameEndingReason::Trap(_)
|
||||
| LogicalFrameEndingReason::Breakpoint
|
||||
);
|
||||
|
||||
let is_frame_end = matches!(rep.reason, LogicalFrameEndingReason::FrameSync);
|
||||
out.push(rep);
|
||||
|
||||
if terminal {
|
||||
break;
|
||||
}
|
||||
if is_frame_end {
|
||||
frames_done += 1;
|
||||
}
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// Harness: alias for `run_frames(frames, ...)`.
|
||||
pub fn run_ticks(
|
||||
&mut self,
|
||||
ticks: u64,
|
||||
budget_per_slice: u64,
|
||||
native: &mut dyn NativeInterface,
|
||||
ctx: &mut HostContext,
|
||||
) -> Result<Vec<BudgetReport>, String> {
|
||||
self.run_frames(ticks, budget_per_slice, native, ctx)
|
||||
}
|
||||
|
||||
/// Harness: run until HALT/EndOfRom/Panic/Trap/Breakpoint deterministically.
|
||||
///
|
||||
/// Repeatedly invokes `run_budget` with a fixed `budget_per_slice`, collecting
|
||||
/// each slice's report until a terminal condition is reached.
|
||||
pub fn run_until_halt(
|
||||
&mut self,
|
||||
budget_per_slice: u64,
|
||||
native: &mut dyn NativeInterface,
|
||||
ctx: &mut HostContext,
|
||||
) -> Result<Vec<BudgetReport>, String> {
|
||||
assert!(budget_per_slice > 0, "budget_per_slice must be > 0");
|
||||
|
||||
let mut out = Vec::new();
|
||||
loop {
|
||||
let rep = self.run_budget(budget_per_slice, native, ctx)?;
|
||||
let terminal = matches!(
|
||||
rep.reason,
|
||||
LogicalFrameEndingReason::Halted
|
||||
| LogicalFrameEndingReason::EndOfRom
|
||||
| LogicalFrameEndingReason::Panic(_)
|
||||
| LogicalFrameEndingReason::Trap(_)
|
||||
| LogicalFrameEndingReason::Breakpoint
|
||||
);
|
||||
out.push(rep);
|
||||
if terminal { break; }
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
|
||||
/// Executes a single instruction at the current Program Counter (PC).
|
||||
///
|
||||
/// This follows the classic CPU cycle:
|
||||
|
||||
@ -1,19 +1,3 @@
|
||||
# PR-8 — Tooling & Test Harness (JVM-Grade Discipline)
|
||||
|
||||
This phase establishes tooling and test discipline required to keep the Prometeu VM at JVM-grade quality.
|
||||
|
||||
Goals:
|
||||
|
||||
* Deterministic execution
|
||||
* Reproducible tests
|
||||
* Strong disassembler guarantees
|
||||
* Layered test coverage
|
||||
* Zero legacy artifacts enforcement
|
||||
|
||||
Each PR below is self-contained and must compile independently.
|
||||
|
||||
---
|
||||
|
||||
# PR-8.1 — Disassembler (Roundtrip + Snapshot Reliability)
|
||||
|
||||
## Briefing
|
||||
@ -72,61 +56,6 @@ If any opcode semantics unclear, STOP and ask.
|
||||
|
||||
---
|
||||
|
||||
# PR-8.2 — Deterministic Execution Harness
|
||||
|
||||
## Briefing
|
||||
|
||||
The VM must be testable deterministically.
|
||||
|
||||
Requirements:
|
||||
|
||||
* No wall-clock time.
|
||||
* Controlled tick progression.
|
||||
* Fixed seed where randomness exists (if any).
|
||||
|
||||
## Target
|
||||
|
||||
Introduce a test harness wrapper:
|
||||
|
||||
* Controlled `tick` counter.
|
||||
* Deterministic scheduler stepping.
|
||||
* Explicit run_budget boundaries.
|
||||
|
||||
Provide utilities:
|
||||
|
||||
* `run_until_halt()`
|
||||
* `run_ticks(n)`
|
||||
* `run_frames(n)`
|
||||
|
||||
No external timing.
|
||||
|
||||
## Acceptance Checklist
|
||||
|
||||
* [ ] No real-time dependencies.
|
||||
* [ ] Deterministic coroutine wake order.
|
||||
* [ ] Repeatable runs produce identical traces.
|
||||
|
||||
## Tests
|
||||
|
||||
1. Same program run twice produces identical state traces.
|
||||
2. Sleep/wake ordering stable.
|
||||
|
||||
## Junie Instructions
|
||||
|
||||
You MAY:
|
||||
|
||||
* Extend test harness.
|
||||
* Add deterministic trace utilities.
|
||||
|
||||
You MUST NOT:
|
||||
|
||||
* Introduce randomness.
|
||||
* Use system time.
|
||||
|
||||
If current VM depends on real time, STOP and refactor before proceeding.
|
||||
|
||||
---
|
||||
|
||||
# PR-8.3 — Layered Test Suite Architecture
|
||||
|
||||
## Briefing
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user