Skip to content


Run Linux on… JavaScript?!

JavaScript logo 150x150 Fabrice Bellard built an x86 PC emulator using JavaScript. He’s even gone so far as to install Linux kernal 2.6.20 on top of it. “Thee code is written in pure Javascript using Typed Arrays which are available in recent browsersm,” Bellard wrote. It works in Firefox and Chrome 11, but not not Chrome 12.

As for the Linux instance, Bellard wrote: “The disk image is just a ram disk image loaded at boot time. It contains a filesystem generated with Buildroot containing BusyBox. I added my toy C compiler TinyCC and my unfinished but usable emacs clone QEmacs.” You can see Linux running JavaScript here.

Sponsor

JS/Linux screenshot

Bellard did it just for fun, but he speculates that it could be useful for the following purposes:

  • Benchmarking of Javascript engines (how much time takes your Javascript engine to boot Linux ?). For this particular application, efficient handling of 32 bit signed and unsigned integers and of typed arrays is important.
  • Client side processing using an x86 library, for example for cryptographic purposes. For such application, the x86 emulator can be modified to provide an API to load x86 dynamic libraries and to provide a js-ctypes like API to call the C/C++ functions from javascript.
  • A more advanced version would allow to use old DOS PC software such as games.

Oddly enough, he found that Linux ran twice as fast on Jaeger Monkey as it did on V8. He’s not sure why.

Discuss


Posted in General, Technology, Web.

Tagged with .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.



Some HTML is OK

or, reply to this post via trackback.