-
Notifications
You must be signed in to change notification settings - Fork 161
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
Refactor Host
and AdviceProvider
#1572
Conversation
d27cb3d
to
c21c8ba
Compare
164b6c3
to
8af6358
Compare
c21c8ba
to
90619ec
Compare
8af6358
to
2f9669a
Compare
2b49880
to
b7e9d44
Compare
2f9669a
to
592414f
Compare
3afd7d0
to
cb51a16
Compare
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.
Thank you! Not a full review, but I left a couple of small comments inline.
More generally, I'd like to understand what is the overall plan for the refactoring. Depending on how we go, it seems to me that a subsequent PR may need to reverse many of the changes in this PR.
For example, I'm imagining that Host::on_event()
method will handle the actual dispatch of advice injectors. It could look something like:
fn on_event(
&mut self,
process: ProcessState,
event_source: u32,
event_id: u32
) -> Result<(), ExecutionError> {
let handler = self.get_event_handler(event_source_id)?;
handler.process(event_id, process, self.advice_provider_mut())
}
If we go this way, instead of removing individual advice injector functions, we'd remove the corresponding functions from the AdviceProvider
trait. This would make the AdviceProvider
trait pretty general (i.e., all injector functionality would be defined separately, while the trait will contain mostly "required" methods).
fn on_debug( | ||
&mut self, | ||
_process: ProcessState, | ||
_options: &DebugOptions, | ||
) -> Result<HostResponse, ExecutionError> { | ||
) -> Result<(), ExecutionError> { |
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.
Should we change &mut self
to just &self
here? The thought is that debug
decorators should not modify the state of the host. But maybe there is a good reason not to do that.
Also nit: I'd probably name the parameters process
and options
and add a clippy exception to this method (this way it will look nicer in docs).
/// Handles the trace emitted from the VM. | ||
fn on_trace( | ||
&mut self, | ||
_process: ProcessState, | ||
_trace_id: u32, | ||
) -> Result<HostResponse, ExecutionError> { | ||
fn on_trace(&mut self, _process: ProcessState, _trace_id: u32) -> Result<(), ExecutionError> { |
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.
Same comment as above.
I saw this PR as a cleanup that we'd want no matter ultimate direction of the subsequent PR. The main contribution is to remove the Then the Finally I inlined all the
That's fine, I don't think this undoes any of the changes here - just more moving things around.
I agree with this direction - I'd like the |
cb51a16
to
f40dffc
Compare
Also renames the variant to `FalconSigToStack`
…eToStack` In preparation for converting advice injectors to instructions. This parameter was never used, and is not crucial - the caller can always put the key on top of the stack before calling this injector.
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.
Looks good! Thank you! Let's merge this together with #1581.
…le, and rename AdviceInjector
…tors-emit Compiles advice injectors down to `Emit`
19cc0e7
to
cfd166e
Compare
Builds on #1571
A round of refactoring to make the PR that addresses #1457 more self contained.