News Archive (1999-2012) | 2013-current at LinuxGizmos | Current Tech News Portal |    About   

Javascript emulator runs Linux in web browser

May 18, 2011 — by Eric Brown — from the LinuxDevices Archive — 3 views

The developer of the QEMU emulator has programmed a new PC emulator written in Javascript, capable of running Linux entirely within a web browser. Fabrice Bellard's Javascript emulator has been tested on Firefox 4 and Google Chrome 11, enabling a Linux 2.6.2 kernel to run in RAM, no matter what the underlying operating system.

Bellard posted the emulator on his Bellard.org site, accompanied by technical notes explaining that some of the code is inspired by the x86 dynamic translator present in his widely used QEMU emulator. Key differences include the fact that the translator is used as an interpreter in this case, writes Bellard in his notes.


Fabrice Bellard's Linux Javascript emulator

(Click to enlarge)

The emulator exploits the growing speed of the Javascript implementations in today's browsers, including Mozilla's Firefox 4 and Google's Chrome 11, the two browsers that have been tested so far.

According to Bellard, the emulator performance is equivalent to a 486 PC without a floating point unit (FPU), equipped with an 8259 programmable interrupt controller, 8254 programmable interrupt timer, and a 16450 UART.

"The lack of FPU is not a problem when running Linux as the operating system because it contains a FPU emulator," writes Bellard in his technical notes. "In order to be able to run Linux, a complete MMU [memory management unit] is implemented."

Restrictions are said to include the lack of segment limit and right checks when accessing memory, the lack of CS/DS/ES/SS segment overrides, no single-stepping or real-mode, and no 16-bit protected mode. In device support, there are other limitations, including the current lack of network emulation.

Bellard wrote his own Javascript terminal, and used a Linux 2.6.20 kernel, although any older Linux kernel that includes an FPU emulator will do, he says. The disk image contains a file-system generated with Buildroot, containing BusyBox, as well as his own TinyCC compiler. It also includes "my unfinished but usable emacs clone QEmacs," he adds.

Bellard programmed the emulator as a way to learn how to write optimized code for recent Javascript engines, including Firefox 4's Jaeger Monkey and Chrome's V8. Bellard was puzzled as to why Firefox 4 ran the emulation about twice as fast as Chrome.

Possible uses for the emulator include a platform for benchmarking Javascript engines, as well as client side processing applications using an x86 library, for example for cryptographic purposes. A more advanced version would be able to run old DOS PC games in one's browser, he adds.

In addition to developing QEMU, Fabrice Bellard was the chief programmer behind the LZEXE compression engine and the FFmpeg A/V converter, according to a report in Geek.com. In addition, Bellard broke the world record for the computation of PI to 2,700 billion digits on Dec. 31, 2009, and held the record until Alexander J. Yee and Shigeru Kondo achieved five trillion digits on Aug. 2 of last year.


This article was originally published on LinuxDevices.com and has been donated to the open source community by QuinStreet Inc. Please visit LinuxToday.com for up-to-date news and articles about Linux and open source.



Comments are closed.