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

cpu/kl1839vm1.cpp: Updated save state #13303

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

holub
Copy link
Contributor

@holub holub commented Jan 31, 2025

No description provided.

Comment on lines 782 to 786
while (!tmp_args.empty())
{
m_pcm_queue.push_back(tmp_args.back());
tmp_args.pop_back();
}
Copy link
Member

Choose a reason for hiding this comment

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

Is there any chance this can cause m_pcm_queue to grow beyond six items? Because if it can, it will break save states.

Registering a std::vector for save states saves the size/address of the storage at the time it’s registered. If you do anything that causes it to be resized later, it breaks, because the new size won’t be saved/restored, and if the storage was reallocated, the address won’t be updated. To be honest, I think allowing std::vector to be registered for save states was a mistake, given the pitfalls.

If the PCM queue always has a size of six, you can use an array of some kind. If the size never exceeds six but is variable at the time you return to the scheduler, you can use an array and store the size or start/end separately. (Of course, if the PCM queue is always empty when you return to the scheduler, you don’t actually need to save it, and you can add an assert to check that it’s empty when exiting the execute loop.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's always 6. I tried to avoid extra internal state, but as you insist - I'll do.

Copy link
Member

Choose a reason for hiding this comment

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

If it’s always exactly 6, you can just maintain a local pointer to the current position within this function, can’t you?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A bit tricky as it's <=6 but done.

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.

2 participants