Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to replace browser javascript engine with LLVM?

Tags:

As a proof of concept, I would like to get a browser to be able to run LLVM IR. The basic idea would be that any language with an LLVM compiler, would be able to work as a first class citizen on the net. (Which is why I don't want to go the LLVM IR -> JS route for anything other than a "fallback")

The LLVM code should be able to all the same functions (e.g. DOM) with the same restrictions. I'm looking for pointers on getting started, where the best place to dive in is (I have C/C++ experience) and what the easiest browser is going to be to extend.

Ideally I'm looking for something very modular, so this is just another "scripting engine" as is the javascript one, as is any other future ones (e.g. direct python one)

Thanks very much

like image 781
Heptic Avatar asked Jun 12 '11 07:06

Heptic


People also ask

Can LLVM compile to WebAssembly?

There's a secret in the compiler community. LLVM can compile to web assembly. LLVM is a tool used by languages like Clang and Rust as a universial intermediate representation(IR) that can be compiled down to machine code output. Web assembly is one of those outputs.

Does V8 use LLVM?

WebAssembly is normally compiled from a source language, which means that developers need tools to use it. Because of that, the V8 team works on relevant open-source projects like LLVM, Emscripten, Binaryen, and WABT.

Does Emscripten use LLVM?

Emscripten is a complete compiler toolchain to WebAssembly, using LLVM, with a special focus on speed, size, and the Web platform. Compile your existing projects written in C or C++ — or any language that uses LLVM — to browsers, Node. js, or wasm runtimes.

Does Go compiler use LLVM?

There are three Go compiler implementations supported by the Go team. These are gc , the default compiler, gccgo , which uses the GCC back end, and a somewhat less mature gollvm , which uses the LLVM infrastructure.


1 Answers

Emscripten is an LLVM backend targeting asm.js, which may be executed on all major browsers. The project dates back to 2010. This translates the IR into asm.js for you. Ideally you should be able to expand the project to support additional languages as opposed to just C/C++; either that or as a launching pad to put the other components in place prior to writing your bindings for the execution environment against the browser interfaces you desire.

asm.js has been used to run the Unreal engine, along with porting DosBox for Archive.org's game archives.

like image 96
Mark Avatar answered Sep 17 '22 17:09

Mark