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

Simplifications to the state access mechanism #303

Merged
merged 4 commits into from
Jan 9, 2025

Conversation

diegonehab
Copy link
Contributor

The shadow PMAs never change once the machine is running.
No need to use the more complicated device mechanism, a read-only memory range is fine.
This allows us to use the standard "peek" for memory ranges with the Mekrle tree.
The old peek needed to use the device-state-access to build the shadow from scratch every time.
It used i-device-state-access, which needed to have read_pma_istart/read_pma_ilength.
This in turn required us to add read_pma_istart/read_pma_ilength to i-state-access.
A waste of effort for something that can simply be done in machine.cpp once and for all.

We also remove find_pma_entry from the state access.
A single implementation in interpret.cpp is enough.

Remove context from HTIF device.
This is important because it was the only device used in reproducible code that had a context.
This meant there was some gambiarra in the driver code to check if the context was nullptr.

Remove read_device and write_device from i_state_access.
The code is now in interpret.cpp.
This reduces even more the amount of code we need when implementing a new state access class.

Simplify the mock pma implementations used by different state access classes.
I think we should merge them into a single one.

@diegonehab diegonehab self-assigned this Jan 7, 2025
@diegonehab diegonehab added the enhancement New feature or request label Jan 7, 2025
@diegonehab diegonehab added this to the v0.19.0 milestone Jan 7, 2025
src/machine.cpp Show resolved Hide resolved
src/record-step-state-access.h Show resolved Hide resolved
src/find-pma-entry.h Outdated Show resolved Hide resolved
src/find-pma-entry.h Outdated Show resolved Hide resolved
mpernambuco
mpernambuco previously approved these changes Jan 7, 2025
src/replay-step-state-access.h Show resolved Hide resolved
@diegonehab diegonehab force-pushed the refactor/more-simplifications branch 2 times, most recently from cda4fbd to 8bd1b59 Compare January 8, 2025 14:27
The shadow PMAs never change once the machine is running.
No need to use the more complicated device mechanism, a read-only memory range is fine.
This allows us to use the standard "peek" for memory ranges with the Mekrle tree.
The old peek needed to use the device-state-access to build the shadow from scratch every time.
It used i-device-state-access, which needed to have read_pma_istart/read_pma_ilength.
This in turn required us to add read_pma_istart/read_pma_ilength to i-state-access.
A huge waste of effort for something that can simply be done in machine.cpp once and for all.
@diegonehab diegonehab force-pushed the refactor/more-simplifications branch 3 times, most recently from d5cb327 to dff530d Compare January 8, 2025 16:04
edubart
edubart previously approved these changes Jan 8, 2025
A single unified implementation is enough.
Remove context from HTIF device. This is important because it was
the only device used in reproducible code that had a context.
This meant there was some gambiarra in the driver code to check if
the context was nullptr.

Remove read_device and write_device from i_state_access. The code
is now in interpret.cpp. This reduces the amount of code we need
when implementing a new state access class.

Simplify the mock pma implementations used by different state access
classes. I think we should merge them into a single one.
@diegonehab diegonehab force-pushed the refactor/more-simplifications branch from 113ea9e to bec0525 Compare January 9, 2025 14:04
@diegonehab diegonehab marked this pull request as ready for review January 9, 2025 16:55
@diegonehab diegonehab merged commit bec0525 into main Jan 9, 2025
8 checks passed
@diegonehab diegonehab deleted the refactor/more-simplifications branch January 9, 2025 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants