Repository navigation
VM: a number's % & | ^ << >> ** without a scope - #301
Conversation
vm_num_bin_ok named + - * / < <= > >= only, so a Bignum's & or | went through vm_scoped and the parser's EBin made in it. For a number on the left the EBin arm reaches eval_bin_prim the same way for these, so they are answered in vm_call as the others are. so_meteor_contest on the VM: 1,208.0 -> 1,142.0 G instructions (the evaluator: 1,134.1).
There was a problem hiding this comment.
Reviewed head 69c7c2a7f8981c9ab8fb7ddce96724d79ea0b32e against current main 1a3380b0e5738ee3ed4436c1eb94843e94ac9676. The prospective merge tree equals the reviewed head. No new actionable findings.
The whitelist extension keeps the existing dispatch guards and primitive implementation. Corpus 828 usefully covers Bignum board operations, refusals, an override and a refinement.
Validation on Darwin arm64:
- Fresh ordinary O2 head build using pinned Mere
9dec2ff687a08433247dbdb7729bc19c8522e538and mgz661a01d8bb68f5acd68e3192bd47f081d179c436. For the base comparison, reused the previously built O2 main binary after verifying all tracked files and dependency sources are byte-identical to current main. - Full VM corpus: 956/956, no fallback, failure or fallback-list discrepancy. Strict ISeq checks: 245/245.
- 33 focused corpus files: 264/264 comparisons match Ruby 4.0.10 across base/head, evaluator/VM and hash-index on/off, with GC-tight enabled.
- 49 additional operator/type and dispatch probes: 392 executions preserve the corresponding base results exactly; eight exception/recovery executions also preserve base results. All 50 added probe programs are accepted by the VM. Existing Ruby discrepancies in the wider probes remain unchanged and are not introduced by this PR.
- Source checks for duplicate/dead definitions, GC roots, method writes, namespaces and name lengths pass. Emitted C nesting is 155 under the unchanged 1024 limit.
Performance figures were not independently remeasured. Full original upstream-file/resource/platform acceptance is not established by these focused checks. The pre-post check showed the Linux core build and macOS Delegation/URI and Upstream gem tests still running; macOS/reference builds and other macOS jobs were queued, with downstream coverage incomplete. The recorded all-merge hold remains active, so I am not merging or applying the runner-queue exception. Historical failure evidence is preserved.
284km
left a comment
There was a problem hiding this comment.
Reviewed 69c7c2a. No Critical / Major / Minor findings. vm_num_bin_ok now also lets % & | ^ << >> ** take the VM's direct path when both operands are plain numbers and no hook or refinement is active, matching the evaluator's EBin arm. Bignum board & mask no longer goes through a scope and the parser (so_meteor_contest 1,208.0 → 1,142.0 G on the VM). I ran corpus 828 and a probe on the author's build, on the evaluator and MERE_RUBY_VM=1 against ruby 4.0.10: % with negatives and Floats, & / | / ^ with Bignums, shifts by large and negative amounts, ** with negative, Float and huge exponents, ZeroDivisionError, a redefined Integer#& (then restored), and Rationals. All identical. The description has vm_corpus 956 on the VM / 0 FAIL, run_corpus 956/956 and vm_check 245/245. The Float ^ / << / >> exception-class difference is pre-existing on both engines and recorded. git merge-tree against current main (with #300): clean. The bot found nothing actionable. Merging.
On the VM, a Bignum's
&or|(and%,^,<<,>>,**) went through a scope and the parser'sEBininstead of being answered where+and<are.Found while taking apart the benchmarks furthest from the evaluator (note 558). so_meteor_contest was 1,208 G instructions on the VM against the evaluator's 1,134 G. Its search tests and joins boards, which are Bignums:
board & cmask == imask,board | mask.Cause
vm_callanswers a send of two numbers and an operator without a scope whenvm_num_bin_oksays the evaluator's EBin arm would reacheval_bin_primwith nothing before it taking the call: no TracePoint, refinement, undef or alias of the operator, and no operator of the program's own. It named only+ - * / < <= > >=. Two Integers in a Fixnum's range are answered before it (int_fast_op). A Bignum's&went tovm_scoped: a scope from the pool, a fail handler, a region, and the parser'sEBinmade in it.For a number on the left, the EBin arm reaches
eval_bin_primthe same way for% & | ^ << >> **as for the operators already named. The arms before it that look at the operator are for Strings, Arrays, Ranges and objects.Change
vm_num_bin_oktakes% & | ^ << >> **too. The checks and the call are unchanged.Numbers
VM instructions, the median of three runs alternating main and this branch:
x = (b & c == 2), a Bignum b, 200,000 turnsx = b | c, the sameChecked
Integer#&and a refinement ofInteger#|. It matches ruby on both executions.vm_corpus.sh: 956 on the VM, 0 FAIL.run_corpus.sh: 956/956.vm_check.sh: 245/245.Recorded, not changed:
2.5 ^ 3,2.5 << 3and2.5 >> 3raise StandardError "mere-ruby: ^ type error" on both executions, as on main. Ruby raises NoMethodError.Record:
loop/2026-11-26-stage10-vm-number-bit-operators.md.🤖 Generated with Claude Code