All Projects → MichaReiser → Speedy.js

MichaReiser / Speedy.js

Licence: mit
Accelerate JavaScript Applications by Compiling to WebAssembly

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to Speedy.js

Bytecoder
Rich Domain Model for JVM Bytecode and Framework to interpret and transpile it.
Stars: ✭ 401 (+33.67%)
Mutual labels:  compiler, llvm, webassembly
Nxdk
The cross-platform, open-source SDK to develop for original Xbox: *new* xdk
Stars: ✭ 200 (-33.33%)
Mutual labels:  compiler, llvm
Lhc
The LLVM LHC Haskell Optimization System
Stars: ✭ 188 (-37.33%)
Mutual labels:  compiler, llvm
Customasm
💻 An assembler for custom, user-defined instruction sets! https://hlorenzi.github.io/customasm/web/
Stars: ✭ 211 (-29.67%)
Mutual labels:  compiler, webassembly
Wag
WebAssembly compiler implemented in Go
Stars: ✭ 177 (-41%)
Mutual labels:  compiler, webassembly
Llvm Guide Zh
User Guides For those new to the LLVM system.(LLVM系统的新用户指南,中文翻译版)
Stars: ✭ 180 (-40%)
Mutual labels:  compiler, llvm
Ppci
A compiler for ARM, X86, MSP430, xtensa and more implemented in pure Python
Stars: ✭ 210 (-30%)
Mutual labels:  compiler, webassembly
Rhine
🔬 a C++ compiler middle-end, using an LLVM backend
Stars: ✭ 157 (-47.67%)
Mutual labels:  compiler, llvm
Ts Llvm
TypeScript to LLVM compiler (abandoned)
Stars: ✭ 230 (-23.33%)
Mutual labels:  compiler, llvm
Wasm Loader
✨ WASM webpack loader
Stars: ✭ 604 (+101.33%)
Mutual labels:  webpack-loader, webassembly
Webpack Core Usage
webpack2完整系列课程,欢迎阅读。同时欢迎移步我的react全家桶文章全集: https://github.com/liangklfangl/react-article-bucket
Stars: ✭ 94 (-68.67%)
Mutual labels:  webpack-loader, compiler
Play with llvm
A book about LLVM & Clang(中文开源书:玩转 LLVM)
Stars: ✭ 175 (-41.67%)
Mutual labels:  compiler, llvm
Compile To Web
Discover what languages can be compiled to Web Assembly
Stars: ✭ 164 (-45.33%)
Mutual labels:  compiler, llvm
Prototype
(deprecated) The journey continues at ASNEXT: https://github.com/AssemblyScript/assemblyscript
Stars: ✭ 2,114 (+604.67%)
Mutual labels:  compiler, webassembly
Jitfromscratch
Example project from my talks in the LLVM Social Berlin and C++ User Group
Stars: ✭ 158 (-47.33%)
Mutual labels:  compiler, llvm
Binaryen.js
A buildbot for binaryen.js, a port of Binaryen to the Web, with TypeScript support.
Stars: ✭ 201 (-33%)
Mutual labels:  compiler, webassembly
Cone
Cone Programming Language
Stars: ✭ 257 (-14.33%)
Mutual labels:  compiler, webassembly
Assemblyscript
A TypeScript-like language for WebAssembly.
Stars: ✭ 13,152 (+4284%)
Mutual labels:  compiler, webassembly
Wah
a slightly higher-level language superset of webassembly
Stars: ✭ 147 (-51%)
Mutual labels:  compiler, webassembly
Llvm
[MERGED UPSTREAM] AVR backend for the LLVM compiler library
Stars: ✭ 222 (-26%)
Mutual labels:  compiler, llvm

Speedy.js

npm version Build Status Code Climate

Speedy.js is a compiler for a well considered, performance pitfalls free subset of JavaScript targeting WebAssembly. Because WebAssembly is statically-typed, the project uses TypeScript as type-checker and to resolve the types of the program symbols.

The project is very experimental and still far away from being production ready.

Getting Started

Setup LLVM

First, you need an LLVM installation that includes the experimental WebAssembly target. You can test if your LLVM installation includes the WebAssembly backend by running

llvm-config --targets-built

If the output contains the word WebAssembly you are good to go (continue with Install Cross Compiler). If not, then you have to build LLVM from source by following these instructions.

After LLVM has been built and is installed, set the path to the llvm-config executable (it is located in the installation directory) using npm config set or an .npmrc file in your project:

npm config set LLVM_CONFIG /llvm/install/dir/llvm-config

or when using the .npmrc file:

LLVM_CONFIG = "/llvm/install/dir/llvm-config"

Install Cross Compiler

Now the compiler can be installed using npm install (or yarn or whatever). Also install the custom TypeScript version that has support for the int base type.

npm install --save-dev speedyjs-compiler MichaReiser/TypeScript#2.3.3-with-int

Prebuilt VM

For those just interested in playing around the prebuilt Ubuntu Ubuntu VM (user: speedyjs, password: welcome) might be interesting. It contians the Speedy.js Playground project in the user's home directory.

Compile your first Script

You have to mark Speedy.js functions with the use speedyjs directive. Furthermore, you have to declare Speedy.js functions that are called from a pure JavaScript function as async (see fib).

fib.ts:

async function fib(value: int): Promise<int> {
    "use speedyjs";

    return fibSync(value);
}

function fibSync(value: int): int {
    "use speedyjs";

    if (value <= 2) {
        return 1;
    }

    return fibSync(value - 2) + fibSync(value - 1);
}

async function main() {
    console.log(await fib(40));
}

The compiler will compile the fib and fibSync function to WebAssembly whereas the main function remains in pure JS.

The script can be compiled using:

$(npm bin)/speedyjs fib.ts

which outputs the fib.js file.

To compile all files in the current directory omit any file names or pass multiple file names to the CLI. More details about how to use the CLI are documented in the wiki.

WebPack Loader

The package loader contains a WebPack loader for Speedy.js. Consult the README of the loader package for more details.

Benchmark

Benchmark

Setup the Development Environment

Clone the git repository:

git clone --recursive https://github.com/MichaReiser/speedy.js.git

Ensure that LLVM is set up (see Getting Started).

Run the install and bootstrap scripts in the just cloned directory:

npm install
npm run bootstrap
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].