-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix - test_code_length_estimate() #4
Conversation
3cf48f4
to
7b01ed7
Compare
for sbpf_version in [SBPFVersion::V0, SBPFVersion::V3] { | ||
println!("opcode;machine_code_length_per_instruction;assembly"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this for debugging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It enables one to run the test with --nocapture
and get a CSV of the machine_code_length_per_instruction
.
}; | ||
for pc in 0..INSTRUCTION_COUNT { | ||
prog[pc * ebpf::INSN_SIZE] = opcode; | ||
prog[pc * ebpf::INSN_SIZE + 1] = registers; | ||
prog[pc * ebpf::INSN_SIZE + 2] = 0xFF; | ||
prog[pc * ebpf::INSN_SIZE + 3] = 0xFF; | ||
let offset = 7_u16.wrapping_sub(pc as u16); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this subtraction supposed to create randomness?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is for having relative jump offsets in conditional branches. This way some point forward and others backward. Otherwise they would be -1
and always point to themselves.
src/jit.rs
Outdated
@@ -1900,12 +1912,19 @@ mod tests { | |||
(machine_code_length_per_instruction + 0.5) as usize |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The floating point division and the 0.5 addition aren't necessary here.
7b01ed7
to
ae750f7
Compare
No description provided.