Skip to content
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

Enhanced MemoryAddr #4

Merged
merged 16 commits into from
Aug 26, 2024
Merged

Enhanced MemoryAddr #4

merged 16 commits into from
Aug 26, 2024

Conversation

aarkegz
Copy link
Collaborator

@aarkegz aarkegz commented Aug 20, 2024

This is what we can get if we add more bounds to MemoryAddr. I do think it's worth it.

@aarkegz aarkegz requested review from equation314 and hky1999 August 20, 2024 14:07
@aarkegz aarkegz self-assigned this Aug 20, 2024
@hky1999
Copy link
Contributor

hky1999 commented Aug 20, 2024

But I think Ord is worth it

@aarkegz
Copy link
Collaborator Author

aarkegz commented Aug 20, 2024

But I think Ord is worth it

Yes, I think so. But having (Add|Sub)(Assign)? is also good.

@hky1999
Copy link
Contributor

hky1999 commented Aug 20, 2024

But I think Ord is worth it

Yes, I think so. But having (Add|Sub)(Assign)? is also good.

I just read your do as donot by mistake, yep, they all LGTM

@aarkegz aarkegz mentioned this pull request Aug 20, 2024
memory_set/src/area.rs Outdated Show resolved Hide resolved
memory_addr/src/addr.rs Show resolved Hide resolved
memory_addr/src/addr.rs Show resolved Hide resolved
@aarkegz aarkegz requested a review from hky1999 August 23, 2024 07:36
memory_addr/src/addr.rs Show resolved Hide resolved
@@ -98,7 +92,11 @@ where
/// ```
#[inline]
pub fn size(self) -> usize {
usize!(self.end) - usize!(self.start)
if self.is_empty() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there an if?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To handle empty ranges with start > end. I think we should make it clear what it means and what the behavior these methods should have when start > end. Maybe just reject them with a checked new and write a new_unchecked?

@aarkegz
Copy link
Collaborator Author

aarkegz commented Aug 25, 2024

I think this and #3 are mergeable as the behavior of the structures and functions has been clarified by docs and tested by doc and unit tests now. @hky1999 @equation314

memory_addr/src/range.rs Show resolved Hide resolved
@aarkegz aarkegz merged commit 5f526d6 into update_memory_set Aug 26, 2024
10 checks passed
@aarkegz aarkegz deleted the enhanced_memory_addr branch August 26, 2024 03:43
aarkegz added a commit that referenced this pull request Aug 26, 2024
* use local `memory_addr` for `memory_set`, update `memory_set`, move generic params of mapping structures into `MappingBackEnd` as associated types

* fix docs

* Enhanced `MemoryAddr` (#4)

* demo: what if we add more bounds to `MemoryAddr`

* remove arithmetic bounds for `MemoryAddr`, add some provided methods

* rename `MemoryAddr::sub_addr` to `MemoryAddr::offset_from`

* remove a wrong bug todo

* add two more functions to `VirtAddr`

* add `add` and `sub` to `MemoryAddr`

* clarify the behavior of arithmetic operations of `MemoryAddr`, add detailed unit tests

* formatted

* add `overflowing_add/sub` to `MemoryAddr`

* add `checked_add/sub` to `MemoryAddr`

* `AddrRange` candidate B: allow malformed ranges and treat them as empty

* doc and tests improvement for `MemoryAddr` and `AddrRange`

* update `PageIter`

* formatted

* even more tests, ready to merge

* switch to `AddrRange` candidate A

* add `sub_addr` series to `MemoryAddr`, improve panic messages in `MemoryAddr` and `AddrRange`

* some small code improvements

* bump version to 0.3.0

* update function calls about address arithmetic operations in `MemoryArea`s and `MemorySet`s

* loosen memory area shrink check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants