Skip to content

merge queue: merged #2695, #2704, #2703: refactor(sv)!: pass the analysis session explicitly instead of sharing it through RefCell (+2 more) - #2712

Closed
mergify[bot] wants to merge 8 commits into
masterfrom
mergify/merge-queue/6647118bdc
Closed

mergify[bot] wants to merge 8 commits into
masterfrom
mergify/merge-queue/6647118bdc

Conversation

@mergify

@mergify mergify Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Note

This is a merge queue draft opened by Mergify. Its pull requests have merged, and nobody needs to act on it.
Mergify opened it for batch grown-fricassee-c3dqmp of the changes queue, to test #2695, #2704 and #2703 before they merged into master.

🎉 What landed

Mergify merged each pull request into master on its own, then closed this draft:

  • #2695 refactor(sv)!: pass the analysis session explicitly instead of sharing it through RefCell (tignear), as 325abf4
  • #2704 perf(sv): fold zero-argument functions whose kept result is never read (tignear), as f33cfb9
  • #2703 perf(sv): parse wide based literals in linear time (tignear), as 5a591bf

This draft's code was built in this order:

  1. master at 41d9667
  2. the pull request queued ahead of this batch, listed below, which brought the tip to 62e046d
  3. #2695 + #2704 + #2703, the pull requests of this batch, tested together as one tip

Queued ahead of this batch

This pull request entered the queue before this batch and is not part of it.

Metadata for CI tooling, read by mergify ci
---
all_scopes: false
checking_base_sha: 62e046d4a49a828a3491f7484bad56d6069f3271
previous_check_retries: []
previous_failed_batches: []
pull_requests:
  - number: 2695
    scopes:
      - core
  - number: 2704
    scopes:
      - core
  - number: 2703
    scopes:
      - core
scopes:
  - core
...
1 scope
  • core
Required conditions of queue rule changes for merge
  • check-success = Conventional Commit title
  • check-success = Queue validation
  • check-success = Verify workflow lockfile
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Lint & Format
    • check-neutral = @github-actions/Lint & Format
    • check-skipped = @github-actions/Lint & Format
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Rust Test & NAPI Build
    • check-neutral = @github-actions/Rust Test & NAPI Build
    • check-skipped = @github-actions/Rust Test & NAPI Build
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/JS Test (Ubuntu)
    • check-neutral = @github-actions/JS Test (Ubuntu)
    • check-skipped = @github-actions/JS Test (Ubuntu)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Conventional Commit title
    • check-neutral = @github-actions/Conventional Commit title
    • check-skipped = @github-actions/Conventional Commit title
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Queue validation
    • check-neutral = @github-actions/Queue validation
    • check-skipped = @github-actions/Queue validation
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Verify workflow lockfile
    • check-neutral = @github-actions/Verify workflow lockfile
    • check-skipped = @github-actions/Verify workflow lockfile
Required conditions to stay in the queue

tignear and others added 8 commits October 31, 2026 17:08
…g it through RefCell

An analysis kept its caches and what it reported in an AnalysisState that
its contexts shared through an Rc, mutated behind RefCells and Cells: the
classes and class specializations laid out so far, the class declaration
scopes, the progress of nested specializations, the dimension discovery
caches, the elaboration memo, the semantic type table, the registry of
package class specializations, the call sites, the diagnostics and the
inline randomizations. These are now plain fields of a Session that
analysis owns and passes as `&mut Session` beside its context. A scope
analyzed on its own starts a session; a package class specialization is
analyzed in a session that takes over the registry, the types and the call
sites and gives them back. Guards that undid state on drop are explicit
steps after the work they bracket, and the constraint budget, the counters
of unnamed generate blocks and the interface expansion cache are owned
values too.

What module analyses add to the packages they use (package class
specializations, semantic types and call sites) was mutated through the
shared `&Packages`. It is now a `Design`, which `Packages::design` starts
from and which every analysis of a module of the design takes as
`&mut Design`: `ParsedSource::analyze_module` and its siblings take
`(&Packages, &mut Design)`, and `Packages::specialized_state_modules` reads
the package state from a `Design`. The frontend keeps one `Design` per
elaboration.

Behavior is unchanged: the analyzer and frontend tests, the SystemVerilog
suite and a UVM elaboration (same output, about 11 s and 1.0 GB before and
after) agree.

Change-Id: I45f5bd5855e3593db29f801e7ecc65846a9adc24
Binary, octal and hex digits were accumulated by shifting the whole value and
mask once per digit, so parsing a literal was quadratic in its width. The
constant interpreter round-trips wide values through such literals: evaluating
the 14,884-bit mask function of Taxi's 64-bit LFSR spent about 30% of its
compile time in these shifts. Fill each digit's bits of the value and mask
words directly instead; octal digits may straddle a word boundary. An
equivalence test checks random digit strings, including unknown and invalid
digits, against the shifting parser.

Change-Id: Icdda4fd7195824bdd3bfcbad8e02a4c7a518ba70
Taxi's LFSR builds its 122x122-bit mask in `wire mask = lfsr_mask();`, a static
zero-argument function that assigns its result bit by bit. The analyzer cannot
prove that every call assigns all of it, so the result stays static storage
kept between calls (IEEE 1800-2023 13.4.2). That excluded the function from the
evaluate-once constant path, and the call made its process count as reading
simulation state. The function body was then generated as runtime logic of
1.8M machine instructions, which spent most of the compile in register
allocation.

Without arguments and without any read of that result, every call performs the
same assignments, so the bits no call assigns keep their initial value and each
call returns what the first does. Accept such functions for constant evaluation,
and do not treat a call that lowers to its constant as reading state. A read of
the result, including through an assignment target index, keeps the call.

Single-CPU `celox vpi build`: lfsr64 125 s -> 18 s with a peak RSS of 1.7 GiB ->
243 MiB, and phy64 281 s -> 50 s with 2.1 GiB -> 288 MiB. The Taxi cocotb tests
of both configurations pass with the same simulated durations as Verilator.

Change-Id: I740502a83e35de07efdaf2e88e8dcd12ccee6cd4
@mergify mergify Bot changed the title merge queue: checking #2695 + #2704 + #2703 together on master (41d9667), stacked on #2700 merge queue: merged #2695, #2704, #2703: refactor(sv)!: pass the analysis session explicitly instead of sharing it through RefCell (+2 more) Oct 31, 2026
@mergify mergify Bot closed this Oct 31, 2026
@mergify
mergify Bot deleted the mergify/merge-queue/6647118bdc branch October 31, 2026 09:59
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.

1 participant