@@ -443,7 +443,7 @@ impl<'a, C: ContextObject> JitCompiler<'a, C> {
443
443
444
444
match insn. opc {
445
445
ebpf:: LD_DW_IMM if !self . executable . get_sbpf_version ( ) . disable_lddw ( ) => {
446
- self . emit_validate_and_profile_instruction_count ( Some ( self . pc + 2 ) ) ;
446
+ self . emit_validate_and_profile_instruction_count ( self . pc + 2 ) ;
447
447
self . pc += 1 ;
448
448
self . result . pc_section [ self . pc ] = unsafe { self . anchors [ ANCHOR_CALL_UNSUPPORTED_INSTRUCTION ] . offset_from ( self . result . text_section . as_ptr ( ) ) as u32 } ;
449
449
ebpf:: augment_lddw_unchecked ( self . program , & mut insn) ;
@@ -722,7 +722,7 @@ impl<'a, C: ContextObject> JitCompiler<'a, C> {
722
722
723
723
// BPF_JMP class
724
724
ebpf:: JA => {
725
- self . emit_validate_and_profile_instruction_count ( Some ( target_pc) ) ;
725
+ self . emit_validate_and_profile_instruction_count ( target_pc) ;
726
726
let jump_offset = self . relative_to_target_pc ( target_pc, 5 ) ;
727
727
self . emit_ins ( X86Instruction :: jump_immediate ( jump_offset) ) ;
728
728
} ,
@@ -792,7 +792,7 @@ impl<'a, C: ContextObject> JitCompiler<'a, C> {
792
792
|| ( insn. opc == ebpf:: RETURN && !self . executable . get_sbpf_version ( ) . static_syscalls ( ) ) {
793
793
return Err ( EbpfError :: UnsupportedInstruction ) ;
794
794
}
795
- self . emit_validate_and_profile_instruction_count ( Some ( 0 ) ) ;
795
+ self . emit_validate_and_profile_instruction_count ( 0 ) ;
796
796
797
797
let call_depth_access = X86IndirectAccess :: Offset ( self . slot_in_vm ( RuntimeEnvironmentSlot :: CallDepth ) ) ;
798
798
// If env.call_depth == 0, we've reached the exit instruction of the entry point
@@ -817,7 +817,7 @@ impl<'a, C: ContextObject> JitCompiler<'a, C> {
817
817
if self . offset_in_text_section + MAX_MACHINE_CODE_LENGTH_PER_INSTRUCTION * 2 >= self . result . text_section . len ( ) {
818
818
return Err ( EbpfError :: ExhaustedTextSegment ( self . pc ) ) ;
819
819
}
820
- self . emit_validate_and_profile_instruction_count ( Some ( self . pc + 1 ) ) ;
820
+ self . emit_validate_and_profile_instruction_count ( self . pc + 1 ) ;
821
821
self . emit_ins ( X86Instruction :: load_immediate ( REGISTER_SCRATCH , self . pc as i64 ) ) ; // Save pc
822
822
self . emit_set_exception_kind ( EbpfError :: ExecutionOverrun ) ;
823
823
self . emit_ins ( X86Instruction :: jump_immediate ( self . relative_to_anchor ( ANCHOR_THROW_EXCEPTION , 5 ) ) ) ;
@@ -982,8 +982,7 @@ impl<'a, C: ContextObject> JitCompiler<'a, C> {
982
982
}
983
983
984
984
#[ inline]
985
- fn emit_validate_and_profile_instruction_count ( & mut self , target_pc : Option < usize > ) {
986
- let target_pc = target_pc. unwrap ( ) ;
985
+ fn emit_validate_and_profile_instruction_count ( & mut self , target_pc : usize ) {
987
986
self . last_instruction_meter_validation_pc = self . pc ;
988
987
self . emit_ins ( X86Instruction :: load_immediate ( REGISTER_SCRATCH , ( ( ( target_pc << 32 ) | self . pc ) as i64 ) ^ self . immediate_value_key ) ) ;
989
988
self . emit_ins ( X86Instruction :: call_immediate ( self . relative_to_anchor ( ANCHOR_VALIDATE_AND_PROFILE_INSTRUCTION_COUNT , 5 ) ) ) ;
@@ -1143,7 +1142,7 @@ impl<'a, C: ContextObject> JitCompiler<'a, C> {
1143
1142
1144
1143
#[ inline]
1145
1144
fn emit_syscall_dispatch ( & mut self , function : BuiltinFunction < C > ) {
1146
- self . emit_validate_and_profile_instruction_count ( Some ( 0 ) ) ;
1145
+ self . emit_validate_and_profile_instruction_count ( 0 ) ;
1147
1146
self . emit_ins ( X86Instruction :: load_immediate ( REGISTER_SCRATCH , function as usize as i64 ) ) ;
1148
1147
self . emit_ins ( X86Instruction :: call_immediate ( self . relative_to_anchor ( ANCHOR_EXTERNAL_FUNCTION_CALL , 5 ) ) ) ;
1149
1148
self . emit_undo_profile_instruction_count ( 0 ) ;
@@ -1218,7 +1217,7 @@ impl<'a, C: ContextObject> JitCompiler<'a, C> {
1218
1217
1219
1218
#[ inline]
1220
1219
fn emit_conditional_branch_reg ( & mut self , op : u8 , bitwise : bool , first_operand : X86Register , second_operand : X86Register , target_pc : usize ) {
1221
- self . emit_validate_and_profile_instruction_count ( Some ( target_pc) ) ;
1220
+ self . emit_validate_and_profile_instruction_count ( target_pc) ;
1222
1221
if bitwise { // Logical
1223
1222
self . emit_ins ( X86Instruction :: test ( OperandSize :: S64 , first_operand, second_operand, None ) ) ;
1224
1223
} else { // Arithmetic
@@ -1231,7 +1230,7 @@ impl<'a, C: ContextObject> JitCompiler<'a, C> {
1231
1230
1232
1231
#[ inline]
1233
1232
fn emit_conditional_branch_imm ( & mut self , op : u8 , bitwise : bool , immediate : i64 , second_operand : X86Register , target_pc : usize ) {
1234
- self . emit_validate_and_profile_instruction_count ( Some ( target_pc) ) ;
1233
+ self . emit_validate_and_profile_instruction_count ( target_pc) ;
1235
1234
if self . should_sanitize_constant ( immediate) {
1236
1235
self . emit_ins ( X86Instruction :: mov_mmx ( OperandSize :: S64 , REGISTER_SCRATCH , MM0 ) ) ;
1237
1236
self . emit_sanitized_load_immediate ( REGISTER_SCRATCH , immediate) ;
0 commit comments