Repository navigation
VM: a for loop's variable takes an Array whole, as |x| does - #300
Conversation
Both compilers' export for the VM said a for loop's block's one parameter (lead_num) and not that it was a for loop's, and vm_params read one required parameter that is not ambiguous_param0 as |x,|, adding the *, that spreads an Array: `for x in [[1, 2]]` bound 1. The export now says "for", and vm_params binds it as |x| -- which also takes the one-store path for a single parameter. so_spectralnorm on the VM: 614.9 -> 577.9 G instructions. vm_check.sh runs the reference as $REF_RUBY_BIN, not rbenv's shim (#298's review).
284km
left a comment
There was a problem hiding this comment.
Reviewed f1a355bb617de7c62ef94300ed1801b79ad1ef68 against current main 1a3380b0e5738ee3ed4436c1eb94843e94ac9676. No new actionable Critical / Major / Minor findings.
The two compiler exports agree on the VM-only for marker, and the loader suppresses the trailing-comma destructuring only where appropriate. Ordinary |x,| and multi-target/rest loop bindings remain intact. The generated library matches regeneration, and public to_a/disassembly remains compatible.
Independent validation on Darwin arm64, using fresh ordinary O2 builds of both revisions, pinned Mere 9dec2ff687a08433247dbdb7729bc19c8522e538, pinned mgz 661a01d8bb68f5acd68e3192bd47f081d179c436, and reference Ruby 4.0.10:
- VM corpus: 956/956 on the VM, zero fallback or failure.
- Strict ISeq snippets: 246/246.
- Public
to_a/disassembly comparison with Ruby: 956/956; native/Ruby VM-export comparison: 956/956. - 36 focused corpus files across evaluator/VM and hash index on/off with
MERE_RUBY_GC_TIGHT=1: head 144/144, main 142/144. The two main failures are the new corpus 827 on the VM; no passing baseline combination is lost. - An additional probe covering zero/multiple/keyword yields, nested loops, nonlocal targets, trailing commas, rest targets and a raising
to_arymatches Ruby in all six head VM compiler/hash combinations; all six base combinations reproduce the defect. A separate evaluator discrepancy forfor *awith multiple yields is byte-identical on main/head and is pre-existing. - All seven source/build gates pass, including GC roots and bracket depth (155 under the unchanged 1024 budget). A harness-only ENV control reproduces the rbenv-shim mismatch on main and passes with this reference-binary change.
The clean prospective integration has exactly the tested head tree. Performance counts were not remeasured; full upstream-file/platform/resource acceptance is not claimed. Hosted build-linux is still executing, with seven macOS/reference jobs queued. Current main's core CI run 45663174315 is pending and exposes zero jobs; its separate load-path workflow has Linux success and an unassigned cancelled macOS job, not a reproduced test failure. The recorded hold_all_merges / new_failure_review_required remain active. No merge: this is not a queue-only situation with equivalent complete coverage.
284km
left a comment
There was a problem hiding this comment.
Reviewed f1a355b. No Critical / Major / Minor findings. A for loop's block has one parameter and no has_lead; both compilers' VM export now say "for", and vm_params binds it as |x| instead of |x,|. On main's VM, for x in [[1, 2], [3]] gave 1 and 3; ruby gives [1, 2] and [3]. I ran a probe on the author's build, on the evaluator and MERE_RUBY_VM=1 against ruby 4.0.10: Arrays, nil and [] elements; an each yielding 1, 2, [3, 4] and nothing; a Hash; for a, b; a Range; the loop variable after the loop; an empty loop. All identical (main's VM differs). vm_check.sh now uses $REF_RUBY_BIN (#298's Suggestion). The description has vm_corpus 956/956 on the VM, run_corpus 956/956, vm_check 246/246, the native compiler check 956 the same, and spectralnorm 614.9 → 577.9 G on the VM. git merge-tree against main: clean. The bot found nothing actionable. Merging.
On the VM, a
forloop's variable took the first element of an Array:Found while taking apart the benchmark furthest from the evaluator (note 558: the VM's speed, from the
so_*/app_*benchmarks). so_spectralnorm was 1.13x the evaluator's instructions, and the gap was itsforloop, not its calls.Cause
A for loop's block has one parameter without has_lead, which ruby binds as
|x|: an Array whole. Both compilers' export for the VM gives that parameter (lead_num) and did not say the block is a for loop's.vm_paramsread one required parameter that is notambiguous_param0as|x,|and added the*,that spreads an Array. Each turn's binding also went past the one-store path for a single parameter (blk_simple1).Change
lib/iseq_compiler_ext.rbandic/m_ic_export.mere: the export for the VM saysforin a for loop's block's parameters, afterambiguous_param0.to_ais unchanged.m_pathname_lib.mereis regenerated.vm_paramsreadsforasambiguous_param0.tools/iseq/vm_check.shruns the reference as$REF_RUBY_BIN, not rbenv's shim (vm_check.sh takes the reference ruby through tools/ref_ruby.sh (#296's review) #298's review).Numbers
VM instructions, the median of three runs alternating main and this branch:
for j in 0..249999; endChecked
vm_corpus.sh: 956 programs, 956 on the VM, 0 FAIL.run_corpus.sh: 956/956.vm_check.sh: 246/246 (one snippet added).tools/iseq/native/check.sh corpus/*.rb: 956 the same.Record:
loop/2026-11-26-stage10-vm-for-param.md.🤖 Generated with Claude Code