Harden xtensa call_primitive_last and align encode_rrr with the ISA#2361
Harden xtensa call_primitive_last and align encode_rrr with the ISA#2361pguyot wants to merge 1 commit into
Conversation
|
AMP, ever pedantic - pick and choose: PR Review:
|
call_primitive_last only supports args of the form [_, jit_state | _] (the windowed-ABI tail call rewrites the second argument to jit_state_tail_call). Reject every other shape in the function head, before any register allocation or stream writes, so a scratch-exhausting argument list fails with a descriptive error rather than an opaque first_avail/1 function_clause. Also rename encode_rrr's op1/op2 parameters and align the RRR comments (including SLLI) with the Xtensa ISA field order; emitted bytes are unchanged, verified by the jit_xtensa_asm round-trip tests (73) and codegen tests (145). Signed-off-by: Paul Guyot <pguyot@kallisys.net>
4e42b57 to
61aab80
Compare
petermm
left a comment
There was a problem hiding this comment.
PR Review: 61aab805e — Harden Xtensa tail calls and align RRR naming
Verdict: approved
No unresolved P0–P3 findings. The force-pushed commit correctly addresses both findings from the review of obsolete commit 4e42b57c3, without changing supported code generation.
Resolved findings
P2 resolved: unsupported arguments are rejected before allocation
call_primitive_last/3 now matches [_, jit_state | _] in the supported function head. Every other shape reaches the fallback clause before parameter-mask calculation, first_avail/1, argument rewriting, or stream access:
call_primitive_last(_State, _Primitive, Args) ->
error({unsupported_call_primitive_last_args, Args}).This preserves the caller's original Args in the diagnostic. The new regression test uses [ctx, a9, a7, a6, a5, 0], which genuinely exhausted every available register under the old ordering: six parameters reserve a10..a15, while the explicit source registers reserve a9, a7, a6, and a5.
Supported callers and their generated instruction streams are unchanged.
P3 resolved: SLLI uses the ISA field name
The SLLI field description now identifies bits [19:16] as op1, consistently with the general RRR layout and encode_rrr/6 parameter names.
Verification
- Oracle follow-up review: merge, with no unresolved P0–P3 findings.
git diff --check HEAD^ HEAD: passed.eunit:test(jit_xtensa_asm_tests, [verbose]): 73 tests passed.eunit:test(jit_xtensa_tests, [verbose]): 145 tests passed, includingcall_primitive_last_unsupported_args_test/0.
The first codegen test invocation loaded a stale pre-force-push jit_xtensa.beam and failed the new regression test with the old first_avail/1 behavior. Rebuilding the jit_emu target recompiled jit_xtensa.erl; the complete 145-test suite then passed. This was a local incremental-build artifact, not a source defect.
Add an explicit error clause for the currently unreachable non-jit_state argument shape. Rename encode_rrr's op1/op2 parameters and comments to match the ISA field order; emitted bytes are unchanged.
These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).
SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later