CheerpX

Native code virtualization as a JavaScript library

Version %CX_LATEST%Discord serverGitHub repositoryGitHub issues

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.

<script src="https://cxrtnc.leaningtech.com/%CX_LATEST%/cx.js"></script>

Why CheerpX?

CheerpX is perfect for web-based IDEs, programming tutorials, virtual machines, and interactive demos.

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

  • Without modifications
  • Without recompilation
  • Without source-code
  • Fully client-side

It can also be used to provide a secure sandbox for untrusted code. CheerpX is very robust and deployed as part of WebVM and PythonFiddle. It is also used in production environments as part of CheerpX for Flash, an enterprise solution to run legacy Adobe Flash content in the browser.

Get started

Licensing

CheerpX is free to use for personal projects, most non-commercial applications, and for technical evaluations. See licensing for details.

How does CheerpX work?

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 preprocessing steps. 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 such as Node.js, which includes the V8 engine and its remarkable JIT and code garbage collection.

CheerpX currently focuses on user mode code, on top of a Linux-compatible system call interface. Although this layer is not 100% complete it covers an extended subset of Linux capabilities and it is sufficient to run most applications. We are also working on a full system emulation mode, with DOS-era applications and games already supported.

Comparisons

CheerpX versus cloud VMs

Cloud VMs are the most common solution to run native logic for use by a Web application, but also have significant drawbacks in terms of computational costs and user data ownership.

CheerpX is a client-side solution, which means that 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 complex application will most likely have multiple target-dependent code paths or definition, so the effort required is not dissimilar from porting the application to a new native architecture.

CheerpX versus v86/JSLinux

CheerpX virtualization the system as a higher level. While v86 and JSLinux emulate specific hardware peripherals, CheerpX implements Linux system calls.

They also require the entire disk image to be downloaded ahead-of-time. A 2GB complete Debian system would not be a practical option. CheerpX can stream the disk image from the server as needed.

Moreover, 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.

Community

Have a question, looking for inspiration, or just want to chat?

Join our Discord server Follow us on Twitter
Was this page helpful?
Suggest changes