Removes anonymous lambda usage from 32-bit syscalls#4899
Removes anonymous lambda usage from 32-bit syscalls#4899Sonicadvance1 wants to merge 12 commits intoFEX-Emu:mainfrom
Conversation
How is this related? Lambda expressions decay to function pointers, so I would expect them to be equivalent to defining free functions in that sense. |
The act of them being a lambda or function doesn't matter in this case. It's the act of them being anonymous being the issue since I need the symbols visible for the dispatch arrays. |
Ah, yeah that sounds reasonable. |
|
How far off is a full PR that enables 32-bit/64-bit table switching? I think it would be easier judge the change as a whole than looking at preliminary refactors. |
7e3f3bc to
3d02bbc
Compare
Main thing is pushing all these functions in to the C namespace, that way we can use C symbol non-mangling to take advantage of variadic function signatures to mangle them in to constexpr tables. extern "C" {
auto fex_exit (FEXCore::Core::CpuStateFrame* Frame, ...) -> uint64_t;
}
auto Syscalls_32 = []() {
std::array<SyscallHandler::SyscallFunctionDefinition, 512> Array {{
{}, // TODO: restart_syscall.
{{.PtrVariadic = &fex_exit}, 2}
// TODO: Remaining 510 syscalls.
}};
return Array;
}();Generate a table for 64-bit and 32-bit, and then runtime will select which jumptable to use depending on if the entrypoint is 32-bit or 64-bit. Saving 8KB of generated memory allocations per process, and removing an insignificantly small startup cost. That's as far as I've gotten before review happened. Alternative reality, just make it |
|
I think it's still unclear to me why all this needs to happen at compile-time instead of using an incrementally (runtime-)populated table during FEX startup. A free saving of 8KiB would be nice, but also perhaps not the best guiding metric to design code around. |
94ed8f2 to
f0a4c7b
Compare
f0a4c7b to
a25d6d0
Compare
5f2f060 to
2d1f59e
Compare
2d1f59e to
7f263f4
Compare
b1cb431 to
14b5213
Compare
416bad4 to
8047bdd
Compare
8047bdd to
f913dde
Compare
f913dde to
1a95fea
Compare
1a95fea to
263973e
Compare
neobrain
left a comment
There was a problem hiding this comment.
(highlighting pending discussions since our PR list is getting cluttered by stalled PRs)
263973e to
2c67c3a
Compare
|
There's 3 of these changesets that have been sitting in the pull request list for half a year now (on top of the 4 |
2c67c3a to
4558659
Compare
These need to not be anonymous, so just remove the lambdas entirely.
This is the first step towards syscall dispatcher tables being constexpr and supporting both 32-bit and 64-bit tables being executable inside the same process.
NFC.