Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
434 commits
Select commit Hold shift + click to select a range
2680ad6
Propagate filter iterator plans through locals
rtfeldman Jun 26, 2026
8dbc17c
Propagate single iterator plans through locals
rtfeldman Jun 26, 2026
21aecb4
Propagate range iterator plans through locals
rtfeldman Jun 26, 2026
0282448
Propagate custom iterator plans through locals
rtfeldman Jun 26, 2026
56db803
Optimize prepended iterator plans
rtfeldman Jun 26, 2026
4f96f86
Propagate iterator adapter chains through locals
rtfeldman Jun 26, 2026
99c2727
Forward identity iterator plans
rtfeldman Jun 26, 2026
d9911ee
Optimize prepended fold and collection
rtfeldman Jun 26, 2026
09acc1a
Cover iterator plan public boundaries
rtfeldman Jun 26, 2026
e93efb7
Cover iterator plan return boundaries
rtfeldman Jun 26, 2026
7d145bd
Cover direct iterator next materialization
rtfeldman Jun 26, 2026
feb1063
Optimize filtered fold and collection
rtfeldman Jun 26, 2026
c0ee3fb
Cover branch iterator adapter plans
rtfeldman Jun 26, 2026
3ec444d
Fix public iterator filter rest materialization
rtfeldman Jun 26, 2026
beaea98
Update iterator plan completion checklist
rtfeldman Jun 26, 2026
09aba3b
Fix CI fallout from iterator nominal
rtfeldman Jun 26, 2026
1dbf783
Document iterator plan public declarations
rtfeldman Jun 26, 2026
8c6e21f
Clean up iterator tidy violations
rtfeldman Jun 26, 2026
bee9378
Ignore local planning scratch file
rtfeldman Jun 26, 2026
1d362a6
Remove zero enum placeholders in tests
rtfeldman Jun 26, 2026
4dc9dab
Tighten iterator design audit wording
rtfeldman Jun 26, 2026
a736519
Update snapshots for iterator checker changes
rtfeldman Jun 26, 2026
e27ffe2
Fix const function restoration through callable static data
rtfeldman Jun 26, 2026
473eae3
Remove dead dispatch-plan helper
rtfeldman Jun 26, 2026
1476079
Fix hoisted iterator const restoration
rtfeldman Jun 26, 2026
189206f
Fix hoisted local dependency restoration
rtfeldman Jun 26, 2026
d6e384a
Fix stored function capture typing
rtfeldman Jun 26, 2026
81549d5
Document iterator plan completion
rtfeldman Jun 26, 2026
4fc2c47
Document iterator shape specialization plan
rtfeldman Jun 26, 2026
66b9697
Restore three-variant Iter step shape
rtfeldman Jun 26, 2026
a598c45
Update Iter.next tests for three-step API
rtfeldman Jun 26, 2026
be89bdb
Remove explicit iterator plan IR
rtfeldman Jun 26, 2026
b5d33a5
Clarify iterator shape specialization design
rtfeldman Jun 26, 2026
013a145
Preserve branch-joined value shapes
rtfeldman Jun 26, 2026
5fdf336
Expose direct call result shapes
rtfeldman Jun 26, 2026
7dca6d5
Document base body shape specialization design
rtfeldman Jun 26, 2026
61757a7
Refactor spec constr worker discovery
rtfeldman Jun 26, 2026
ac9686b
Split projectable loop state shapes
rtfeldman Jun 26, 2026
8c508c5
Document known-value iterator specialization design
rtfeldman Jun 26, 2026
66ab7bb
Specialize loop callable state facts
rtfeldman Jun 26, 2026
5ad0cb6
Cover annotated returned callable loop state
rtfeldman Jun 26, 2026
f9b33cf
Make loop fact projection value-aware
rtfeldman Jun 26, 2026
8a111ea
Fix spec constr capture lets for direct calls
rtfeldman Jun 26, 2026
74beffd
Rename spec constr shapes to value facts
rtfeldman Jun 26, 2026
25872fc
Reduce static iter append adapters
rtfeldman Jun 26, 2026
c96d705
Propagate direct call fact demand
Jun 26, 2026
726ad2f
Add iterator append shape regression tests
Jun 26, 2026
bfc2b10
Propagate fact demand through empty blocks
Jun 26, 2026
a55794c
Demand facts for inspected direct call arguments
Jun 26, 2026
5dc4f76
Minimize iterator append regression tests
Jun 26, 2026
76c3761
Update iterator specialization plan status
Jun 26, 2026
8c3a645
WIP preserve known iterator facts through specialization
Jun 27, 2026
312af7d
WIP preserve inline facts through statement lets
Jun 27, 2026
c31b205
Document finite callable iterator state
Jun 27, 2026
59a2d21
WIP keep iterator adapter facts exposed
Jun 27, 2026
3a1c3bd
Document iterator loop refinement blocker
Jun 27, 2026
e628801
Handle speculative known-match misses
Jun 27, 2026
7e6ccb7
WIP preserve pending-let facts in spec constr
Jun 27, 2026
42c5b88
WIP strengthen known value facts
Jun 27, 2026
ea05389
Keep solved callable facts in optimized spec constr
Jun 27, 2026
aa216cc
Advance iterator known-value specialization
Jun 27, 2026
ec4631b
Document solved spec constr entrypoint
Jun 27, 2026
bb72c01
Satisfy tidy after iterator refactor
Jun 27, 2026
48d2eb7
Remove obsolete inline unsafe count
Jun 27, 2026
4f0bbfd
Use explicit known-value terminology
Jun 27, 2026
d7cea6b
Update snapshot constraint ids
Jun 27, 2026
425c5a0
Guard specialization against implicit captures
Jun 27, 2026
1598b2e
Preserve default platform debug frames
Jun 27, 2026
c811fc6
Document optimized loop state specialization
Jun 27, 2026
340d1d5
Gate optimized post-check specialization
Jun 27, 2026
f0d90fe
Add state loop IR scaffold
Jun 27, 2026
417091d
Add state loop construction checkpoint
Jun 27, 2026
ca3bca4
Test ARC forward sibling joins
Jun 27, 2026
e3ea6da
Track projection demands in spec constr
Jun 27, 2026
425658f
Document optimized iterator state specialization
Jun 27, 2026
b99a22d
Allow partial record known-value projection
Jun 27, 2026
b8ca5d1
Document optimized iterator result demand design
Jun 27, 2026
692c403
Document loop demand fixed point
Jun 27, 2026
984a167
Document sparse demanded known values
Jun 27, 2026
64b6155
Add sparse demanded known values
Jun 27, 2026
be441bc
Document optimized iterator specialization design
Jun 27, 2026
9aacbfe
Preserve target-only callable demand
Jun 27, 2026
d2dbce0
Add tag-specific value demand
Jun 27, 2026
61bd54e
Add demanded known value state operations
Jun 27, 2026
edd91e2
Document sparse demanded state values
Jun 27, 2026
f30d09e
Add sparse demanded state key expansion
Jun 27, 2026
4447014
Add sparse private state value construction
Jun 27, 2026
f8a7868
Document optimized iterator specialization mode
Jun 27, 2026
ff2d0d6
Add sparse demanded state matching
Jun 27, 2026
3b3d770
Add sparse private state readers
Jun 27, 2026
e502e54
Add private state value boundary
Jun 27, 2026
a23a774
Clarify optimized iterator specialization boundary
Jun 27, 2026
58fbd98
Document optimized iterator specialization boundary
Jun 27, 2026
a0c6ddf
Document optimized callable-state specialization
Jun 28, 2026
73b8c40
Document callable-state specialization design
Jun 28, 2026
d953b65
Document opt-mode callable-state specialization
rtfeldman Jun 28, 2026
6a6ac6e
Document optimized callable-state control boundaries
rtfeldman Jun 28, 2026
966c6ab
Document control-boundary specialization design
rtfeldman Jun 28, 2026
c7c0d4e
Document callable-state specialization landing contract
rtfeldman Jun 28, 2026
418cf77
Document optimized callable-state invariants
rtfeldman Jun 28, 2026
a4a9f90
Document opt-mode callable-state specialization
rtfeldman Jun 28, 2026
8085d31
Document optimized callable-state mode ownership
rtfeldman Jun 28, 2026
0a58ad4
Document optimized callable-state mode gating
rtfeldman Jun 28, 2026
2735f61
Document optimized callable-state lowering boundary
rtfeldman Jun 28, 2026
8fe600d
Clarify optimized callable-state lowering design
rtfeldman Jun 28, 2026
9ad33a6
Clarify opt-mode callable-state optimizer gate
rtfeldman Jun 28, 2026
a74cf7e
Document opt-mode callable-state lowering design
rtfeldman Jun 28, 2026
9d3ac2a
Document optimized lowering mode gate
rtfeldman Jun 28, 2026
7a9dd75
Document recursive loop demand graph
rtfeldman Jun 28, 2026
9e0543a
Clarify optimized callable-state test gate
rtfeldman Jun 28, 2026
50a09c3
Clarify demand-frame optimizer design
rtfeldman Jun 28, 2026
29fee5d
Clarify optimized lowering gate checkpoint
rtfeldman Jun 28, 2026
8145a99
Document opt-only callable-state lowering
rtfeldman Jun 28, 2026
cc02362
Clarify opt-only lowering ownership split
rtfeldman Jun 28, 2026
4b81d6e
Clarify opt-only callable-state lowering design
rtfeldman Jun 28, 2026
877d0f9
Clarify callable-state optimizer commitments
rtfeldman Jun 28, 2026
23ad762
Clarify opt-only callable-state lowering gate
rtfeldman Jun 28, 2026
35f7d75
docs: clarify optimized callable-state lowering design
rtfeldman Jun 28, 2026
8ac6c5b
docs: clarify optimized callable-state lowering design
rtfeldman Jun 28, 2026
1973a4a
docs: refine callable-state specialization plan
rtfeldman Jun 28, 2026
5e46683
docs: clarify optimized callable-state mode boundary
rtfeldman Jun 28, 2026
8c29e25
docs: clarify callable-state optimization target
rtfeldman Jun 28, 2026
caddad3
docs: pin callable-state optimization mode boundary
rtfeldman Jun 28, 2026
4fbc26f
docs: clarify optimized lowering mode ownership
rtfeldman Jun 28, 2026
ea1f39c
fix compact loop escape lowering
rtfeldman Jun 28, 2026
ac01ddf
document post-check pipeline aliases
rtfeldman Jun 28, 2026
f2f0d4a
remove dead optimizer helpers
rtfeldman Jun 28, 2026
e4c929f
avoid zero enum placeholders in optimizer tests
rtfeldman Jun 28, 2026
06e4fce
remove unused suppression patterns
rtfeldman Jun 28, 2026
d85508a
clarify optimized lowering design boundary
rtfeldman Jun 28, 2026
ef858f8
satisfy semantic audit in optimizer docs
rtfeldman Jun 28, 2026
84b81c8
avoid callable field storage on non-aggregates
rtfeldman Jun 28, 2026
325efa8
clarify optimized lowering mode boundary
rtfeldman Jun 28, 2026
b7338dc
clarify opt-mode callable-state plan
rtfeldman Jun 28, 2026
50d3f4c
fix callable-state capture demand propagation
rtfeldman Jun 28, 2026
0d1a33c
preserve private loop entry demand facts
rtfeldman Jun 28, 2026
692210c
Advance demand specialization lowering
rtfeldman Jun 29, 2026
8504539
Make post-check lowering mode structural
rtfeldman Jun 29, 2026
e474b9e
Prove ordinary post-check modes skip optimized context
rtfeldman Jun 29, 2026
3056a81
Name optimized specialization context explicitly
rtfeldman Jun 29, 2026
41fa43e
Clean up iterator specialization scaffolding
rtfeldman Jun 30, 2026
c27ffa3
Clean up callable-state optimization docs
rtfeldman Jun 30, 2026
654e1a7
Clean up specialization WIP
rtfeldman Jun 30, 2026
b3d20c6
Define callable-state optimizer contract
rtfeldman Jun 30, 2026
f6d00b3
Add callable-state implementation guardrails
rtfeldman Jun 30, 2026
ea88135
Add callable-state architecture checks
rtfeldman Jun 30, 2026
5c10f88
Tighten callable-state reset plan
rtfeldman Jun 30, 2026
224ad8c
Update callable-state reset plan
rtfeldman Jun 30, 2026
0cdfb5c
Tighten wrapper reset guardrails
rtfeldman Jun 30, 2026
6eb49db
Move wrapper facts into optimized lowering
rtfeldman Jun 30, 2026
3ba8662
Update iterator optimization plan guardrails
rtfeldman Jun 30, 2026
86ef018
Tighten iterator optimization reset protocol
rtfeldman Jun 30, 2026
ad07b90
Project finite callable capture demand per target
rtfeldman Jun 30, 2026
8be106f
Document reset protocol for loop demand work
rtfeldman Jun 30, 2026
13bd570
Document stale demanded product guardrail
rtfeldman Jun 30, 2026
9834b66
Document loop-supplied callable capture demand
rtfeldman Jun 30, 2026
c5ada0b
Checkpoint callable demand WIP
rtfeldman Jun 30, 2026
ac8c4bd
Fix demanded loop entry state shape
rtfeldman Jul 1, 2026
066a93c
Add WIP optimization report
rtfeldman Jul 1, 2026
2de940e
Return loop-state callable demand to its owning loop
rtfeldman Jul 1, 2026
62f4cf6
Scope known-value loop split params while cloning the loop body
rtfeldman Jul 1, 2026
2a7d757
Scope statement-bound locals and pair loop keys with demanded entries
rtfeldman Jul 1, 2026
9bc86bf
Keep preserved statement inits visible to demand and boundaries
rtfeldman Jul 2, 2026
69c81dd
Make public call boundaries one fact for demand and cloning
rtfeldman Jul 2, 2026
dcb978f
Carry unsplittable loop entries and results as demanded private state
rtfeldman Jul 2, 2026
a7de4b7
Project private leaves and keep recursive callable state finite
rtfeldman Jul 2, 2026
ea5f7b7
Emit multi-use control-flow bindings once
rtfeldman Jul 2, 2026
44b1c3a
Say field read exactly in the private-child comment
rtfeldman Jul 2, 2026
1dc9e2e
Merge origin/main into wasm-changes
rtfeldman Jul 2, 2026
96ec6e8
Add iterator fusion design contract
rtfeldman Jul 2, 2026
f91a54b
Add iterator-fusion Phase 0 differential test harness
rtfeldman Jul 2, 2026
e825645
Keep count-limited Iter adapters on a single step successor
rtfeldman Jul 2, 2026
3502a5b
Activate the custom-iterator differential test as a known divergence
rtfeldman Jul 2, 2026
2a9c0d5
Carry loop-carried iterator state whole when a back edge can't rebuil…
rtfeldman Jul 2, 2026
b3e9d9c
Key call-pattern substitutions by full local identity, not binder alone
rtfeldman Jul 2, 2026
9b8e83a
Add iterator fusion Phase 2 implementation plan
rtfeldman Jul 2, 2026
c045df2
Carry advanced iterator state through inlined step successors
rtfeldman Jul 2, 2026
2753620
Activate the keep_if collect differential test
rtfeldman Jul 2, 2026
57b0541
Own capture-record fields while lowering their capture operands
rtfeldman Jul 2, 2026
cc0c901
Decide loop-state splits by cloning the body, not by scanning source …
rtfeldman Jul 3, 2026
f889e65
Share one pending-binding stack and let structured values keep their …
rtfeldman Jul 3, 2026
67e48c3
Let bindings and blocks stay transparent to structured value flow
rtfeldman Jul 3, 2026
1addab9
Collapse branch-built steps into consumers and dissolve their bindings
rtfeldman Jul 3, 2026
b6d6361
Pin the scalar loop shape of a bare list iter collect
rtfeldman Jul 3, 2026
51e7585
Decline sinking a continuation onto an opaque branch value
rtfeldman Jul 3, 2026
59ab523
Admit a strictly-smaller re-entrant inline through the recursion guard
rtfeldman Jul 3, 2026
4aa7559
Scalarize a for-loop over an owned iterator source into its loop
rtfeldman Jul 3, 2026
2e3a81b
Activate the tier-one map-collect acceptance test
rtfeldman Jul 3, 2026
020ee23
Fuse for-loops over branch-chosen iterators by sinking into branches
rtfeldman Jul 3, 2026
b0069f3
Demote loop-state leaves per-leaf, not per-slot
rtfeldman Jul 3, 2026
5a92fe6
Add Rocci Bird --opt=size function-level forensics report
rtfeldman Jul 3, 2026
2a36886
Anchor loop-carried borrows on their join parameter
rtfeldman Jul 3, 2026
73e384e
Peel branch-chosen append loops into one base loop plus tail dispatch
rtfeldman Jul 3, 2026
a61df92
Peel branch-append loops before specialization and support search loops
rtfeldman Jul 3, 2026
9393458
Make the branch-append search differential match Rocci's record shape
rtfeldman Jul 3, 2026
00a7880
Add zero-allocation gate for Iter (intentionally RED)
rtfeldman Jul 5, 2026
48cd00e
Add static zero-allocation gate for escaping iterators (intentionally…
rtfeldman Jul 5, 2026
4c391be
Store the base Iter step closure inline instead of erasing it to a box
rtfeldman Jul 5, 2026
5701c11
Guard: a list held by a live iterator is not mutated in place
rtfeldman Jul 5, 2026
b76e1de
Merge remote-tracking branch 'origin/main' into wasm-changes
rtfeldman Jul 6, 2026
3c0e200
Make per-chain minting the iterator representation
rtfeldman Jul 6, 2026
2df7404
Merge remote-tracking branch 'origin/main' into wasm-changes
rtfeldman Jul 6, 2026
3dfb22a
Complete iterator specialization fixes
rtfeldman Jul 6, 2026
79c8e56
Merge origin/main into iterator specialization work
rtfeldman Jul 6, 2026
a3fee12
Update static dispatch snapshots after merge
rtfeldman Jul 6, 2026
07d1fb2
Guard iterator minting against opt-only specialization
rtfeldman Jul 6, 2026
e4aa42c
Merge remote-tracking branch 'origin/main' into wasm-changes
rtfeldman Jul 6, 2026
bbbf32c
Fix borrowed-span loops in the LIR shape walker
rtfeldman Jul 6, 2026
ca87aea
Restore Binaryen and zeroed-memory wiring on the wasm link path
rtfeldman Jul 6, 2026
ab9c6a1
Bound minted iterator chain depth at the construction choke point
rtfeldman Jul 6, 2026
e026f6e
Bound SpecConstr walks over self-referential known values
rtfeldman Jul 7, 2026
1017dae
Merge remote-tracking branch 'origin/main' into wasm-changes
rtfeldman Jul 7, 2026
2defbba
Fix for-loop over Iter.append freezing the inner iterator
rtfeldman Jul 8, 2026
6aeb1da
Reconcile iterator design contract with the as-built minting
rtfeldman Jul 8, 2026
051f062
Add end-to-end minted-iterator cart gate on the --opt=size path
rtfeldman Jul 8, 2026
e640bcd
Track the minted-iterator size premium in the wasm cart gate
rtfeldman Jul 8, 2026
c4cff0c
Keep minted concat and single single-typed so nested concat compiles
rtfeldman Jul 8, 2026
4f0ce4c
Fix wasm composite loop state rebinding
rtfeldman Jul 8, 2026
4353fbc
Restore static data materialization
rtfeldman Jul 8, 2026
88a2bda
Elide adjacent retain release pairs
rtfeldman Jul 8, 2026
33a8cd7
Fix semantic audit findings
rtfeldman Jul 8, 2026
67f6acc
Fix minici build-ci failures
rtfeldman Jul 8, 2026
92a9ba1
Remove stale static data helpers
rtfeldman Jul 8, 2026
ce78633
Avoid enum zero in static data test
rtfeldman Jul 8, 2026
d47fa08
Remove stale LIR static data parameter
rtfeldman Jul 8, 2026
f7650e0
Format Builtin roc source
rtfeldman Jul 8, 2026
16552a0
Update static data snapshots
rtfeldman Jul 8, 2026
a98c9e8
Copy dev static data literals from symbols
rtfeldman Jul 8, 2026
1fdd539
Make checked cache corruption test deterministic
rtfeldman Jul 8, 2026
d7a60b7
fix iterator for-loop scalarization
rtfeldman Jul 9, 2026
c79a7e0
fix dev wasm static data exports
rtfeldman Jul 9, 2026
e778cb0
restore iterator list static data
rtfeldman Jul 9, 2026
1f1c6a2
elide adjacent ARC retain release pairs
rtfeldman Jul 9, 2026
89abb46
document allocation test helper
rtfeldman Jul 9, 2026
2ec217d
use explicit hoisted constants test error
rtfeldman Jul 9, 2026
7883649
cover hoisted constants test errors
rtfeldman Jul 9, 2026
26c9fcf
fix let-bound iterator fold specialization
rtfeldman Jul 9, 2026
a90c22e
bound value-aware call-pattern specialization
rtfeldman Jul 9, 2026
56a462f
Reuse boxed platform models in updates
rtfeldman Jul 9, 2026
9549f10
Gate zero-alloc static-data hoisting of list literals via .iter()
rtfeldman Jul 9, 2026
f6e0d3a
Bound recursive iterator representations explicitly
rtfeldman Jul 10, 2026
e81c2dd
Reconcile iterator and post-check design
rtfeldman Jul 10, 2026
f57cdbd
Record ARC size pilot result
rtfeldman Jul 10, 2026
73b0464
Make final wasm exports explicit
rtfeldman Jul 10, 2026
167ae5e
Strip target features from size wasm output
rtfeldman Jul 10, 2026
c298e22
Record completed wasm size audit
rtfeldman Jul 10, 2026
484295a
Clarify wasm metadata stripping contract
rtfeldman Jul 10, 2026
91c61e7
Document iterator representation tiers
rtfeldman Jul 10, 2026
40015fd
Generate box reuse test join ids
rtfeldman Jul 10, 2026
5fd6f52
Bump checked artifact schema version
rtfeldman Jul 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
target
!src/target
generated-docs
plan.md

zig-out
zig-pkg
Expand All @@ -47,6 +48,7 @@ zig-pkg
*.def
*.tmp
*.wasm
!test/cli/rocci_bird_postcheck_panic/platform/targets/wasm32/host.wasm
*.exe
*.pdb

Expand Down Expand Up @@ -156,5 +158,5 @@ test/glue/*/roc_platform_abi.zig
test/echo/builtin_doc_*.roc
tmp/

# Scratch planning docs (CI forbids tracking these)
# Local implementation planning notes / scratch planning docs (CI forbids tracking these)
plan.md
181 changes: 181 additions & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2773,6 +2773,7 @@ pub fn build(b: *std.Build) void {
.imports = &.{
.{ .name = "test_harness", .module = createTestHarnessModule(b, roc_modules) },
.{ .name = "collections", .module = roc_modules.collections },
.{ .name = "backend", .module = roc_modules.backend },
},
}),
});
Expand Down Expand Up @@ -3592,6 +3593,72 @@ pub fn build(b: *std.Build) void {
build_wasm_str_concat_join_app.step.dependOn(build_test_hosts_step);
build_test_wasm_static_lib_runner_step.dependOn(&build_wasm_str_concat_join_app.step);

// End-to-end cart gate for the minted-iterator `for`-loop drive. The
// size build covers the LLVM cart path, and the dev build covers wasm
// composite loop-state rebinding for recursive generated iterators.
const build_wasm_iter_for_app = b.addRunArtifact(roc_exe);
build_wasm_iter_for_app.addArgs(&.{
"build",
"test/wasm/iter_for_static_lib_app.roc",
"--opt=size",
"--target=wasm32",
"--output=test/wasm/iter_for_static_lib_app.wasm",
});
build_wasm_iter_for_app.step.dependOn(build_test_hosts_step);
build_test_wasm_static_lib_runner_step.dependOn(&build_wasm_iter_for_app.step);

const build_wasm_iter_for_dev_app = b.addRunArtifact(roc_exe);
build_wasm_iter_for_dev_app.addArgs(&.{
"build",
"test/wasm/iter_for_static_lib_app.roc",
"--opt=dev",
"--target=wasm32",
"--output=test/wasm/iter_for_static_lib_app_dev.wasm",
});
build_wasm_iter_for_dev_app.step.dependOn(build_test_hosts_step);
build_test_wasm_static_lib_runner_step.dependOn(&build_wasm_iter_for_dev_app.step);

// Dev-mode recursive iterator construction must converge at the
// explicit forced-dynamic representation tier.
const build_wasm_iter_recursive_concat_app = b.addRunArtifact(roc_exe);
build_wasm_iter_recursive_concat_app.addArgs(&.{
"build",
"test/wasm/iter_recursive_concat_static_lib_app.roc",
"--opt=dev",
"--target=wasm32",
"--output=test/wasm/iter_recursive_concat_static_lib_app.wasm",
});
build_wasm_iter_recursive_concat_app.step.dependOn(build_test_hosts_step);
build_test_wasm_static_lib_runner_step.dependOn(&build_wasm_iter_recursive_concat_app.step);

// Static-data hoisting gate: a constant list literal consumed via
// `.iter()` must materialize as static data and allocate nothing, so the
// whole minted chain (base list included) is zero-alloc on the cart path.
const build_wasm_iter_list_hoist_app = b.addRunArtifact(roc_exe);
build_wasm_iter_list_hoist_app.addArgs(&.{
"build",
"test/wasm/iter_list_hoist_static_lib_app.roc",
"--opt=size",
"--target=wasm32",
"--output=test/wasm/iter_list_hoist_static_lib_app.wasm",
});
build_wasm_iter_list_hoist_app.step.dependOn(build_test_hosts_step);
build_test_wasm_static_lib_runner_step.dependOn(&build_wasm_iter_list_hoist_app.step);

// Noiter twin: the same sums over plain list literals. The runner prints
// each cart's byte size, so the iter build minus this baseline is the
// minted-adapter premium tracked in CI (the fusion pass's target).
const build_wasm_iter_noiter_app = b.addRunArtifact(roc_exe);
build_wasm_iter_noiter_app.addArgs(&.{
"build",
"test/wasm/iter_for_noiter_static_lib_app.roc",
"--opt=size",
"--target=wasm32",
"--output=test/wasm/iter_for_noiter_static_lib_app.wasm",
});
build_wasm_iter_noiter_app.step.dependOn(build_test_hosts_step);
build_test_wasm_static_lib_runner_step.dependOn(&build_wasm_iter_noiter_app.step);

const build_wasm_rc_cleanup_app = b.addRunArtifact(roc_exe);
build_wasm_rc_cleanup_app.addArgs(&.{
"build",
Expand All @@ -3614,6 +3681,17 @@ pub fn build(b: *std.Build) void {
build_wasm_rc_cleanup_model_list_app.step.dependOn(build_test_hosts_step);
build_test_wasm_static_lib_runner_step.dependOn(&build_wasm_rc_cleanup_model_list_app.step);

const build_wasm_boxed_model_update_app = b.addRunArtifact(roc_exe);
build_wasm_boxed_model_update_app.addArgs(&.{
"build",
"test/wasm/boxed_model_update_static_lib_app.roc",
"--opt=dev",
"--target=wasm32",
"--output=test/wasm/boxed_model_update_static_lib_app.wasm",
});
build_wasm_boxed_model_update_app.step.dependOn(build_test_hosts_step);
build_test_wasm_static_lib_runner_step.dependOn(&build_wasm_boxed_model_update_app.step);

const wasm_test_exe = b.addExecutable(.{
.name = "wasm_static_lib_test",
.root_module = b.createModule(.{
Expand Down Expand Up @@ -3689,6 +3767,81 @@ pub fn build(b: *std.Build) void {
run_wasm_str_concat_join_test.step.dependOn(build_test_wasm_static_lib_runner_step);
run_test_wasm_static_lib_step.dependOn(&run_wasm_str_concat_join_test.step);

// Boot-and-play the minted-iterator `for`-loop cart; "ok" means every
// inlined `for` over append/map/concat/chained minted chains ran to
// completion with correct sums (i.e. the drive advanced its inner
// iterators and terminated). `--assert-alloc-balanced` also catches a
// per-step allocate/free leak in the drive.
const run_wasm_iter_for_test = b.addRunArtifact(wasm_test_exe);
run_wasm_iter_for_test.addArgs(&.{
"--wasm-path",
"test/wasm/iter_for_static_lib_app.wasm",
"--expected",
"ok",
"--assert-alloc-balanced",
// Absolute-size ceiling: the un-fused minted cart is ~48 KB
// (premium ~18 KB over the noiter twin). This catches a gross
// size blowup; the premium itself is read from the two printed
// sizes and is the fusion pass's target, not a hard gate pre-fusion.
"--max-bytes",
"65536",
});
run_wasm_iter_for_test.step.dependOn(build_test_wasm_static_lib_runner_step);
run_test_wasm_static_lib_step.dependOn(&run_wasm_iter_for_test.step);

const run_wasm_iter_recursive_concat_test = b.addRunArtifact(wasm_test_exe);
run_wasm_iter_recursive_concat_test.addArgs(&.{
"--wasm-path",
"test/wasm/iter_recursive_concat_static_lib_app.wasm",
"--expected",
"ok",
"--assert-alloc-balanced",
// The fixed cart is ~542 KB. The prior unbounded generated
// callable expansion exceeded 815 KB before failing to lower.
"--max-bytes",
"600000",
});
run_wasm_iter_recursive_concat_test.step.dependOn(build_test_wasm_static_lib_runner_step);
run_test_wasm_static_lib_step.dependOn(&run_wasm_iter_recursive_concat_test.step);

// Static-data hoisting: the constant list literal is materialized as
// static data, so the whole chain allocates nothing. `--max-allocs 0`
// is a strictly stronger assertion than `--assert-alloc-balanced`.
const run_wasm_iter_list_hoist_test = b.addRunArtifact(wasm_test_exe);
run_wasm_iter_list_hoist_test.addArgs(&.{
"--wasm-path",
"test/wasm/iter_list_hoist_static_lib_app.wasm",
"--expected",
"ok",
"--max-allocs",
"0",
});
run_wasm_iter_list_hoist_test.step.dependOn(build_test_wasm_static_lib_runner_step);
run_test_wasm_static_lib_step.dependOn(&run_wasm_iter_list_hoist_test.step);

const run_wasm_iter_for_dev_test = b.addRunArtifact(wasm_test_exe);
run_wasm_iter_for_dev_test.addArgs(&.{
"--wasm-path",
"test/wasm/iter_for_static_lib_app_dev.wasm",
"--expected",
"ok",
"--assert-alloc-balanced",
});
run_wasm_iter_for_dev_test.step.dependOn(build_test_wasm_static_lib_runner_step);
run_test_wasm_static_lib_step.dependOn(&run_wasm_iter_for_dev_test.step);

// Noiter twin — asserts correctness and prints its size so CI logs
// carry both numbers for premium tracking.
const run_wasm_iter_noiter_test = b.addRunArtifact(wasm_test_exe);
run_wasm_iter_noiter_test.addArgs(&.{
"--wasm-path",
"test/wasm/iter_for_noiter_static_lib_app.wasm",
"--expected",
"ok",
});
run_wasm_iter_noiter_test.step.dependOn(build_test_wasm_static_lib_runner_step);
run_test_wasm_static_lib_step.dependOn(&run_wasm_iter_noiter_test.step);

const run_wasm_rc_cleanup_test = b.addRunArtifact(wasm_test_exe);
run_wasm_rc_cleanup_test.addArgs(&.{
"--wasm-path",
Expand All @@ -3714,6 +3867,16 @@ pub fn build(b: *std.Build) void {
});
run_wasm_rc_cleanup_model_list_test.step.dependOn(build_test_wasm_static_lib_runner_step);
run_test_wasm_static_lib_step.dependOn(&run_wasm_rc_cleanup_model_list_test.step);

const run_wasm_boxed_model_update_test = b.addRunArtifact(wasm_test_exe);
run_wasm_boxed_model_update_test.addArgs(&.{
"--wasm-path",
"test/wasm/boxed_model_update_static_lib_app.wasm",
"--expected",
"ok",
});
run_wasm_boxed_model_update_test.step.dependOn(build_test_wasm_static_lib_runner_step);
run_test_wasm_static_lib_step.dependOn(&run_wasm_boxed_model_update_test.step);
}
run_wasm_test.step.dependOn(build_test_wasm_static_lib_runner_step);
run_test_wasm_static_lib_step.dependOn(&run_wasm_test.step);
Expand Down Expand Up @@ -5664,14 +5827,20 @@ fn addMainExe(
}
}

const use_bundled_deps = !use_system_llvm and user_llvm_path == null;

const config = b.addOptions();
config.addOption(bool, "llvm", true);
config.addOption(bool, "binaryen", use_bundled_deps);
exe.root_module.addOptions("config", config);
exe.root_module.addAnonymousImport("legal_details", .{ .root_source_file = b.path("legal_details") });

const llvm_paths_exe = llvmPaths(b, target, use_system_llvm, user_llvm_path) orelse return null;
exe.root_module.addLibraryPath(.{ .cwd_relative = llvm_paths_exe.lib });
exe.root_module.addIncludePath(.{ .cwd_relative = llvm_paths_exe.include });
if (use_bundled_deps) {
addStaticBinaryenOptionsToModule(exe.root_module);
}
try addStaticLlvmOptionsToModule(exe.root_module);

add_tracy(b, roc_modules.build_options, exe, target, true, tracy);
Expand Down Expand Up @@ -5970,6 +6139,18 @@ fn addStaticLlvmOptionsToModule(mod: *std.Build.Module) !void {
}
}

fn addStaticBinaryenOptionsToModule(mod: *std.Build.Module) void {
const link_static = std.Build.Module.LinkSystemLibraryOptions{
.preferred_link_mode = .static,
.search_strategy = .mode_first,
};
mod.addCSourceFile(.{
.file = .{ .cwd_relative = "src/build/zig_binaryen.cpp" },
.flags = &exe_cflags,
});
mod.linkSystemLibrary("binaryen", link_static);
}

const cpp_sources = [_][]const u8{
"src/build/zig_llvm.cpp",
};
Expand Down
32 changes: 16 additions & 16 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,43 @@
.lazy = true,
},
.roc_deps_aarch64_macos_none = .{
.url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0/aarch64-macos-none.tar.xz",
.hash = "N-V-__8AAEvEEA9B1q8qGkm3rJW_bkae4wn1SvyrfDa0w1lp",
.url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0-binaryen/aarch64-macos-none.tar.xz",
.hash = "N-V-__8AAKS-VRH7JXsaDHpnFPSd-B5fSdtnDbh0XrfnncWc",
.lazy = true,
},
.roc_deps_aarch64_linux_musl = .{
.url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0/aarch64-linux-musl.tar.xz",
.hash = "N-V-__8AAHPjwBNV6lTtxPO6DYe4lg2Gx5Qakmeg1PO7N5k7",
.url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0-binaryen/aarch64-linux-musl.tar.xz",
.hash = "N-V-__8AACK4KheKSiltX0PPURTNh0CvJhsopNXzcXpvq9pS",
.lazy = true,
},
.roc_deps_aarch64_windows_gnu = .{
.url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0/aarch64-windows-gnu.zip",
.hash = "N-V-__8AAI4OFxV11RN1xAhLXxLTyaxZh3Wbi4U1Dza1OESo",
.url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0-binaryen/aarch64-windows-gnu.zip",
.hash = "N-V-__8AAPEjNhjVXuc6-b70fcyHFGS_ckUIx5_ICD3-3HZk",
.lazy = true,
},
.roc_deps_arm_linux_musleabihf = .{
.url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0/arm-linux-musleabihf.tar.xz",
.hash = "N-V-__8AAHU1FhRO-2yZIDQWw5rkVVuUYn5purRT9mAqykzw",
.url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0-binaryen/arm-linux-musleabihf.tar.xz",
.hash = "N-V-__8AAKywPxfY01H2OMTuZllxIuavfyGGm3kpW7-1RmkP",
.lazy = true,
},
.roc_deps_x86_linux_musl = .{
.url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0/x86-linux-musl.tar.xz",
.hash = "N-V-__8AACNk7BFESU37UNPvVOXf2dGyPMjtDSsji-VYqvmz",
.url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0-binaryen/x86-linux-musl.tar.xz",
.hash = "N-V-__8AAMg8ihSrg9Udc8ZJ1trVVUgglxJg8CbHoYG51dZq",
.lazy = true,
},
.roc_deps_x86_64_linux_musl = .{
.url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0/x86_64-linux-musl.tar.xz",
.hash = "N-V-__8AAJmm4xTmXSEZeLYLtOlZWKI_Kitjx2TOzm9vhCWM",
.url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0-binaryen/x86_64-linux-musl.tar.xz",
.hash = "N-V-__8AAGJLMhhn8pu3uyxtKTIlha8CxCjE6TNpLYvvj-cz",
.lazy = true,
},
.roc_deps_x86_64_macos_none = .{
.url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0/x86_64-macos-none.tar.xz",
.hash = "N-V-__8AAJGgsQ-GR2yR2tLFM4OM0z7ClQ0Rx7SjviQbx8Ks",
.url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0-binaryen/x86_64-macos-none.tar.xz",
.hash = "N-V-__8AAJrG0hG7ZWMT8yxRBa17ivn77bWqDpseO904PYT7",
.lazy = true,
},
.roc_deps_x86_64_windows_gnu = .{
.url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0/x86_64-windows-gnu.zip",
.hash = "N-V-__8AAJAOJxiRcaWQZpXytjyF8_Q7Mj9g7xXQWtegD-6C",
.url = "https://github.com/roc-lang/roc-bootstrap/releases/download/zig-0.16.0-binaryen/x86_64-windows-gnu.zip",
.hash = "N-V-__8AADfFZhvsrNly3AbA2PmVP9piXKNto_CmeqLuNNsd",
.lazy = true,
},
.bytebox = .{
Expand Down
Loading
Loading