-
Notifications
You must be signed in to change notification settings - Fork 160
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
Memory: Create newtype ContextId
#1117
Conversation
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! Totally agree with the motivation of the PR (and also think it would be a good idea to have a special type for memory address - though, probably in a different PR). A few preliminary comments:
- I think a single
ContextId
type will probably suffice. Specifically, I don't think we need another type forMemoryContextId
. I would also put the definition ofContextId
into/src/system/mod.rs
rather than into memory chiplet. - I don't think we need to implement arithmetic operations on
ContextId
. As far as I remember, we never actually add/subtract contexts. - We usually try to reduce the number of non-dev dependencies as much as possible. So, I would probably manually implement
Display
,Into
etc. traits onContextId
rather than adding an extra dependency.
The only arithmetic we do is a subtraction here. For now I'll implement only I applied all the other requested changes! |
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! Looks good! I left a few small comments inline. Once these are addressed, we can merge.
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.
All looks good! Thank you! I left one small nit inline. After this, let's squash the commits and merge.
* ContextId type * propagate MemoryContextId * fix tests * MemoryContextId -> ContextId * move definition * Remove derive-more dependency * fix repl * fmt * docstring * import newline * Remove `Sub` from `ContextId` * blank line * section name change * blank line * use `ContextId::root()` * fmt * memory context -> execution context
* ContextId type * propagate MemoryContextId * fix tests * MemoryContextId -> ContextId * move definition * Remove derive-more dependency * fix repl * fmt * docstring * import newline * Remove `Sub` from `ContextId` * blank line * section name change * blank line * use `ContextId::root()` * fmt * memory context -> execution context
Creates the
ContextId
type instead of usingu32
everywhere. This makes the code easier to understand to a newcomer; e.g. types such as(u32, u32, u32)
make understanding the code harder. And this newtype will also prevent bugs which e.g. use the context ID as an address (who's also au32
).I suggest we also introduce a newtype for memory
Address
.