amiberry icon indicating copy to clipboard operation
amiberry copied to clipboard

Improve JIT compatibility

Open amyren1966 opened this issue 4 years ago • 32 comments

JIT seem to break compatibility also for system friendly applications. I notice this specially for programs made with Hollywood. RNOpdf is one example, as the script will fail (stack overflow) if launched when JIT is enabled. Also games made with Hollywood does fail, or act strange if JIT is on. This is the case for one of my own games, Runaway. They run fine when JIT is off, but quite slow. For comparisation, these apps and games does run fine on WinUAE with JIT.

So the feature request is as described in the title.

amyren1966 avatar Apr 10 '20 20:04 amyren1966

@amyren1966 Thanks for reporting this. I also have a few Hollywood apps I can test with, so have a scenario to recreate this with.

Normally it's TomB who's doing the JIT and low-level work, so if we can have a scenario to recreate the problem, I can open an issue with him afterwards. ;)

midwan avatar Apr 11 '20 08:04 midwan

@amyren1966 My Hollywood apps didn't seem to have a problem with JIT.

I'm assuming you're referring to this RunAway game? http://os4.aminet.net/package/game/wb/Runaway_OS3

I could run it normally in my installation, what kind of unexpected behavior did you notice?

midwan avatar Apr 12 '20 11:04 midwan

If JIT is on, the searchlight will stop moving after a while, and stay on just beside the position next to the barell. I guess that the sprite hangs at this position, while the real position is towards the barell. The player can now pass the light without being detected. Also the two guards will stop moving at certain positions. That is, they do move, but the sprites freezes at certain points for a while.

One of my other Hollywood game, donkey kong does work normally, and also one other Hollywood app I did try. But the RNOpdf app does crash for me if JIT is on. Did you try that one?

amyren1966 avatar Apr 14 '20 06:04 amyren1966

@amyren1966 I just tested RNOpdf with the Hollywood.pdf file (3.84 MB), on my AmigaOS 3.1.4.1 installation:

  • The 68k version worked normally
  • The FPU version showed an error (stack overflow) as you described.

Can you confirm the same with the other Hollywood apps you've tested with?

midwan avatar Apr 14 '20 17:04 midwan

I've opened an issue at Tom's repo about this: https://github.com/PandTomB/uae4arm/issues/7

midwan avatar Apr 14 '20 17:04 midwan

I confirm that non-FPU version of RNOPdf starts up when JIT enabled. FPU version will fail with JIT.

But my Runaway game is not compiled as a FPU version, and it will not work properly when JIT is enabled. The easiest way to spot this is by launching it, and wait. The searchligt will start moving, from the right side to the left, and then turn back. It will then stop before reaching the right side. If launched with JIT turned off it will continue moving.

Also I did test my other game, Donkey Kong (also an LCD conversion). This does not use FPU either. It will lauch and you can start playing. But if you start it (press "1" on the keyboard, or press the A button), then move 3 to 4 steps to the right, and then step back to the left using the arrow keys. The player will stop moving at one point, and the barells will pass you without generating a miss. Do this immidiately after pressing "1", then you should be able to test it without getting hit by the barells (or else you might just jump over a few barells first and wait until the path is clear). If JIT is disabled, the player will move as it should.

By the way. This is on OS3.9, 68030 / AGA chipset, but running on a P96 screen. I also tried testing it with 68020, same thing.

amyren1966 avatar Apr 15 '20 06:04 amyren1966

Thanks! I also noticed that disabling JIT FPU doesn't make a difference, so the problem is somewhere in the main JIT code, not the FPU specific part.

Let's give Tom some time to look into this.

midwan avatar Apr 15 '20 06:04 midwan

I don‘t know if it‘s the same issue, but playing Jim Power gives me sprites on wrong positions and faulty collisions. Playing without JIT seems to be correct but hell slow and sound stuttering.

andiweli avatar Dec 20 '20 10:12 andiweli

@andiweli Games and JIT are usually not a good combination, though there may be some exceptions (those that don't use the custom chipset but really want CPU power). Jim Power is kind of a special case, works normally on the RPI4 but on lower powered systems it works properly only with frameskip.

midwan avatar Dec 20 '20 10:12 midwan

Fixed with e0cd52cf2fecf7e6b55d0e76907dd4881f40efdf

midwan avatar Jan 23 '21 11:01 midwan

I notice this issue have been closed. But I still encounter the same issues with JIT enabled. Is this covered by another thread?

amyren1966 avatar Jan 26 '21 23:01 amyren1966

What kind of issues do you encounter?

solskogen avatar Jan 27 '21 07:01 solskogen

@amyren1966 I assume you're referring to the Hollywood made games mentioned above? If so, let's move those in a separate issue please, as the original mentioned here was actually fixed with the commit above. Looks like we're not 100% bug-free on the JIT engine yet! :)

midwan avatar Jan 27 '21 17:01 midwan

I am not sure what you refer to by "original mentioned here was fixed"? In the first post in this thread I mentioned two examples, RNOPdf and the Hollywood games. I just tested the FPU version of RNOPdf, and it still fails with the stack overflow error, and the game mentioned also still fails. I can make a new issue for this if you prefer, but it will still be the same issue as reported in this thread. Or did you test the RNOpdf FPU version successfully with JIT now after the fix?

amyren1966 avatar Jan 28 '21 07:01 amyren1966

I was referring to the RNOpdf tool which was originally reported having the problem. After the JIT fix mentioned above, I could test the tool and I didn't see the problem anymore. Perhaps I missed something however? I only tested this on 3.9, not on 3.1.4.x, so if the issue only occurs there, then we can revisit it.

midwan avatar Jan 28 '21 22:01 midwan

I am on OS3.9 also. RNOpdf comes in two editions for OS3, one compiled for FPU and one plain 68k. It is only the FPU version that crashes. I tested with version 1.3 from aminet.net. This is the same version that was available when I wrote the first post. (I have not tested the ECS/AGA 0.1 version)

amyren1966 avatar Jan 29 '21 11:01 amyren1966

I tested the FPU version (and it worked), but I'll run another test on a different OS installation also, to check if it behaves differently.

midwan avatar Jan 29 '21 12:01 midwan

I notice that your post "Fixed with e0cd52c" refers to AARCH64 Does it mean the fix is for 64bit version? In that case I might be on differrent version here, I dont think I am running 64 bit OS on my Pi4. BTW, my build is dated 23-01-2021,

amyren1966 avatar Jan 29 '21 15:01 amyren1966

Ah, perhaps that was it. I tested the 64-bit only, as the JIT fix was related to aarch64 only and I wanted to see what other JIT-related issues it may have fixed. I'll run another test on 32-bit to see, if it's still an issue there then I'll report it back to TomB. :)

midwan avatar Jan 29 '21 18:01 midwan

I can confirm this is happening under 32-bit JIT at least.

Interesting fact: RNOpdf requires the codesets.library which needed to be downloaded from Aminet. I wonder if the error comes from that library, not the application itself.

midwan avatar Jan 29 '21 18:01 midwan

Tested it again on 64-bit JIT also:

  • On WB3.9, it works fine
  • On 3.1.4, it shows a software failure message (not the stack overflow error that we get on 32-bit)

So this seems to be specifically happening on 3.1.4, from what I can tell. Not sure why, at this point.

midwan avatar Jan 29 '21 19:01 midwan

Under 3.1.4, it also throws a software failure for me even without JIT, so this part is not related to JIT.

midwan avatar Jan 29 '21 19:01 midwan

Reported to TomB: https://github.com/PandTomB/uae4arm/issues/11

midwan avatar Jan 29 '21 19:01 midwan

codesets.library is a requirement for all Hollywood programs. It is listed as one of the requirements for the Hollywood Player. Hollywood is a scripted language, and all executables made with Hollywood are basicly the Hollywood Player program packed together with the script and other needed files like sound samples, images etc.

amyren1966 avatar Jan 29 '21 20:01 amyren1966

What 64 bit Os distro are you using for Rpi4?

amyren1966 avatar Jan 30 '21 21:01 amyren1966

Manjaro: https://manjaro.org/download/#raspberry-pi-4

midwan avatar Jan 30 '21 21:01 midwan

Thanks. Are there any benfits with 64 bit over 32 bit, apart from the JIT fix for 64 bit. My Rpi4 is the 4GB version.

amyren1966 avatar Jan 30 '21 22:01 amyren1966

@amyren1966 Amiberry runs much faster under 64-bit, mostly due to a faster JIT implementation there. Also, with Manjaro you get the latest versions of drivers and libraries directly (it's a rolling distro), so you benefit from any bugfixes there much sooner than in RPI OS. :)

midwan avatar Jan 30 '21 23:01 midwan

Testing Manjaro (KDE Plasma) now. I'm getting this error when trying to compile amiberry-dev g++: error: unrecognized command-line option ‘-mfpu=neon-fp-armv8’

amyren1966 avatar Jan 31 '21 21:01 amyren1966

That's because you tried compiling the 32-bit target. Try with PLATFORM=pi64

midwan avatar Jan 31 '21 22:01 midwan