regcheck

command
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Command regcheck generates engine/interp_run_regcheck.go, the checked build of the interpreter loop: a copy of engine/interp_run.go whose run checks every access to a frame's registers. The fast run indexes them through an array with the register operands and no bounds checks (engine/interp.go, window), relying on bytecode.VerifyRegisters and bytecode.RegisterSpans; the copy compares each access with the layout RegisterSpans gives the instruction being run (or with the registers of the handler being entered), with NumRegs, and with the stack the window was taken from, and each pc it dispatches with the instruction starts of VerifyRegisters' walk, so a layout row that leaves out a register run touches, an opcode without a row, a window run kept across a move of the stack, or a jump into an instruction fails there (engine/regcheck.go). The generator refuses a run that uses its window other than by index, which the copy could not check.

It is a copy rather than a variant of the same source because run's register allocation is fragile: the fast build stays the source as it is written. The copy builds with -tags moejsregcheck and the original without; TestGenerated keeps the copy current.

Usage (from engine/, see the go:generate line in interp_run.go):

go run ../internal/gen/regcheck [-in interp_run.go] [-out interp_run_regcheck.go]

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL