Hacker News new | past | comments | ask | show | jobs | submit login
Porting Linux to a new processor architecture, Part 2 (lwn.net)
90 points by vezzy-fnord on Sept 15, 2015 | hide | past | favorite | 6 comments



Call me crazy, but what I would really like to see is a port to the Javascript "architecture", that you can compile via emscripten. In principle this should already be possible by using the current User Mode Linux target. But I guess no one was insane enough so far to try it.


A good approach might be to add a coprocessor to jor1k that validates and accepts page sized chunks of asm.js code for execution in a restricted manner. Validation would check that memory accesses go through a software MMU, all loops can escape on timeout or other events, etc. Emscripten would need modification to emit collections of restricted code blocks that make up an executable. The kernel and userspace would be incrementally ported until the regular emulator is wholly unnecessary.


Well, just look at these lines of code: https://github.com/s-macke/jor1k/tree/master/js/worker/or1k/...

I tried something like this already. I mean to recompile parts of the code into Javascript. In my test cases the speed benefit was a factor of two or three. However in the real world, it was around a factor of two slower for different reasons.

1. The heuristic to find code chunks, which are good to recompile takes a lot of time and memory.

2. To stay on the safe side I can only recompile from jump to jump like QEMU does. Anything else would mean a much more complicated heuristic and recompilation which would beat the complexity of QEMU.

3. asm.js code runs through an foreign function interface. That means, you have to stay very long in the asm.js styled code that it is worthwhile. I got a drop of a factor of 10 in speed when I try to compile ~20 lines of code into asm.js code instead of normal Javascript code.


Yea, even if you increase the chunk size and omit dynamic recompilation, there still may be unavoidable slowdowns due to shoving all that Javascript through the browser.

I am currently designing a software-only CPU with sliding register window (128 entries) and dirt simple instruction set. The for/switch/loop emulator for it should be quite a bit faster than any emulated silicon CPU.


You know what they say... scratch your own itches. ;)


For those that didn't see the first part https://lwn.net/Articles/654783/




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: