CheerpX

Native code virtualization as a JavaScript library

CheerpX is an x86 virtualization technology for running executables and operating systems entirely client-side. It’s an always available, zero-cost virtual machine with guaranteed data privacy, powered by a WebAssembly JIT engine.

What!?

CheerpX enables you to run existing 32-bit x86 native binaries and Linux distributions:

  • without modifications;
  • without recompilation;
  • without source-code;
  • fully client-side.

CheerpX is perfect for web-based IDEs, programming tutorials, virtual machines, and interactive demos. It can also be used to provide a secure sandbox for untrusted code. CheerpX is used by WebVM, PythonFiddle, and has been fully tested in production as part of CheerpX for Flash, an enterprise solution to run legacy Adobe Flash content in the browser.

If you’re looking to run Java in the browser, check out CheerpJ.

Comparisons

CheerpX versus cloud VMs

Cloud based solutions are trivial to implement but also have significant drawbacks in terms of computational costs and user data ownership.

CheerpX is a client-side solution, which means that the code is executed directly in the browser, without any server-side component. This has several advantages:

  • Cost effective. No need to pay by the minute for cloud VMs.
  • Improved user experience. No latency. Works offline.
  • Private. User data never leaves their browser.
  • Secure. No risk of bad actors running malicious code on your servers.
  • Scale. Client-side compute increases with the number of users.

CheerpX versus WebContainers

CheerpX is a more general solution than WebContainers.

WebContainers can only execute languages that are natively supported on the Web. In practice, this means only Node.js or WebAssembly can be executed. CheerpX supports any x86 executable.

CheerpX versus porting to WebAssembly

Porting a large C/C++ codebase to WebAssembly is not necessarily a simple endeavor. For instance, a programming language implementation will most likely have multiple target-dependent code paths or definition, so the effort required is not dissimilar from porting the language to a new native architecture.

CheerpX versus v86/JSLinux

CheerpX virtualises at a higher level. v86 and JSLinux emulate specific hardware peripherals, whereas CheerpX implements Linux system calls.

They also require the entire disk image to be downloaded ahead-of-time (so full 600MB Debian is not really an option). CheerpX can stream the disk image from the server as needed.

v86 and JSLinux are hobby projects, whereas CheerpX is a commercial product with a dedicated team of engineers. If you’re shipping with CheerpX, you can rely on us to provide support and maintenance.

How it works

At its core, CheerpX is a two-tier emulator for the x86 architecture implemented in C++ and compiled to JavaScript and WebAssembly. There is both an interpreter and a sophisticated JIT compiler that is able to generate efficient WebAssembly representations for hot code. The whole process is 100% automated and requires no metadata or assumptions whatsoever. The system is so robust that it can deal with applications that generate new code internally at runtime, and even with self-modifying code.

This means that you can actually run things like Node.js, including the full V8 engine with its remarkable JIT and code garbage collection. Demo.

CheerpX currently focuses on user mode (ring 3), and does not fully emulate the kernel (ring 0). We do, however, implement a subset of the Linux system call interface, which is enough to run most applications. We are working on a full system emulation mode - DOS already works.

Community

Have a question, want some inspiration, or just want to chat? Join our Discord community!

Was this page helpful?
Suggest changes