SSE/Opcode emulation

As the computer I’m usually using only has a core 2 duo which does not support sse4, I’m wondering if op code emulation for those older (generally still perfectly usable systems) would make sense. For linux I found
an opcode emulator (GitHub - mirh/opemu-linux: Linux kernel module for emulating SSE instructions).

I wonder if it would be possible to include something like that in the Haiku kernel because that would allow for older computers to run applications that are dependant on sse3/4 instructions.

I could try to look into implementing something like that, though I’d probably fail miserably, but I could try. I have some little understanding of kernel development though not really with Haiku.

Do you think that something like that would make sense?

1 Like

For what purpose? Haiku applications are supposed to detect and use cpu features at runtime, thus eliminating the need to recompile everything for a specific processor.

I don’t know if it is needed to run any real worls haiku apps currently, but if it is that would probably be considered a bug.

Do you have an example of applications that would be helped by this?

If I’m reading the original post correctly, a good example use case would be WebPositive, which requires SSE2 - otherwise you’d need to use NetSurf: R1/beta3 – Release Notes | Haiku Project

1 Like

The question is about sse4, webkit is a bit of an oddball, the JIT is complicated and we can’t easily make it not use sse2 iirc. :confused:

The question is also if you emulate sse2 if the hardware is fast enough for webkit regardless of this. Netsurf is definetely more lightweight.

Well, if the OS can do it, why force application developers to do it manually? Sounds like a good idea to me to provide a fallback.

There is no JIT for 32bit anymore in WebKit. So it should be possible to get it running again without SSE2, if someone can figure out how to insert the flags at the right place. There are patches for GTKWebKit in Debian to do this, I think.

However, the browser ends up being so slow on these old machines, and a bit slower also on modern machines. This solution with emulation seems better: provide best performance on modern machines, and still manage to run on old ones.

5 Likes

Sorry for taking this long for a reply, I had (and still have) a lot of school stuff to do.

I also have to understand the kernel and the sse instructions. The Invalid Opcode exceptions would need to be catched so the thread frames could be changed accordingly and there’d need to be some place where the (virtual) registers get saved. This would probably need to be done for each architecture seperatly.

I’ll have a closer look once I have a bit more time.

I think it should be fast enough for light sites, though I generally agree that for pre-sse2 computers netsurf might be the better choice. However I’m thinking more about sse3 and especially sse4 emulation as those computers missing it (sse4 on a core 2 duo / quad) are still definetly fast enough for daily use (I’m using one right now) but some applications only don’t run on them because they need sse4.

Do you have any examples? These should be reported to haikuports and fixed there.

1 Like

There are no programs (at least none that I know of) in haikuports that require SSE3 or SSE4, but some new programs (mainly proprietary and Windows applications with wine) could require them.

(I couldn’t find an example for an open-source program that absolutely requires sse4 but one program where opcode emulation could help would be Yuzu which requires the fma instruction set)