This commit is contained in:
2026-03-24 13:40:40 +00:00
parent 3fba722b50
commit 49025b1055
4 changed files with 115 additions and 63 deletions
-61
View File
@@ -1,64 +1,3 @@
# PR-7 — Coroutines (Cooperative, Deterministic, No Mailbox)
Coroutines are the **only concurrency model** in the Prometeu VM.
This phase introduces:
* Cooperative scheduling
* Deterministic execution order
* SPAWN / YIELD / SLEEP
* Switching only at safepoints (FRAME_SYNC)
* Full GC integration
No mailbox. No message passing. No preemption.
Each PR below is self-contained and must compile independently.
---
# PR-7.1 — Coroutine Heap Object
## Briefing
A coroutine is a suspended execution context with its own stack and call frames.
No mailbox is implemented in this phase.
## Target
Define `ObjectKind::Coroutine` with:
* `state: enum { Ready, Running, Sleeping, Finished, Faulted }`
* `wake_tick: u64`
* `stack: Vec<Value>`
* `frames: Vec<CallFrame>`
Rules:
* Allocated in GC heap.
* Addressed via `HeapRef`.
* Stack and frames stored inside the coroutine object.
## Checklist
* [ ] Coroutine heap object defined.
* [ ] Stack/frames encapsulated.
* [ ] No RC/HIP remnants.
* [ ] Compiles and tests pass.
## Tests
* Allocate coroutine object.
* Validate state transitions manually.
## Junie Rules
You MAY extend heap object kinds.
You MUST NOT implement scheduling yet.
If stack representation is unclear, STOP and ask.
---
# PR-7.2 — Deterministic Scheduler Core
## Briefing