-
Notifications
You must be signed in to change notification settings - Fork 167
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
Compiles advice injectors down to Emit
#1581
Compiles advice injectors down to Emit
#1581
Conversation
0e738df
to
91d8b85
Compare
91d8b85
to
6487a01
Compare
6487a01
to
8cab631
Compare
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.
b765077
to
de02088
Compare
Last thing we could do in this PR is rename |
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! I left some comments inline. Most are pretty small and the bigger once can be done in future PRs.
Once this and #1572 are merged (I would probably first merge this into #1572 and then merge #1572), we can close #1457. But let's also create an issue describing the remaining work on this (e.g., getting rid of AdviceInjector
enum, moving some events to the standard library, coming up with a mechanism for handling events in an extensible manner etc.).
processor/src/operations/sys_ops.rs
Outdated
if let Some(advice_injector) = AdviceInjector::from_event_id(event_id) { | ||
self.handle_advice_injector(advice_injector, host) | ||
} else { | ||
host.on_event(self.into(), event_id) | ||
} |
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.
Not for this PR, but in the future we should probably split event_id
into source and ID where source identifies a library (e.g., source=0
for the system events, source=1
for the standard library etc.). We've discussed some of this in #1457, but may be good to create a separate issue once #1457 is closed.
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.
My issue with this though is that it reduces the number of "non-colliding libraries" from potentially 2^32 down to 2^16. Also, most libraries will probably only define a few events, wasting ~2^16 bits of unused event IDs (but still allocated to them).
I figured it to be better to just have libraries subscribe to the set of event IDs they need, (which the host can track with a BTreeMap<u32, EventHandler>
). Then, we're actually very unlikely for libraries to define the same event ID (assuming all libraries properly generate their event IDs randomly).
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.
Let's discuss this in a follow-up issue. For example, we could still have 32-bit space for libraries and then within each library we could have a 16-bit space for event IDs.
FalconSigToStack, | ||
} | ||
|
||
impl AdviceInjector { |
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.
Probably not for this PR, but I'm wonder if we actually need the AdviceInjector
enum at all. I think pretty much in all cases it can be replaced with Operation::Emit(EVENT_ID)
and the code would be just as readable.
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 renamed AdviceInjector
to SystemEvent
, and I don't think it's so bad to have an enum. For example, in handle_system_event
, we match on an enum instead of u32
constants, so if we add a SystemEvent
, we'll get a compile error there (instead of nothing)
…le, and rename AdviceInjector
025ed0d
to
b82f2f1
Compare
19cc0e7
into
plafer-1457-refactor-host-advice-provider
…tors-emit Compiles advice injectors down to `Emit`
Closes #1457
Left to do:
AdviceInjector
toNativeEvent
(orNativeAdviceEvent
?)