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

Avoid System::GetInstance() and ppcState global in Jit64 and CachedInterpreter. #11677

Merged
merged 3 commits into from Mar 25, 2023

Conversation

AdmiralCurtiss
Copy link
Contributor

No description provided.

@AdmiralCurtiss AdmiralCurtiss force-pushed the deglobal-jit branch 4 times, most recently from 72eb8b0 to e67f4e5 Compare March 21, 2023 03:23
@@ -9,11 +9,10 @@

// We offset by 0x80 because the range of one byte memory offsets is
// -0x80..0x7f.
#define PPCSTATE(x) \
MDisp(RPPCSTATE, (int)((char*)&PowerPC::ppcState.x - (char*)&PowerPC::ppcState) - 0x80)
#define PPCSTATE(state, x) MDisp(RPPCSTATE, (int)((char*)&(state).x - (char*)&(state)) - 0x80)
Copy link
Member

Choose a reason for hiding this comment

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

Any reason why you can't use something like offsetof here? We don't actually need to know where in memory the struct is when calculating this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see why not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

MSVC has no problems with this, but GCC unfortunately does.

/buildbot/pr-ubu-x64/build/Source/Core/Core/PowerPC/Jit64/Jit_SystemRegisters.cpp:23:29: error: ‘field’ is not a constant expression
   23 |   return PPCSTATE(cr.fields[field]);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've reverted the change again but if you want to experiment it's here: https://github.com/AdmiralCurtiss/dolphin/tree/deglobal-jit-offsetof

Copy link
Member

Choose a reason for hiding this comment

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

Oh, I see. Come to think of it, we made a special helper for this in JitArm64 for this reason:

#define PPCSTATE_OFF_CR(i) PPCSTATE_OFF_ARRAY(cr.fields, i)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that should work... lemme try that here too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems to work.

@AdmiralCurtiss AdmiralCurtiss force-pushed the deglobal-jit branch 4 times, most recently from df313c2 to 31204ee Compare March 21, 2023 21:18
@AdmiralCurtiss
Copy link
Contributor Author

Poke?

@AdmiralCurtiss AdmiralCurtiss merged commit 6b44947 into dolphin-emu:master Mar 25, 2023
14 checks passed
@AdmiralCurtiss AdmiralCurtiss deleted the deglobal-jit branch March 25, 2023 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants