@@ -440,7 +440,7 @@ impl<'a, C: ContextObject> JitCompiler<'a, C> {
440
440
441
441
match insn. opc {
442
442
ebpf:: LD_DW_IMM if !self . executable . get_sbpf_version ( ) . disable_lddw ( ) => {
443
- self . emit_validate_and_profile_instruction_count ( Some ( self . pc + 2 ) ) ;
443
+ self . emit_validate_and_profile_instruction_count ( self . pc + 2 ) ;
444
444
self . pc += 1 ;
445
445
self . result . pc_section [ self . pc ] = unsafe { self . anchors [ ANCHOR_CALL_UNSUPPORTED_INSTRUCTION ] . offset_from ( self . result . text_section . as_ptr ( ) ) as u32 } ;
446
446
ebpf:: augment_lddw_unchecked ( self . program , & mut insn) ;
@@ -719,7 +719,7 @@ impl<'a, C: ContextObject> JitCompiler<'a, C> {
719
719
720
720
// BPF_JMP class
721
721
ebpf:: JA => {
722
- self . emit_validate_and_profile_instruction_count ( Some ( target_pc) ) ;
722
+ self . emit_validate_and_profile_instruction_count ( target_pc) ;
723
723
let jump_offset = self . relative_to_target_pc ( target_pc, 5 ) ;
724
724
self . emit_ins ( X86Instruction :: jump_immediate ( jump_offset) ) ;
725
725
} ,
@@ -789,7 +789,7 @@ impl<'a, C: ContextObject> JitCompiler<'a, C> {
789
789
|| ( insn. opc == ebpf:: RETURN && !self . executable . get_sbpf_version ( ) . static_syscalls ( ) ) {
790
790
return Err ( EbpfError :: UnsupportedInstruction ) ;
791
791
}
792
- self . emit_validate_and_profile_instruction_count ( Some ( 0 ) ) ;
792
+ self . emit_validate_and_profile_instruction_count ( 0 ) ;
793
793
794
794
let call_depth_access = X86IndirectAccess :: Offset ( self . slot_in_vm ( RuntimeEnvironmentSlot :: CallDepth ) ) ;
795
795
// If env.call_depth == 0, we've reached the exit instruction of the entry point
@@ -814,7 +814,7 @@ impl<'a, C: ContextObject> JitCompiler<'a, C> {
814
814
if self . offset_in_text_section + MAX_MACHINE_CODE_LENGTH_PER_INSTRUCTION * 2 >= self . result . text_section . len ( ) {
815
815
return Err ( EbpfError :: ExhaustedTextSegment ( self . pc ) ) ;
816
816
}
817
- self . emit_validate_and_profile_instruction_count ( Some ( self . pc + 1 ) ) ;
817
+ self . emit_validate_and_profile_instruction_count ( self . pc + 1 ) ;
818
818
self . emit_ins ( X86Instruction :: load_immediate ( REGISTER_SCRATCH , self . pc as i64 ) ) ; // Save pc
819
819
self . emit_set_exception_kind ( EbpfError :: ExecutionOverrun ) ;
820
820
self . emit_ins ( X86Instruction :: jump_immediate ( self . relative_to_anchor ( ANCHOR_THROW_EXCEPTION , 5 ) ) ) ;
@@ -979,8 +979,7 @@ impl<'a, C: ContextObject> JitCompiler<'a, C> {
979
979
}
980
980
981
981
#[ inline]
982
- fn emit_validate_and_profile_instruction_count ( & mut self , target_pc : Option < usize > ) {
983
- let target_pc = target_pc. unwrap ( ) ;
982
+ fn emit_validate_and_profile_instruction_count ( & mut self , target_pc : usize ) {
984
983
self . last_instruction_meter_validation_pc = self . pc ;
985
984
self . emit_ins ( X86Instruction :: load_immediate ( REGISTER_SCRATCH , ( ( target_pc << 32 | self . pc ) as i64 ) ^ self . immediate_value_key ) ) ;
986
985
self . emit_ins ( X86Instruction :: call_immediate ( self . relative_to_anchor ( ANCHOR_VALIDATE_AND_PROFILE_INSTRUCTION_COUNT , 5 ) ) ) ;
@@ -1140,7 +1139,7 @@ impl<'a, C: ContextObject> JitCompiler<'a, C> {
1140
1139
1141
1140
#[ inline]
1142
1141
fn emit_syscall_dispatch ( & mut self , function : BuiltinFunction < C > ) {
1143
- self . emit_validate_and_profile_instruction_count ( Some ( 0 ) ) ;
1142
+ self . emit_validate_and_profile_instruction_count ( 0 ) ;
1144
1143
self . emit_ins ( X86Instruction :: load_immediate ( REGISTER_SCRATCH , function as usize as i64 ) ) ;
1145
1144
self . emit_ins ( X86Instruction :: call_immediate ( self . relative_to_anchor ( ANCHOR_EXTERNAL_FUNCTION_CALL , 5 ) ) ) ;
1146
1145
self . emit_undo_profile_instruction_count ( 0 ) ;
@@ -1215,7 +1214,7 @@ impl<'a, C: ContextObject> JitCompiler<'a, C> {
1215
1214
1216
1215
#[ inline]
1217
1216
fn emit_conditional_branch_reg ( & mut self , op : u8 , bitwise : bool , first_operand : X86Register , second_operand : X86Register , target_pc : usize ) {
1218
- self . emit_validate_and_profile_instruction_count ( Some ( target_pc) ) ;
1217
+ self . emit_validate_and_profile_instruction_count ( target_pc) ;
1219
1218
if bitwise { // Logical
1220
1219
self . emit_ins ( X86Instruction :: test ( OperandSize :: S64 , first_operand, second_operand, None ) ) ;
1221
1220
} else { // Arithmetic
@@ -1228,7 +1227,7 @@ impl<'a, C: ContextObject> JitCompiler<'a, C> {
1228
1227
1229
1228
#[ inline]
1230
1229
fn emit_conditional_branch_imm ( & mut self , op : u8 , bitwise : bool , immediate : i64 , second_operand : X86Register , target_pc : usize ) {
1231
- self . emit_validate_and_profile_instruction_count ( Some ( target_pc) ) ;
1230
+ self . emit_validate_and_profile_instruction_count ( target_pc) ;
1232
1231
if self . should_sanitize_constant ( immediate) {
1233
1232
self . emit_ins ( X86Instruction :: mov_mmx ( OperandSize :: S64 , REGISTER_SCRATCH , MM0 ) ) ;
1234
1233
self . emit_sanitized_load_immediate ( REGISTER_SCRATCH , immediate) ;
0 commit comments