TASEmulators / TASEmulators/BizHawk

AOT Compilation Support

Open
#3,768 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

App: EmuHawk Meta re: Multiplatform Request: Feature/Enhancement
Dominant language
C#
Stars
2.8k
Forks
468
PR merge metrics
No merged PRs in 30d

Description

Something to look at wrt .NET6 (or more I guess really .NET 7/8; see #1415). This could be required for some platforms in a moonshot future (iOS/iPad/Apple TV support, lol) and very good for a WASM build due to performance. Perhaps this would be more performant for us due to p/invoke often being used for emulation?

This however has several limitations:

  • Blocked by #3767
  • No dynamic loading
    • Similar to the trimming limitation, but this just outright disallows dynamic loading from working at all. External Tools would have to be re-worked to not rely on .NET dynamic assembly loading at all, or simply be unavailable for use.
  • No run-time code generation
    • i.e. Reflection.Emit
    • Used in SettingsUtil.cs, BinaryQuickSerializer.cs, BizInvoker.cs, BizInvokeUtilities.cs, and BizExvoker.cs.
    • SettingsUtil is probably easy enough to replace with source generators? replaced with source generator in f2a47941058e0582c44014138911120ccce7d410
    • BinaryQuickSerializer is only used in WonderSwan.IStatable.cs and probably could be easily factored out. removed in 8941bac1cedc3fda4c78c85713ca4bb72c49def2
    • BizInvoker could probably be replaced using source generators and .NET function pointers.
    • BizExvoker is not actually used anymore (remnant of C# waterbox days), so that can just be removed. removed in 5c475ce8989367c5836499e50afbeb7265fcb36c
    • NLua also uses it technically, but the code is unused and can be easily removed. removed in 582446651fb8eb7dfc4be056c6838c9e5cd308e6

Various other limitations also exist but don't appear to apply to BizHawk (or are just implied by trimming requirement).

see .NET Blog post on this subject

see Meziantou's blog post Accessing private members without reflection in C# re: [UnsafeAccessor]

see also #2654 and Yoshi's notes re: Web target

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with blocker #3767, then inspect BizInvoker.cs and BizInvokeUtilities.cs, the remaining files explicitly identified as using Reflection.Emit. Review the Native AOT limitations and determine the scope needed for BizHawk's build. Done means a supported AOT build works without the listed dynamic-loading or runtime-code-generation dependencies, with affected functionality verified.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, wasm
Domain
build-system, devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.