test(jit): add x86_64 JIT unit test suite#151
Conversation
Add a RISC-V 64-bit JIT compiler (RiscV64Compiler) based on the existing x86_64 JitCompiler pattern. The backend supports the full eBPF instruction set for 64-bit RISC-V targets, using a three-field relocation scheme (pc_locs / jumps / special_targets) consistent with the existing x86_64 compiler. Refactor JitMemory::new() to use #[cfg(target_arch)] dispatch so both x86_64 and riscv64 backends coexist. Make the jit module public so users can call JitMemory::new() directly for custom executable memory control, which is required for integration into OS kernels or custom runtimes. The module remains private on Windows where executable memory allocation is not supported.
Add a new AArch64 JIT compiler (Aarch64Compiler) that translates eBPF bytecode to native AArch64 machine code. The backend follows the same pattern as the existing RiscV64Compiler: - Single-pass compilation with pc_locs/jumps/special_targets relocation - All A64 instruction encodings (ADD/SUB/AND/ORR/EOR/MADD/UDIV, UBFM/SBFM for shifts, LDR/STR variants, STP/LDP for frame management, conditional and unconditional branches) - BPF_END handled via native REV16/REV32/REV64 instructions - Full ALU32/ALU64, LDX/ST/STX, JMP32/JMP64, CALL, and EXIT support - Register mapping: BPF R0-R5 → x0-x5, BPF R6-R9 → x19-x22, BPF R10 → x25 - Frame: 512-byte BPF stack + 64-byte callee-saved area (x19-x22,x25,x29,x30) Integrated into JitMemory::new() via #[cfg(target_arch = "aarch64")] dispatch, matching the existing x86_64 and riscv64 patterns.
Add 6 unit tests covering ALU ops, BPF_END byte swap, unconditional jump, memory load/store, and prologue/epilogue sequences.
42de960 to
2d298ee
Compare
|
|
Thank you for the detailed feedback, and apologies for the late response and the Chinese descriptions. I have reorganized everything into a single PR with 3 commits: #152. The stacked PRs (#148-151) have been closed. To address your specific concerns:
Please take a look at #152 when you get a chance. |
问题
当前 JIT 后端没有单元测试,无法在 CI 中验证 x86_64 代码生成的正确性。
变更内容
测试用例
测试基础设施
验证
cargo test --lib 全部 123 测试通过,cargo clippy 无警告。
依赖
本 PR 包含 #148、#149、#150 的提交,应在 #150 合并后审查。