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

KarpelesLab / goro / 26351198757

24 May 2026 03:51AM UTC coverage: 12.46% (+0.03%) from 12.429%
26351198757

push

github

MagicalTux
vm: lower by-ref/named/spread calls to dedicated ByExprs opcodes

Previously, function/method calls whose argument shape required
the full ctx.Call binding pipeline (by-ref params, named args,
spread) were lowered to OP_CLASS_CONST / OP_TRY_FINALLY — generic
AST.Run() delegation that ran the entire runnableFunctionCall /
runObjectFunc / runnableFunctionCallRef node as one opaque step.

Replace that with three dedicated opcodes that hand the raw
argument-expression list to ctx.Call:

  - OP_CALL_USER_BY_EXPRS:    foo($a, $b, ...)
  - OP_OBJECT_CALL_BY_EXPRS:  $obj->method($a, $b, ...)
  - OP_CALL_INDIRECT_BY_EXPRS: $f($a, $b, ...)

The arg expressions live in a new Function.SubArgs slice (parallel
to SubASTs / SubFns) so the opcode only carries the SubArgs index.
At runtime, each handler resolves its callable (same CallableCache
hookup as OP_CALL_USER, same ResolveCallable as OP_CALL_INDIRECT,
same method-lookup as OP_OBJECT_CALL) then calls ctx.Call(...,
exprs, ...), which evaluates each expression with by-ref binding,
named-arg reordering, and spread expansion — the path the AST
runner's runnableFunctionCall.Run already takes.

For OP_OBJECT_CALL_BY_EXPRS, extract a sibling helper
CallInstanceMethodByExprs in core/compiler/dispatch.go that
mirrors CallInstanceMethod byte-for-byte; only the terminal call
switches from ctx.CallZVal to ctx.Call so by-ref params bind
correctly. The __call magic-method fallback still uses ZVal args
(the magic array needs them), so the helper evaluates exprs
up-front for that branch only.

emit_call.go's emitFunctionCall and emitFunctionCallRef, and
emit_object.go's emitObjectFuncCall, now route the
by-ref/special-args/writable-arg cases through these opcodes
instead of emitCallViaAST. Stmt-context drops the result with
OP_POP; OP_REFRESH_SLOTS follows each call so subsequent slot-
cache reads see any caller-local mutations from a by-ref param.

Smoke tests pass: sort/array_pop/preg_match by-ref builtins,
user-function by-... (continued)

113 of 284 new or added lines in 5 files covered. (39.79%)

35 existing lines in 4 files now uncovered.

14725 of 118174 relevant lines covered (12.46%)

2579.45 hits per line

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

22.0
/core/phpobj/zobject.go


Source Not Available

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

© 2026 Coveralls, Inc