• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

KarpelesLab / goro / 25336161853

04 May 2026 06:30PM UTC coverage: 6.72% (+0.008%) from 6.712%
25336161853

push

github

MagicalTux
vm: cache locals in a slot array (skip hashtable on reads)

Frame.locals is a fixed-size []*phpv.ZVal indexed by
Function.Locals position. At frame init the slots are
populated from the FuncContext hashtable via OffsetCheck
(distinguishing "exists" from "missing" — OffsetGet can't,
since ZHashTable.GetString returns a fresh ZNULL on miss).

Reads (OP_LOAD_LOCAL, OP_LOAD_LOCAL_OR_WARN, the inc/dec
helpers, OP_OP_ASSIGN_LOCAL, OP_FOREACH_STEP key/val
binding, OP_ARRAY_*_LOCAL container fetch) all go straight
to the slot — zero hashtable lookups on the hot path.

Writes go through Frame.storeLocal which updates the slot
and the hashtable. The hashtable stays authoritative for
external readers (extract/compact/debug_print_backtrace
arg lists, builtins inspecting the FuncContext, …) so
nothing observable changes.

ZHashTable.SetString dups a cached singleton ZVal before
storing — slot writes follow the same policy via the new
phpv.(*ZVal).IsCached accessor and a NewZVal(v.Value()) dup.
Without this, OP_OP_ASSIGN_LOCAL on a fresh slot ($x=5;
$x++) would later panic in DoInc when SetVal hit the cached
small-int singleton.

Bench impact (vs. AST baseline):
  Arithmetic    ~ -30%  (44M -> 31M ns)
  Fibonacci     ~ -17%  (25M -> 21M ns)
  ArrayOps      ~ -16%  (13M -> 11M ns)
  FunctionCalls ~ -16%  (20M -> 17M ns)
  StringConcat  ~ flat
phpt under GORO_VM=1: still zero new regressions.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

40 of 57 new or added lines in 4 files covered. (70.18%)

8 existing lines in 3 files now uncovered.

7662 of 114020 relevant lines covered (6.72%)

802.57 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

29.25
/core/phpctx/global-array.go


Source Not Available

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc