-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
base: master
Are you sure you want to change the base?
Conversation
while (!tmp_args.empty()) | ||
{ | ||
m_pcm_queue.push_back(tmp_args.back()); | ||
tmp_args.pop_back(); | ||
} |
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.
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.)
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.
It's always 6. I tried to avoid extra internal state, but as you insist - I'll do.
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.
If it’s always exactly 6, you can just maintain a local pointer to the current position within this function, can’t you?
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.
A bit tricky as it's <=6 but done.
No description provided.