MCPcopy Index your code
hub / github.com/Starlight-JS/starlight

github.com/Starlight-JS/starlight @0.0.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.0.1 ↗ · + Follow
2,019 symbols 6,099 edges 142 files 221 documented · 11%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Starlight

Starlight is a JS engine in Rust which focuses on performance rather than ensuring 100% safety of JS runtime.

Discord <- Starlight channel in Programming language dev community

Features

  • Bytecode interpreter
  • Mostly-precise GC
  • Polymorphic inline caches
  • Startup snapshots
  • Executable JS bundles

Why?

I was developing my own JS-like language but then I realized that there's no point in it and decided to try to create optimized JS engine with JIT,inline caches, fast GC and other fun stuff that is interesting me.

Starlight VS Boa

Starlight is much faster than Boa in a lot of ways one of which is object property accesses but Starlight is designed more like JS engine that can be potentionally used in web browsers like V8 and JSC and not something small and embedabble (we have 1.6MB binary through!).

Startup snapshots

The ES specification includes lots and lots of builtin objects. Every new single Runtime type instance has to set-up and initialize these builtins at the time runtime is created. It takes quite some time to do this from scratch.

To solve this problems V8-like startup snapshots were implemented. Startup snapshots just deserialize previously serialized heap state which might reduce load times singnificantly (not much difference right now since not that many builtins is implemented). Custom JS functions and objects could be added to global state and then serialized into binary file and deserialized later which removes overhead of initializing objects, parsing source code and compiling it to bytecode to just simple deserialization of raw bytes. Think of it like AOT compilation but simpler and smaller.

Build and install instructions (Linux,*BSD,macOS)

Executing these two commands will result in building starlight and installing libraries to necessary folders:

git clone https://github.com/starlight-js/starlight
./build.sh # use build-debug.sh for debug build

NOTE: macOS and FreeBSD do not use *.so file format so .dynlib files from target/release should be installed manually.

Bundles

Starlight supports creating executable JavaScript bundles. To create one starlight-bundle could be used: just run it on one of JS files like starlight-bundle file.js file-bundle and it will produce statically linked executable file file-bundle which can be run. Internally bundle is just heap snapshot after JS file was compiled and simple call to execute code from this snapshot.

NOTE starlight-bundle might panic when run on platform that does have cc available in PATH so --output-c option should be used and C file should be compiled and linked manually.

Get Started

Working with nightly Rust

# https://rust-lang.github.io/rustup/concepts/channels.html
rustup toolchain install nightly
rustup run nightly rustc --version
rustup default nightly

Run Js File

cargo run --bin sl examples/hello-world.js

Extension points exported contracts — how you extend this code

Trace (Interface)
Indicates that a type can be traced by a garbage collector. This doesn't necessarily mean that the type is safe to allo [47 …
crates/starlight/src/gc/cell.rs
RetainMut (Interface)
Trait that provides `retain_mut` method. [2 implementers]
crates/wtf-rs/src/lib.rs
GcCell (Interface)
`GcCell` is a type that can be allocated in GC gc and passed to JavaScript environment. All cells that is not part of [34 …
crates/starlight/src/gc/cell.rs
SwapByteOrder (Interface)
(no doc) [2 implementers]
crates/wtf-rs/src/swap_byte_order.rs
Deserializable (Interface)
(no doc) [46 implementers]
crates/starlight/src/gc/snapshot/deserializer.rs
Serializable (Interface)
(no doc) [59 implementers]
crates/starlight/src/gc/snapshot/serializer.rs
JsClass (Interface)
(no doc) [26 implementers]
crates/starlight/src/vm/class.rs

Core symbols most depended-on inside this repo

push
called by 343
crates/starlight/src/vm/structure.rs
at
called by 215
crates/starlight/src/vm/arguments.rs
emit
called by 212
crates/starlight/src/bytecompiler.rs
intern
called by 210
crates/starlight/src/vm/symbol_table.rs
pop
called by 198
crates/starlight/src/vm/structure.rs
to_string
called by 175
crates/starlight/src/vm/value.rs
len
called by 129
crates/starlight/src/vm/string.rs
add
called by 121
crates/starlight/src/vm/structure_builder.rs

Shape

Method 1,325
Function 441
Class 186
Enum 48
Interface 19

Languages

Rust98%
TypeScript2%

Modules by API surface

crates/starlight/src/vm/value.rs105 symbols
crates/starlight/src/vm/object.rs103 symbols
crates/starlight/src/gc.rs82 symbols
crates/starlight/src/bytecompiler.rs72 symbols
crates/starlight/src/bytecode/profile.rs72 symbols
crates/starlight/src/jsrt/date.rs69 symbols
crates/starlight/src/vm/structure.rs67 symbols
crates/starlight/src/vm/function.rs60 symbols
crates/starlight/src/vm.rs48 symbols
crates/starlight/src/gc/cell.rs47 symbols
crates/starlight/src/codegen.rs45 symbols
crates/starlight/src/vm/property_descriptor.rs40 symbols

For agents

$ claude mcp add starlight \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact