iNDS icon indicating copy to clipboard operation
iNDS copied to clipboard

JIT support

Open Wh0ba opened this issue 6 years ago • 14 comments

I'm sorry if I'm rushing the development of this project

But adding JIT support could really help with emulation like 200% Just like we see inside PPSSPP all the amazing performance is because of JIT

And thanks in advance

Wh0ba avatar May 26 '18 13:05 Wh0ba

There is JIT support, but only for 32bit devices :/

AngryKiller avatar May 27 '18 09:05 AngryKiller

There was a discussion earlier today related to a year old post by qwertyoruiop on Reddit regarding a release of a library which brings JIT support in iOS 9 and later. Might be worth checking out in the future: https://www.reddit.com/r/jailbreak/comments/5qy2x0/beta_jitsupport_kernelless_jit_support_for_ios_9/

FrederickGeek8 avatar Jun 29 '18 20:06 FrederickGeek8

There is further discussion from RetroArch here: https://github.com/libretro/RetroArch/issues/3468

The appropriate syscall and flags are documented if you scroll further down in the issue that I linked.

kprinssu avatar Jul 05 '18 13:07 kprinssu

@FrederickGeek8 To me it looks like @WilliamLCobb has already implemented the syscall and flags but newer iOS versions have broken things. Additionally, iNDS uses 4096 sized pages and I am pretty sure that is not the case for 64bit devices.

I did some quick checks into how PPSPP implemented JIT. The implementation is in https://github.com/hrydgard/ppsspp/blob/master/Common/MemoryUtil.cpp and the iOS checks are done by calling PlatformIsWXExclusive. I took a look at the history of the file and there was a fix iOS here: https://github.com/hrydgard/ppsspp/commit/193b5f309490bac0c5a5d5d178c5274252c9a610#diff-2b8fbb5b62261b971fe141ef565cdbaf

hrydgard also explains a bit more of the fixes here, https://github.com/hrydgard/ppsspp/issues/9232 Hopefully this helps.

kprinssu avatar Jul 18 '18 02:07 kprinssu

@kprinssu Thanks for that. I've been looking at the same thing. ~~It's starting to look like it shouldn't be as difficult as I originally expected it to be given the preexisting literature.~~ This is going to be a long and difficult project IMO. The deeper I dig, the harder it looks.

I was just trying to decide whether I should look into qwertyoruiop's library (despite it not supporting non-jailbroken devices) since in the comments it seemed like people had some problems with PPSPP's implementation. I just tweeted at qwertyoruiop about whether his JITSupport library is still maintained but I doubt I will receive a reply (alas, he is popular and probably has flooded mentions).

EDIT (while I was writing this): from @ qwertyoruiop on Twitter

i haven't been maintaining it much as it appeared like there was no interest when it was released, but AFAIK it should still work.. I think it was on the http://yalu.qwertyoruiop.com repo. You can freely rehost it if you so wish.

FrederickGeek8 avatar Jul 18 '18 02:07 FrederickGeek8

@kprinssu If you think you have a good grasp on this, feel free to submit a PR. I'm going away this weekend (without my computer), so I might not be able to put anything out before then. If you do decide to take it up, I'll be available on Gitter if you have any questions.

FrederickGeek8 avatar Jul 18 '18 05:07 FrederickGeek8

AsmJIT has an arm backend currently being worked on. Since DeSmuME uses AsmJIT for JIT, getting JIT support for ARM/64 shouldn't be too hard. Otherwise, updating Lightning JIT to 2.1.2 (we are currently on 1.2, which was released over 10 years ago) should prove to be useful too.

tangalbert919 avatar Aug 29 '18 14:08 tangalbert919

@WilliamLCobb Remember that issue with the JIT hack to allow it to run on jailed devices? https://github.com/WilliamLCobb/iNDS/issues/44#issuecomment-220731803

PPSSPP just received a pull request and was merged that fixes the issue. https://github.com/hrydgard/ppsspp/pull/12421

DuIslingr avatar Oct 15 '19 16:10 DuIslingr

@Dulslingr This will make JIT possible, someone just needs to write the library to do it

Honestly our best is waiting for someone to write ARM64 JIT for a Nintendo Switch port of DeSmuME or MelonDS. Once that happens we can easily port it to iOS

WilliamLCobb avatar Nov 06 '19 21:11 WilliamLCobb

Sadly it seems the fix is broken for non jailbreak. some workaround is still needed for non jailbreak still.

DuIslingr avatar Nov 12 '19 00:11 DuIslingr

@FrederickGeek8 @WilliamLCobb Just as a heads-up: but melonDS now has working ARM64 JIT for the Nintendo Switch, which has been merged into the project's official JIT branch (not sure if it's in master yet). Reportedly, the Switch can play most games now at full speed, which bodes well for newer iOS devices given how much weaker its CPU is than Apple's recent chips.

Actually, given the rate of melonDS's progress, I wonder how much of a headache it would be to port the core over to iOS, using the iNDS UI as a front-end. Partly-working DS WiFi emulation on iOS devices would be pretty slick, as would its OpenGL internal upscaling with minimal performance cost!

a-hurst avatar Apr 20 '20 19:04 a-hurst

Apologies if I'm reviving an old thread, but in light of the recent news that iOS 14.2 now supports JIT, could we now hope for full JIT support in NDS?

m4rkd7 avatar Nov 12 '20 09:11 m4rkd7

@m4rkd7 That's great news! I suppose implementing it is possible, but I can't give a timeline at this time. I'll have to look into how JIT works on iOS 14.2. Any help is welcomed :)

FrederickGeek8 avatar Nov 13 '20 03:11 FrederickGeek8

An update (for those who don't already know) from that I posted in #222

Regarding JIT: We already have a thread open about this #16. Unfortunately (and I'm going to post this on the thread now), it looks like JIT was removed in 14.4 and therefore it doesn't really make sense to support it at this point. It was a dream come true during 14.2, but alas it looks like that was just a dream too.

FrederickGeek8 avatar Mar 04 '21 03:03 FrederickGeek8