JIT services

From Nintendo Switch Brew
Revision as of 14:48, 15 April 2020 by Yellows8 (talk | contribs)
Jump to navigation Jump to search

JIT is a sysmodule for run-time code generation (allowing for overlapping R-X and RW- views of memory). This was added to retail with [10.0.0+]. This was also supported in sdknso for a number of versions prior.

nnMain just initializes ro:1, then starts hosting the service from the main-thread with max_sessions=1 (threads are not created for service-hosting).

This is intended to only be used by Applications. The initialization in sdknso uses PrepareForJit at the start. sdknso later uses svcCreateCodeMemory.

This loads the user-specified NRO into sysmodule-context ("DllPlugin"), and calls various symbols from that NRO. It seems the code writing (in cmd GenerateCode) is done via symbol-calling, allowing the NRO to handle input_buffer->code translation+writing.

jit:u

This is "nn::jitsrv::IJitService".

Cmd Name Notes
0 CreateJitEnvironment Returns an #IJitEnvironment

IJitEnvironment

This is "nn::jitsrv::IJitEnvironment".

Cmd Name
0 GenerateCode
1 Control
1000 LoadPlugin
1001 GetCodeAddress