-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
Sync dh fpu and normal fpu #2248
Conversation
@FeralChild64 this only happens if the dynamic core is using the dh fpu implementation. There are 3 different fpu code paths in dosbox, the normal core that interprets everything, the dynamic core without dh fpu that runs recompiled code but calls the normal fpu functions, and then the new dh fpu that does not share the same functions and data structures with normal core. I'm able to reproduce in windows stable release too. Regarding whether it crashes dosbox or the guest app, I guess the overflow can happen in both normal core or dynamic core. If this happens in normal core it triggers the assertion, but if it happens in dynamic core, it'll probably trigger some sort of exception in the guest app. |
Do we notify the mainline DOSBox folks and @joncampbell123 out of courtesy @kcgen when a core emulation related important fix like this one lands in our repo? |
Yup, it's rare (that we have these), but I've previously informed QBix via PM. Will do the same when we eventually merge this. Another route would be is if @finalpatch was planning to submit a .patch file to sourceforge (for SVN or 0.74.3). |
@finalpatch , all that's left is squashing all the intermediate commits down to one (I don't think we need to have this split across multiple.. it's a nice and small susinct change). |
I saw some CI check failures, but they do not seem to be build or test failures. |
I can send them a patch file for sure. But it should be easy enough for them to just apply the changes themselves, it's not very large after all. |
Are there any performance implications for other software? |
For performance profiling my enhanced DOSBENCH can be found here: |
(text quote)
@finalpatch , have you found any DOS games that cause continuous cache lookup failures or have frequently-invalidated code blocks? Maybe self-modifying code would do this? Unfortunately all of the above benchmarks never traverse this code path. I've also tested on x86-64 and ARM64 builds on native hardware using the dynamic and dynrec cores. |
I wasn't able to reproduce this with my existing copy of DOS Navigator. I re-downloaded DN from https://dnosp.com/e_index.php today, just to start with a clean slate. I grabbed the real-mode version (they start up faster and typically are smaller). Again.. couldn't reproduce it. So I tried the DPMI version, and finally hit the issue. |
@kcgen I changed the class and assignment call around There are a few other instances of |
Okay, answering my own question, we actually need to have this fpu sync around all the other Without these DOS debuggers won't be able to see FPU changes from dynamic core. After adding this, I'm now able to single step in Turbo Debugger and observe the FPU window updating in realtime on the dynamic core. |
Wonderful to see the turbo debugger working correctly now! This is the level of validation that shows this is right approach. 🚀 |
Unless you find new issues, I'm happy with the state of the PR. I'll leave it to you guys to merge it when you are ready. |
There is definitely opportunity to clean up the FPU emulation code. I don't see any good reason to have 2 completely separate FPU states. Code would be much simpler and more efficient if we just have one. |
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.
Thanks for this PR, @finalpatch, and working through the review. I learned a lot along the way - thanks for all the detailed explanations!
Oh, one last change: would be able to squash the 14 commits down to one? I think one is enough to capture this change (and provide a bisectable point). |
FYI, I ran a benchmark on DOSBox-X with Win98. You can see the results here: joncampbell123/dosbox-x#3965 (comment) |
I think you can configure github to squash merge pull requests: I do not have merge permission so it's up to you how you want to merge it. |
@rderooy Thanks for running those benchmarks. We can absorb a hit on 16-bit clean and 16/32-bit mixed code but not for 32-bit clean code because that's where the most performance demand is. I approve based on evidence provided. |
@kcgen IMHO this is a good candidate for backporting to 0.80.2 - we have no idea how many glitches or sporadic crashes this bug causes. |
We don't like using GitHub's auto-squash feature. In part because it's a derivative: it's not what you (as the author) actually put forward for merging. Instead, it creates a huge list of the all the squashed commits. In general, we want PRs to be in final shape, bisectable, and nicely named. Squashing isn't the norm, but it felt like the right granularity (for this PR) if anyone ever needs to bisect back to it. There are merge conflicts, so GitHub is blocking on my side: That's OK - I can do it manually. Here's a log (just for the record) Checkout a new local branch on the main repo to hold your commits
Import changes from your repo
Rebase your feature branch against main
Fix conflicts
Squash intermediate commits
Reformat the commit messageBefore
AfterSummarized from the PR discussion ...
Apply code formatting rules
Build and testAlso checked a UBSAN build -- all still running clean. Sign off
Perform a fast-forward merge to
|
Merge performed manually outside of Github; closing. |
@kcgen I just realise we need to move this
into Another thing is to put dh fpu related code inside a
block so that code is still compilable when it's not defined (using the old dyn fpu) See the other PR I made for X joncampbell123/dosbox-x#3969 |
Great catches, @finalpatch. |
Would you be able to apply these changes? |
I'll try and then include you for review. |
Nice work everyone! 💯 🚀 |
@finalpatch For the future:
I did the mistake of developing a feature on the main branch too, in another project - the only reason it worked was because I was left as the only contributor. |
You might want to familiarise yourself with the "Git rebase workflow" that we use @finalpatch https://www.themoderncoder.com/a-better-git-workflow-with-rebase/ |
When the dynamic core uses normal core to run instructions, we need to
This addresses #2247