feat(vm): count a one-pointer retain or release in the loop (#164) #305
Loading…
Reference in a new issue
No description provided.
Delete branch "loop/164-retain-release-instruction"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Part 2 of #164, now that the published seed torb-seed-5f22f071d02f (nightly-20261010) knows
Machine.countUp/Machine.countDownfrom part 1 (d43017cd, PR #239).What
compiler/src/backend/bytecode/emit.trb,countedPointerOf): akernel retain/kernel releasewhose value shape is one counted word that holds its block (no inline variant, no nested variant) carriesB= register of that word andC= 1 (retain) / 2 (release) in the head. Every other kernel instruction keepsB = C = 0, so older program text runs as before and the format staystorb-bytecode-1.compiler/src/vm/interpret.trb,.Kernelarm):C == 1triesMachine.countUp,C == 2triesMachine.countDownon the register's word and skips the tail when the native did the whole work; otherwise the kernel call runs exactly as today (shared block, last count with destructor, count of zero, open sandbox).compiler/tests/bytecode.test.trb): every retain/release of a one-pointer shape is marked with its register and direction, an inline variant's is not.Measurement
This is the code measured as the "natives" form in PERFORMANCE.md 9.12 (run 419, reference commit
e6468e2donloop/164-measure2):chain-walk1.16x faster,list-iterate1.06x,map-count1.02x, fibonacci/cons-stack/closures level. Numbers for VM.md section 8 are carried by #165.Closes #164
d2bcebcd03e75be78ca59e2b8c62aab76eaeab17b76eaeab175790cc30865790cc3086141d0aee2d141d0aee2db4a6ba9107Approved at
b4a6ba91. CI green on this head (bootstrap, tier A/B, conformance, pdisc, C parity).(6, 6, 1)) and the zero mark for an inline variant's field read; the loop path is exercised by tier A/B and the leak gate.countedPointerOfmirrors the kernel's retain/release (torb_machine_retain_group: first word, onlyNestedexcluded),pointeris range-checked againstlargestOperand, and the loop falls back to the kernel on everyfalse(shared, last count, zero count, open sandbox), so destructor queue and live-block counter see what they saw. Skipping the tail withpc + 1 + amatches the kernel arm.B/Cwere unused (0) forKernel, older program text still runs through the kernel,torb-bytecode-1unchanged.Non-blocking:
retainsOffilters onRetain); the release mark (C= 2) has no direct assertion. A one-line extension toReleasewould pin it in the format test as well.