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

spu/arm64: clean up assembly code generation #12608

Merged
merged 1 commit into from
Sep 7, 2022
Merged

Conversation

sguo35
Copy link
Contributor

@sguo35 sguo35 commented Sep 4, 2022

Clean up asmjit usage so we don't unnecessarily allocate/leak memory anymore for SPURecompiler functions.

Tested with spurs test and 2 basic games and doesn't appear to cause any regressions.

@elad335
Copy link
Contributor

elad335 commented Sep 4, 2022

Hi, you mention a "leak" but the affected code is called once during program initialization. (they are static variables)
We are talking about just a few dozen bytes here which is very far away from a "leak".

@sguo35
Copy link
Contributor Author

sguo35 commented Sep 5, 2022

Hi, you mention a "leak" but the affected code is called once during program initialization. (they are static variables) We are talking about just a few dozen bytes here which is very far away from a "leak".

Neko told me to fix it after the SPU arm port was landed.

Also, some of this code is called every time we branch to a new "function". We can run out of the 256MB allocated JIT memory in some games with large SPU code size as a result of the memory bloat (some Arm code here is a lot bigger than x86 versions in code size).

@@ -1636,18 +1737,24 @@ void spu_recompiler_base::dispatch(spu_thread& spu, void*, u8* rip)

atomic_storage<u64>::release(*reinterpret_cast<u64*>(rip - 8), result);
#elif defined(ARCH_ARM64)
auto jump_instrs = build_function_asm<spu_function_t>("", [](native_asm& c, auto& args)
Copy link
Contributor

@elad335 elad335 Sep 5, 2022

Choose a reason for hiding this comment

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

Oh I see, here is the leak. I think these are the only places where it should be changed. (bytecode is much less readable and is more difficult to work with)

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 see. I've removed the other changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

And keep the rebuild_ubertrampoline changes as well.

@sguo35 sguo35 force-pushed the arm64 branch 2 times, most recently from 0f1dca9 to cd03436 Compare September 5, 2022 00:29
@sguo35
Copy link
Contributor Author

sguo35 commented Sep 5, 2022

I also readded the make_branch_patchpoint changes as that gets called quite often too.

Clean up asmjit usage so we don't unnecessarily allocate memory
anymore for SPURecompiler functions.
@Nekotekina Nekotekina merged commit a0d48c5 into RPCS3:master Sep 7, 2022
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.

3 participants