Skip to content

telecos/stator

Repository files navigation

Stator

Stator is an experimental JavaScript engine written in Rust, designed to be embedded in browser-like environments such as Chromium via a stable C FFI layer.

CI Coverage License: MIT

Architecture

┌──────────────────────────────────────────┐
│           Chromium / Embedder            │
│   (C++ content layer, Node.js, etc.)     │
└───────────────────┬──────────────────────┘
                    │  C ABI  (stator.h)
┌───────────────────▼──────────────────────┐
│              stator_ffi                  │
│  cdylib / staticlib — opaque C handles   │
│  stator_isolate_create / _gc / _destroy  │
└───────────────────┬──────────────────────┘
                    │  Rust rlib
┌───────────────────▼──────────────────────┐
│             stator_core                  │
│  Heap · GC · Objects · Parser · IR · VM  │
└──────────────────────────────────────────┘

Additional crates:

Crate Type Purpose
stator_core rlib Engine internals (heap, GC, IR, VM)
stator_ffi cdylib + staticlib Stable C API for embedders
st8 bin Interactive JavaScript shell (like V8's d8)
stator_test262 bin Test262 conformance harness runner

Requirements

Tool Minimum version
Rust (stable) 1.85 (edition 2024)
Cargo bundled with Rust

Build

# Build all crates
cargo build

# Build in release mode
cargo build --release

The C FFI artifacts are written to:

  • target/release/libstator_ffi.a — static library (Linux / macOS)
  • target/release/libstator_ffi.so — shared library (Linux)
  • target/release/stator_ffi.lib / stator_ffi.dll — Windows equivalents

Test

cargo test

st8 CLI

st8 is the Stator command-line shell, analogous to V8's d8. It executes JavaScript files, evaluates inline snippets, and supports Chrome DevTools Protocol (CDP) inspection.

# Build the shell
cargo build --bin st8

# Execute a JavaScript file
cargo run --bin st8 -- file.js

# Evaluate an inline expression
cargo run --bin st8 -- -e '1 + 2'

# Run with Chrome DevTools inspector on port 9229
cargo run --bin st8 -- --inspect file.js

# Run and pause before the first statement
cargo run --bin st8 -- --inspect-brk file.js

Example session:

$ echo 'print(6 * 7)' > hello.js
$ cargo run --bin st8 -- hello.js
42

Built-in globals

Global Description
print(...args) Prints arguments joined by a space, followed by a newline
console.log(...args) Alias for print
WebAssembly Full WebAssembly JS API namespace

Additional options

Flag Description
-e '<code>' Evaluate an inline JavaScript expression
--inspect[=port] Start CDP inspector (default port: 9229)
--inspect-brk[=port] Start inspector and pause before first statement
--emit-snapshot=<path> Serialize built-in globals to a snapshot file
--snapshot=<path> Load globals from a snapshot for faster startup
--jit-stats Print JIT compilation statistics after execution

Embedding example

See examples/mini_browser for a minimal C++ application that demonstrates how Chromium's content layer would create and destroy isolates via the C FFI API.

Roadmap

See the open issues and project board for the current roadmap and planned milestones.

License

Stator is distributed under the MIT License.

About

Rust implementation for JavaScript engine

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages