Skip to content

vm: dispatcher compiled-call prologue is duplicated 9x — extract a single helper #414

Description

@davydog187

Found during automated review of PR #405.

After the static-arity opcodes and call_self land, the compiled-closure call prologue (register-file build, vararg proto setup, 8-slot frame tuple, call_info, tick, depth check, dispatch/12 re-entry) is copy-pasted 9 times in lib/lua/vm/dispatcher.ex (~940-1290): 2 generic + 6 static-arity + call_self. Two copies already drift: @op_call_one_0 and @op_call_zero_0 inline %{callee_proto | varargs: []} instead of calling setup_vararg_proto/4 (currently equivalent).

Any call-protocol change now has 9 edit sites. Worth extracting a shared helper (or a defmacrop, though CLAUDE.md discourages macros unless warranted) once the perf stack (#400#401#403#405) settles — measured to confirm the abstraction doesn't cost the win the duplication bought.

🤖 Filed from an automated review pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions