-
Notifications
You must be signed in to change notification settings - Fork 180
Refactor - Make FunctionRegistry
accept dense indexes
#617
Conversation
} | ||
} | ||
|
||
impl<T: Copy + PartialEq + ContextObject> FunctionRegistry<BuiltinFunction<T>> { |
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.
I still want to add a few unit tests for these functions.
pub fn keys(&self) -> Box<dyn Iterator<Item = u32> + '_> { | ||
match self { | ||
FunctionRegistry::Sparse(map) => Box::new(map.keys().copied()), | ||
FunctionRegistry::Dense(vec) => Box::new(1..=(vec.len() as u32)), |
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.
Needs to filter out the tombstones
.map(|(key, (name, value))| (*key, (name.as_slice(), *value))), | ||
), | ||
FunctionRegistry::Dense(vec) => { | ||
Box::new(vec.iter().enumerate().map(|(idx, value)| { |
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.
Needs to filter out the tombstones
@@ -350,6 +420,41 @@ macro_rules! declare_builtin_function { | |||
}; | |||
} | |||
|
|||
/// Tombstone function for when we call an invalid syscall (e.g. a syscall deactivated through a |
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.
"when we call" makes it sound like runtime when it is about verification instead. Maybe "for leaving gaps in a sparse function registry"
vm.context_object_pointer | ||
.consume(vm.previous_instruction_meter - vm.due_insn_count); | ||
} | ||
vm.program_result = ProgramResult::Err(EbpfError::SyscallError(Box::new( |
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.
could also add a debug_assert!(false);
to indicate that this is never supposed to actually run.
The idea behind this PR is to allow the registration of syscalls with integers.