Repository navigation
feat(sv)!: support wait fork and disable fork process control - #2116
Conversation
|
This pull request is part of a Mergify stack:
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f60c2b38df
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if self.kernel.is_none() { | ||
| return if matches!(stmt, sv::ir::Stmt::DisableFork) { | ||
| Ok(true) |
There was a problem hiding this comment.
Preserve cancellation when lowering a wait-condition function
When a function containing disable fork is called from a wait condition, this branch silently discards the cancellation. Ff::wait_level temporarily takes self.kernel out while lowering the predicate, so self.kernel.is_none() does not necessarily mean execution is outside a timed process. For example, after spawning a delayed child, wait(cancel()) with a function that executes disable fork and returns 1 continues without cancelling that child, allowing its later writes to occur. Preserve the caller's process-control effects while lowering these predicates, rather than treating this temporary builder state as a no-op context.
Useful? React with 👍 / 👎.
| StatementKind::WaitFork => { | ||
| self.allow_timing("wait fork statement")?; | ||
| Ok(vec![Stmt::WaitFork]) |
There was a problem hiding this comment.
Include wait fork in timed-task classification
Tasks containing the newly accepted Stmt::WaitFork are not classified as suspendable: ast/procedural/timed_tasks.rs::suspends still recognizes only delays, event controls, level waits, and previously classified task calls. Consequently, a valid ordinary process such as always @(posedge clk) await_children();, where await_children contains wait fork, remains on the non-kernel FF lowering path and fails with fork control outside a timed process. Add this variant to suspension propagation so ordinary event-driven callers are promoted to process kernels, as they are for other blocking task statements.
Useful? React with 👍 / 👎.
Forked processes could run concurrently but their caller could not wait for all outstanding children or cancel them. Implement wait fork across all live immediate children, including earlier forks and task calls. Implement disable fork across every descendant, including descendants of completed parents, while preserving the caller and its siblings. Remove cancelled activations from pending starts, waits, ready/inactive/reactive queues and scheduled wakeups before reusing their IDs. Preserve checkpoint replay of joins and cancellation. Function calls retain their caller's process identity for disable fork; wait fork remains forbidden in functions. Handle frameless processes and zero-time final procedures safely. Update obsolete rejection tests and document the supported behavior. Accept exactly four measured official fail-to-pass verdicts for wait_fork and disable_fork in two/four-state modes. These upstream cases exercise elaboration; portable cases exercise execution. Partially addresses #2111. State-file serialization, compound automatic-local event expressions, deferred assertions and join_none exceptions remain separate work. Validation: - P2 review follow-up: retain the kernel during wait-condition evaluation, restore the full predicate resume point after a false reevaluation, and propagate wait fork/fork through task classification. Four new cases fail in all 24 configurations before the fix and pass afterward. - Follow-up validation: 1,057 timing tests, affected frontend unit tests, runtime consumers, Clippy, debug NAPI and 28 JS tests pass. The final explicit-argument reevaluation case also passes all six backend configurations. - External follow-up: Verilator passes three of four new cases, but waits on a cached function result instead of reevaluating the effectful predicate in the fourth (expected q=1, observed q=0). Icarus passes both event-driven task cases; a no-argument wait function hits its Empty NexusSet internal error and the explicit-argument cancellation case leaves the child alive (q=99). - Twelve portable cases pass in 72 configurations across Native/parallel/image, Cranelift/parallel and WASM, including four-state behavior. - Four API tests cover Interpreter/native differential checkpoint replay, cancellation and ID reuse, final no-op behavior and frameless process wakeups. The frameless regression panics before the fix and passes afterward. - Existing fork API seven, library 946 and consumer 343 tests pass. Timing has 1,032 passing tests; the sole stale unsupported-feature expectation was updated and its focused rerun passes. - Formatting, affected-crate Clippy, debug NAPI build and 28 JS boundary tests pass. - Official pinned runner verifies both affected cases in both modes using the debug driver; full release conformance remains in CI. - Verilator 5.052 passes all eleven two-state cases; four-state is unsupported. Icarus 13.0 passes ten cases but fails to cancel descendants of completed parents and children from a function call. Expectations follow IEEE 1800-2023 9.6.1, 9.6.3 and 13.4 and are corroborated by Verilator. BREAKING CHANGE: ProcessStatus and procedural IR gain process-control variants; native image format advances to version 41. Change-Id: I9f0dd3b8a7a23a655d9b8a76f9a8a545ec1a4a22
f60c2b3 to
afa4716
Compare
34807b3 to
6b7252f
Compare
Revision history
|
Merge Queue Status
This pull request spent 48 minutes 31 seconds in the queue, including 47 minutes 7 seconds running CI. Required conditions to merge
|
Forked processes could run concurrently but their caller could not wait for all outstanding children or cancel them. Implement wait fork across all live immediate children, including earlier forks and task calls. Implement disable fork across every descendant, including descendants of completed parents, while preserving the caller and its siblings.
Remove cancelled activations from pending starts, waits, ready/inactive/reactive queues and scheduled wakeups before reusing their IDs. Preserve checkpoint replay of joins and cancellation. Function calls retain their caller's process identity for disable fork; wait fork remains forbidden in functions. Handle frameless processes and zero-time final procedures safely.
Update obsolete rejection tests and document the supported behavior. Accept exactly four measured official fail-to-pass verdicts for wait_fork and disable_fork in two/four-state modes. These upstream cases exercise elaboration; portable cases exercise execution.
Partially addresses #2111. State-file serialization, compound automatic-local event expressions, deferred assertions and join_none exceptions remain separate work.
Validation:
BREAKING CHANGE: ProcessStatus and procedural IR gain process-control variants; native image format advances to version 41.
Depends-On: #2112